From 4a7148c835abdde44160d32399c8240d2e75fb4d Mon Sep 17 00:00:00 2001 From: EwoutV Date: Thu, 23 May 2024 09:58:00 +0200 Subject: [PATCH] fix: project service --- .../src/composables/services/admin.service.ts | 24 +++--- .../composables/services/assistant.service.ts | 48 ++++++------ .../composables/services/course.service.ts | 76 +++++++++---------- .../composables/services/docker.service.ts | 36 ++++----- .../services/extra_checks.service.ts | 24 +++--- .../composables/services/faculty.service.ts | 24 +++--- .../src/composables/services/group.service.ts | 30 ++++---- frontend/src/composables/services/helpers.ts | 32 ++++---- .../composables/services/project.service.ts | 64 ++++++++-------- .../services/structure_check.service.ts | 30 ++++---- .../composables/services/student.service.ts | 60 +++++++-------- .../services/submission.service.ts | 30 ++++---- .../services/submission_status.service.ts | 6 +- .../composables/services/teacher.service.ts | 48 ++++++------ .../src/composables/services/users.service.ts | 30 ++++---- 15 files changed, 282 insertions(+), 280 deletions(-) diff --git a/frontend/src/composables/services/admin.service.ts b/frontend/src/composables/services/admin.service.ts index a1fb1c50..5b576414 100644 --- a/frontend/src/composables/services/admin.service.ts +++ b/frontend/src/composables/services/admin.service.ts @@ -6,27 +6,27 @@ import { User } from '@/types/users/User.ts'; interface AdminState { admins: Ref; admin: Ref; - getAdminByID: (id: string, selfprocessError?: boolean) => Promise; - getAdmins: (selfprocessError?: boolean) => Promise; - createAdmin: (adminData: User, selfprocessError?: boolean) => Promise; - deleteAdmin: (id: string, selfprocessError?: boolean) => Promise; + getAdminByID: (id: string, selfProcessError?: boolean) => Promise; + getAdmins: (selfProcessError?: boolean) => Promise; + createAdmin: (adminData: User, selfProcessError?: boolean) => Promise; + deleteAdmin: (id: string, selfProcessError?: boolean) => Promise; } export function useAdmin(): AdminState { const admins = ref(null); const admin = ref(null); - async function getAdminByID(id: string, selfprocessError: boolean = true): Promise { + async function getAdminByID(id: string, selfProcessError: boolean = true): Promise { const endpoint = endpoints.admins.retrieve.replace('{id}', id); - await get(endpoint, admin, User.fromJSON, selfprocessError); + await get(endpoint, admin, User.fromJSON, selfProcessError); } - async function getAdmins(selfprocessError: boolean = true): Promise { + async function getAdmins(selfProcessError: boolean = true): Promise { const endpoint = endpoints.admins.index; - await getList(endpoint, admins, User.fromJSON, selfprocessError); + await getList(endpoint, admins, User.fromJSON, selfProcessError); } - async function createAdmin(user: User, selfprocessError: boolean = true): Promise { + async function createAdmin(user: User, selfProcessError: boolean = true): Promise { const endpoint = endpoints.admins.index; await createToast( 'admin', @@ -37,13 +37,13 @@ export function useAdmin(): AdminState { admin, User.fromJSON, undefined, - selfprocessError, + selfProcessError, ); } - async function deleteAdmin(id: string, selfprocessError: boolean = true): Promise { + async function deleteAdmin(id: string, selfProcessError: boolean = true): Promise { const endpoint = endpoints.admins.retrieve.replace('{id}', id); - await deleteId(endpoint, admin, User.fromJSON, selfprocessError); + await deleteId(endpoint, admin, User.fromJSON, selfProcessError); } return { diff --git a/frontend/src/composables/services/assistant.service.ts b/frontend/src/composables/services/assistant.service.ts index 7239469b..c2e5eff3 100644 --- a/frontend/src/composables/services/assistant.service.ts +++ b/frontend/src/composables/services/assistant.service.ts @@ -20,14 +20,14 @@ interface AssistantState { assistant: Ref; response: Ref; assistantPagination: Ref | null>; - getAssistantByID: (id: string, init?: boolean, selfprocessError?: boolean) => Promise; - getAssistantsByCourse: (courseId: string, selfprocessError?: boolean) => Promise; - getAssistants: (selfprocessError?: boolean) => Promise; - searchAssistants: (filters: Filter, page: number, pageSize: number, selfprocessError?: boolean) => Promise; - assistantJoinCourse: (courseId: string, assistantId: string, selfprocessError?: boolean) => Promise; - assistantLeaveCourse: (courseId: string, assistantId: string, selfprocessError?: boolean) => Promise; - createAssistant: (assistantData: Assistant, selfprocessError?: boolean) => Promise; - deleteAssistant: (id: string, selfprocessError?: boolean) => Promise; + getAssistantByID: (id: string, init?: boolean, selfProcessError?: boolean) => Promise; + getAssistantsByCourse: (courseId: string, selfProcessError?: boolean) => Promise; + getAssistants: (selfProcessError?: boolean) => Promise; + searchAssistants: (filters: Filter, page: number, pageSize: number, selfProcessError?: boolean) => Promise; + assistantJoinCourse: (courseId: string, assistantId: string, selfProcessError?: boolean) => Promise; + assistantLeaveCourse: (courseId: string, assistantId: string, selfProcessError?: boolean) => Promise; + createAssistant: (assistantData: Assistant, selfProcessError?: boolean) => Promise; + deleteAssistant: (id: string, selfProcessError?: boolean) => Promise; } export function useAssistant(): AssistantState { @@ -37,26 +37,26 @@ export function useAssistant(): AssistantState { const response = ref(null); const assistantPagination = ref | null>(null); - async function getAssistantByID(id: string, selfprocessError: boolean = true): Promise { + async function getAssistantByID(id: string, selfProcessError: boolean = true): Promise { const endpoint = endpoints.assistants.retrieve.replace('{id}', id); - await get(endpoint, assistant, Assistant.fromJSON, selfprocessError); + await get(endpoint, assistant, Assistant.fromJSON, selfProcessError); } - async function getAssistantsByCourse(courseId: string, selfprocessError: boolean = true): Promise { + async function getAssistantsByCourse(courseId: string, selfProcessError: boolean = true): Promise { const endpoint = endpoints.assistants.byCourse.replace('{courseId}', courseId); - await getList(endpoint, assistants, Assistant.fromJSON, selfprocessError); + await getList(endpoint, assistants, Assistant.fromJSON, selfProcessError); } - async function getAssistants(selfprocessError: boolean = true): Promise { + async function getAssistants(selfProcessError: boolean = true): Promise { const endpoint = endpoints.assistants.index; - await getList(endpoint, assistants, Assistant.fromJSON, selfprocessError); + await getList(endpoint, assistants, Assistant.fromJSON, selfProcessError); } async function searchAssistants( filters: Filter, page: number, pageSize: number, - selfprocessError: boolean = true, + selfProcessError: boolean = true, ): Promise { const endpoint = endpoints.assistants.search; await getPaginatedList( @@ -66,14 +66,14 @@ export function useAssistant(): AssistantState { pageSize, assistantPagination, Assistant.fromJSON, - selfprocessError, + selfProcessError, ); } async function assistantJoinCourse( courseId: string, assistantId: string, - selfprocessError: boolean = true, + selfProcessError: boolean = true, ): Promise { const endpoint = endpoints.assistants.byCourse.replace('{courseId}', courseId); await create( @@ -82,14 +82,14 @@ export function useAssistant(): AssistantState { response, Response.fromJSON, undefined, - selfprocessError, + selfProcessError, ); } async function assistantLeaveCourse( courseId: string, assistantId: string, - selfprocessError: boolean = true, + selfProcessError: boolean = true, ): Promise { const endpoint = endpoints.assistants.byCourse.replace('{courseId}', courseId); await deleteIdWithData( @@ -97,11 +97,11 @@ export function useAssistant(): AssistantState { { assistant: assistantId }, response, Response.fromJSON, - selfprocessError, + selfProcessError, ); } - async function createAssistant(user: User, selfprocessError: boolean = true): Promise { + async function createAssistant(user: User, selfProcessError: boolean = true): Promise { const endpoint = endpoints.assistants.index; await createToast( 'assistant', @@ -112,13 +112,13 @@ export function useAssistant(): AssistantState { assistant, Assistant.fromJSON, undefined, - selfprocessError, + selfProcessError, ); } - async function deleteAssistant(id: string, selfprocessError: boolean = true): Promise { + async function deleteAssistant(id: string, selfProcessError: boolean = true): Promise { const endpoint = endpoints.assistants.retrieve.replace('{id}', id); - await deleteId(endpoint, assistant, Assistant.fromJSON, selfprocessError); + await deleteId(endpoint, assistant, Assistant.fromJSON, selfProcessError); } return { diff --git a/frontend/src/composables/services/course.service.ts b/frontend/src/composables/services/course.service.ts index 9e45620a..89c99247 100644 --- a/frontend/src/composables/services/course.service.ts +++ b/frontend/src/composables/services/course.service.ts @@ -14,23 +14,23 @@ interface CoursesState { courses: Ref; course: Ref; - getCourseByID: (id: string, selfprocessError?: boolean) => Promise; - getCourses: (selfprocessError?: boolean) => Promise; - searchCourses: (filters: Filter, page: number, pageSize: number, selfprocessError?: boolean) => Promise; - getCoursesByStudent: (studentId: string, selfprocessError?: boolean) => Promise; - getCoursesByTeacher: (teacherId: string, selfprocessError?: boolean) => Promise; - getCourseByAssistant: (assistantId: string, selfprocessError?: boolean) => Promise; - getCoursesByUser: (user: User, selfprocessError?: boolean) => Promise; - createCourse: (courseData: Course, selfprocessError?: boolean) => Promise; - updateCourse: (courseData: Course, selfprocessError?: boolean) => Promise; + getCourseByID: (id: string, selfProcessError?: boolean) => Promise; + getCourses: (selfProcessError?: boolean) => Promise; + searchCourses: (filters: Filter, page: number, pageSize: number, selfProcessError?: boolean) => Promise; + getCoursesByStudent: (studentId: string, selfProcessError?: boolean) => Promise; + getCoursesByTeacher: (teacherId: string, selfProcessError?: boolean) => Promise; + getCourseByAssistant: (assistantId: string, selfProcessError?: boolean) => Promise; + getCoursesByUser: (user: User, selfProcessError?: boolean) => Promise; + createCourse: (courseData: Course, selfProcessError?: boolean) => Promise; + updateCourse: (courseData: Course, selfProcessError?: boolean) => Promise; cloneCourse: ( courseId: string, cloneAssistants: boolean, cloneTeachers: boolean, - selfprocessError?: boolean, + selfProcessError?: boolean, ) => Promise; - activateInvitationLink: (courseId: string, linkDuration: number, selfprocessError?: boolean) => Promise; - deleteCourse: (id: string, selfprocessError?: boolean) => Promise; + activateInvitationLink: (courseId: string, linkDuration: number, selfProcessError?: boolean) => Promise; + deleteCourse: (id: string, selfProcessError?: boolean) => Promise; } export function useCourses(): CoursesState { @@ -39,21 +39,21 @@ export function useCourses(): CoursesState { const course = ref(null); const response = ref(null); - async function getCourseByID(id: string, selfprocessError: boolean = true): Promise { + async function getCourseByID(id: string, selfProcessError: boolean = true): Promise { const endpoint = endpoints.courses.retrieve.replace('{id}', id); - await get(endpoint, course, Course.fromJSON, selfprocessError); + await get(endpoint, course, Course.fromJSON, selfProcessError); } - async function getCourses(selfprocessError: boolean = true): Promise { + async function getCourses(selfProcessError: boolean = true): Promise { const endpoint = endpoints.courses.index; - await getList(endpoint, courses, Course.fromJSON, selfprocessError); + await getList(endpoint, courses, Course.fromJSON, selfProcessError); } async function searchCourses( filters: Filter, page: number, pageSize: number, - selfprocessError: boolean = true, + selfProcessError: boolean = true, ): Promise { const endpoint = endpoints.courses.search; await getPaginatedList( @@ -63,38 +63,38 @@ export function useCourses(): CoursesState { pageSize, pagination, Course.fromJSON, - selfprocessError, + selfProcessError, ); } - async function getCoursesByStudent(studentId: string, selfprocessError: boolean = true): Promise { + async function getCoursesByStudent(studentId: string, selfProcessError: boolean = true): Promise { const endpoint = endpoints.courses.byStudent.replace('{studentId}', studentId); - await getList(endpoint, courses, Course.fromJSON, selfprocessError); + await getList(endpoint, courses, Course.fromJSON, selfProcessError); } - async function getCoursesByTeacher(teacherId: string, selfprocessError: boolean = true): Promise { + async function getCoursesByTeacher(teacherId: string, selfProcessError: boolean = true): Promise { const endpoint = endpoints.courses.byTeacher.replace('{teacherId}', teacherId); - await getList(endpoint, courses, Course.fromJSON, selfprocessError); + await getList(endpoint, courses, Course.fromJSON, selfProcessError); } - async function getCourseByAssistant(assistantId: string, selfprocessError: boolean = true): Promise { + async function getCourseByAssistant(assistantId: string, selfProcessError: boolean = true): Promise { const endpoint = endpoints.courses.byAssistant.replace('{assistantId}', assistantId); - await getList(endpoint, courses, Course.fromJSON, selfprocessError); + await getList(endpoint, courses, Course.fromJSON, selfProcessError); } - async function getCoursesByUser(user: User, selfprocessError: boolean = true): Promise { + async function getCoursesByUser(user: User, selfProcessError: boolean = true): Promise { if (user.isTeacher()) { - await getCoursesByTeacher(user.id, selfprocessError); + await getCoursesByTeacher(user.id, selfProcessError); } else if (user.isAssistant()) { - await getCourseByAssistant(user.id, selfprocessError); + await getCourseByAssistant(user.id, selfProcessError); } else if (user.isStudent()) { - await getCoursesByStudent(user.id, selfprocessError); + await getCoursesByStudent(user.id, selfProcessError); } else { courses.value = []; } } - async function createCourse(courseData: Course, selfprocessError: boolean = true): Promise { + async function createCourse(courseData: Course, selfProcessError: boolean = true): Promise { const { t } = i18n.global; const { addSuccessMessage } = useMessagesStore(); const endpoint = endpoints.courses.index; @@ -112,7 +112,7 @@ export function useCourses(): CoursesState { course, Course.fromJSON, undefined, - selfprocessError, + selfProcessError, ); addSuccessMessage( t('toasts.messages.success'), @@ -120,7 +120,7 @@ export function useCourses(): CoursesState { ); } - async function updateCourse(courseData: Course, selfprocessError: boolean = true): Promise { + async function updateCourse(courseData: Course, selfProcessError: boolean = true): Promise { // Endpoint to update is same as retrieve const endpoint = endpoints.courses.retrieve.replace('{id}', courseData.id); @@ -136,7 +136,7 @@ export function useCourses(): CoursesState { }, response, undefined, - selfprocessError, + selfProcessError, ); } @@ -144,7 +144,7 @@ export function useCourses(): CoursesState { courseId: string, cloneAssistants: boolean, cloneTeachers: boolean, - selfprocessError: boolean = true, + selfProcessError: boolean = true, ): Promise { const endpoint = endpoints.courses.clone.replace('{courseId}', courseId); await create( @@ -156,19 +156,19 @@ export function useCourses(): CoursesState { course, Course.fromJSON, undefined, - selfprocessError, + selfProcessError, ); } - async function deleteCourse(id: string, selfprocessError: boolean = true): Promise { + async function deleteCourse(id: string, selfProcessError: boolean = true): Promise { const endpoint = endpoints.courses.retrieve.replace('{id}', id); - await deleteId(endpoint, course, Course.fromJSON, selfprocessError); + await deleteId(endpoint, course, Course.fromJSON, selfProcessError); } async function activateInvitationLink( courseId: string, linkDuration: number, - selfprocessError: boolean = true, + selfProcessError: boolean = true, ): Promise { const endpoint = endpoints.courses.invitationLink.replace('{courseId}', courseId); await patch( @@ -178,7 +178,7 @@ export function useCourses(): CoursesState { }, response, undefined, - selfprocessError, + selfProcessError, ); } diff --git a/frontend/src/composables/services/docker.service.ts b/frontend/src/composables/services/docker.service.ts index 2034cf72..6ed450f2 100644 --- a/frontend/src/composables/services/docker.service.ts +++ b/frontend/src/composables/services/docker.service.ts @@ -17,12 +17,12 @@ interface DockerImagesState { pagination: Ref | null>; dockerImages: Ref; response: Ref; - getDockerImages: (selfprocessError?: boolean) => Promise; - searchDockerImages: (filters: Filter, page: number, pageSize: number, selfprocessError?: boolean) => Promise; - patchDockerImage: (dockerData: DockerImage, selfprocessError?: boolean) => Promise; - createDockerImage: (dockerData: DockerImage, file: File, selfprocessError?: boolean) => Promise; - deleteDockerImage: (id: string, selfprocessError?: boolean) => Promise; - deleteDockerImages: (ids: string[], selfprocessError?: boolean) => Promise; + getDockerImages: (selfProcessError?: boolean) => Promise; + searchDockerImages: (filters: Filter, page: number, pageSize: number, selfProcessError?: boolean) => Promise; + patchDockerImage: (dockerData: DockerImage, selfProcessError?: boolean) => Promise; + createDockerImage: (dockerData: DockerImage, file: File, selfProcessError?: boolean) => Promise; + deleteDockerImage: (id: string, selfProcessError?: boolean) => Promise; + deleteDockerImages: (ids: string[], selfProcessError?: boolean) => Promise; } export function useDockerImages(): DockerImagesState { @@ -30,16 +30,16 @@ export function useDockerImages(): DockerImagesState { const dockerImages = ref(null); const response = ref(null); - async function getDockerImages(selfprocessError: boolean = true): Promise { + async function getDockerImages(selfProcessError: boolean = true): Promise { const endpoint = endpoints.dockerImages.index; - await getList(endpoint, dockerImages, DockerImage.fromJSON, selfprocessError); + await getList(endpoint, dockerImages, DockerImage.fromJSON, selfProcessError); } async function searchDockerImages( filters: Filter, page: number, pageSize: number, - selfprocessError: boolean = true, + selfProcessError: boolean = true, ): Promise { const endpoint = endpoints.dockerImages.search; await getPaginatedList( @@ -49,19 +49,19 @@ export function useDockerImages(): DockerImagesState { pageSize, pagination, DockerImage.fromJSON, - selfprocessError, + selfProcessError, ); } - async function patchDockerImage(dockerData: DockerImage, selfprocessError: boolean = true): Promise { + async function patchDockerImage(dockerData: DockerImage, selfProcessError: boolean = true): Promise { const endpoint = endpoints.dockerImages.patch.replace('{id}', dockerData.id); - await patch(endpoint, { public: dockerData.public }, response, undefined, selfprocessError); + await patch(endpoint, { public: dockerData.public }, response, undefined, selfProcessError); } async function createDockerImage( dockerData: DockerImage, file: File, - selfprocessError: boolean = true, + selfProcessError: boolean = true, ): Promise { const endpoint = endpoints.dockerImages.index; await createToast( @@ -75,19 +75,19 @@ export function useDockerImages(): DockerImagesState { response, Response.fromJSON, 'multipart/form-data', - selfprocessError, + selfProcessError, ); } - async function deleteDockerImage(id: string, selfprocessError: boolean = true): Promise { + async function deleteDockerImage(id: string, selfProcessError: boolean = true): Promise { const endpoint = endpoints.dockerImages.retrieve.replace('{id}', id); - await deleteId(endpoint, response, Response.fromJSON, selfprocessError); + await deleteId(endpoint, response, Response.fromJSON, selfProcessError); } - async function deleteDockerImages(ids: string[], selfprocessError: boolean = true): Promise { + async function deleteDockerImages(ids: string[], selfProcessError: boolean = true): Promise { const endpoint = endpoints.dockerImages.deleteMany; const data = { ids }; - await deleteIdWithData(endpoint, data, response, Response.fromJSON, selfprocessError); + await deleteIdWithData(endpoint, data, response, Response.fromJSON, selfProcessError); } return { diff --git a/frontend/src/composables/services/extra_checks.service.ts b/frontend/src/composables/services/extra_checks.service.ts index 39ef35d6..1e7a99f1 100644 --- a/frontend/src/composables/services/extra_checks.service.ts +++ b/frontend/src/composables/services/extra_checks.service.ts @@ -7,10 +7,10 @@ import { Response } from '@/types/Response'; interface ExtraCheckState { extraCheck: Ref; extraChecks: Ref; - getExtraChecksByProject: (projectId: string, selfprocessError?: boolean) => Promise; - addExtraCheck: (extraCheckData: ExtraCheck, projectId: string, selfprocessError?: boolean) => Promise; - setExtraChecks: (extraChecks: ExtraCheck[], projectId: string, selfprocessError?: boolean) => Promise; - deleteExtraCheck: (extraCheckId: string, selfprocessError?: boolean) => Promise; + getExtraChecksByProject: (projectId: string, selfProcessError?: boolean) => Promise; + addExtraCheck: (extraCheckData: ExtraCheck, projectId: string, selfProcessError?: boolean) => Promise; + setExtraChecks: (extraChecks: ExtraCheck[], projectId: string, selfProcessError?: boolean) => Promise; + deleteExtraCheck: (extraCheckId: string, selfProcessError?: boolean) => Promise; } export function useExtraCheck(): ExtraCheckState { @@ -18,15 +18,15 @@ export function useExtraCheck(): ExtraCheckState { const extraChecks = ref(null); const response = ref(null); - async function getExtraChecksByProject(projectId: string, selfprocessError: boolean = true): Promise { + async function getExtraChecksByProject(projectId: string, selfProcessError: boolean = true): Promise { const endpoint = endpoints.extraChecks.byProject.replace('{projectId}', projectId); - await getList(endpoint, extraChecks, ExtraCheck.fromJSON, selfprocessError); + await getList(endpoint, extraChecks, ExtraCheck.fromJSON, selfProcessError); } async function addExtraCheck( extraCheckData: ExtraCheck, projectId: string, - selfprocessError: boolean = true, + selfProcessError: boolean = true, ): Promise { const endpoint = endpoints.extraChecks.byProject.replace('{projectId}', projectId); await create( @@ -42,25 +42,25 @@ export function useExtraCheck(): ExtraCheckState { extraCheck, ExtraCheck.fromJSON, 'multipart/form-data', - selfprocessError, + selfProcessError, ); } async function setExtraChecks( extraChecks: ExtraCheck[], projectId: string, - selfprocessError: boolean = true, + selfProcessError: boolean = true, ): Promise { for (const extraCheck of extraChecks) { if (extraCheck.id === '') { - await addExtraCheck(extraCheck, projectId, selfprocessError); + await addExtraCheck(extraCheck, projectId, selfProcessError); } } } - async function deleteExtraCheck(extraCheckId: string, selfprocessError: boolean = true): Promise { + async function deleteExtraCheck(extraCheckId: string, selfProcessError: boolean = true): Promise { const endpoint = endpoints.extraChecks.retrieve.replace('{id}', extraCheckId); - await deleteId(endpoint, response, Response.fromJSON, selfprocessError); + await deleteId(endpoint, response, Response.fromJSON, selfProcessError); } return { diff --git a/frontend/src/composables/services/faculty.service.ts b/frontend/src/composables/services/faculty.service.ts index 0bfafa1d..6c2c31f4 100644 --- a/frontend/src/composables/services/faculty.service.ts +++ b/frontend/src/composables/services/faculty.service.ts @@ -6,27 +6,27 @@ import { get, getList, deleteId, createToast } from '@/composables/services/help interface FacultyState { faculties: Ref; faculty: Ref; - getFacultyByID: (id: string, selfprocessError?: boolean) => Promise; - getFaculties: (selfprocessError?: boolean) => Promise; - createFaculty: (facultyData: Faculty, selfprocessError?: boolean) => Promise; - deleteFaculty: (id: string, selfprocessError?: boolean) => Promise; + getFacultyByID: (id: string, selfProcessError?: boolean) => Promise; + getFaculties: (selfProcessError?: boolean) => Promise; + createFaculty: (facultyData: Faculty, selfProcessError?: boolean) => Promise; + deleteFaculty: (id: string, selfProcessError?: boolean) => Promise; } export function useFaculty(): FacultyState { const faculties = ref(null); const faculty = ref(null); - async function getFacultyByID(id: string, selfprocessError: boolean = true): Promise { + async function getFacultyByID(id: string, selfProcessError: boolean = true): Promise { const endpoint = endpoints.faculties.retrieve.replace('{id}', id); - await get(endpoint, faculty, Faculty.fromJSON, selfprocessError); + await get(endpoint, faculty, Faculty.fromJSON, selfProcessError); } - async function getFaculties(selfprocessError: boolean = true): Promise { + async function getFaculties(selfProcessError: boolean = true): Promise { const endpoint = endpoints.faculties.index; - await getList(endpoint, faculties, Faculty.fromJSON, selfprocessError); + await getList(endpoint, faculties, Faculty.fromJSON, selfProcessError); } - async function createFaculty(facultyData: Faculty, selfprocessError: boolean = true): Promise { + async function createFaculty(facultyData: Faculty, selfProcessError: boolean = true): Promise { const endpoint = endpoints.faculties.index; await createToast( 'faculty', @@ -35,13 +35,13 @@ export function useFaculty(): FacultyState { faculty, Faculty.fromJSON, undefined, - selfprocessError, + selfProcessError, ); } - async function deleteFaculty(id: string, selfprocessError: boolean = true): Promise { + async function deleteFaculty(id: string, selfProcessError: boolean = true): Promise { const endpoint = endpoints.faculties.retrieve.replace('{id}', id); - await deleteId(endpoint, faculty, Faculty.fromJSON, selfprocessError); + await deleteId(endpoint, faculty, Faculty.fromJSON, selfProcessError); } return { diff --git a/frontend/src/composables/services/group.service.ts b/frontend/src/composables/services/group.service.ts index ec748c04..a810d429 100644 --- a/frontend/src/composables/services/group.service.ts +++ b/frontend/src/composables/services/group.service.ts @@ -6,33 +6,33 @@ import { get, getList, create, deleteId } from '@/composables/services/helpers.t interface GroupState { groups: Ref; group: Ref; - getGroupByID: (id: string, selfprocessError?: boolean) => Promise; - getGroupsByProject: (projectId: string, selfprocessError?: boolean) => Promise; - getGroupsByStudent: (studentId: string, selfprocessError?: boolean) => Promise; - createGroup: (groupData: Group, projectId: string, selfprocessError?: boolean) => Promise; - deleteGroup: (id: string, selfprocessError?: boolean) => Promise; + getGroupByID: (id: string, selfProcessError?: boolean) => Promise; + getGroupsByProject: (projectId: string, selfProcessError?: boolean) => Promise; + getGroupsByStudent: (studentId: string, selfProcessError?: boolean) => Promise; + createGroup: (groupData: Group, projectId: string, selfProcessError?: boolean) => Promise; + deleteGroup: (id: string, selfProcessError?: boolean) => Promise; } export function useGroup(): GroupState { const groups = ref(null); const group = ref(null); - async function getGroupByID(id: string, selfprocessError: boolean = true): Promise { + async function getGroupByID(id: string, selfProcessError: boolean = true): Promise { const endpoint = endpoints.groups.retrieve.replace('{id}', id); - await get(endpoint, group, Group.fromJSON, selfprocessError); + await get(endpoint, group, Group.fromJSON, selfProcessError); } - async function getGroupsByProject(projectId: string, selfprocessError: boolean = true): Promise { + async function getGroupsByProject(projectId: string, selfProcessError: boolean = true): Promise { const endpoint = endpoints.groups.byProject.replace('{projectId}', projectId); - await getList(endpoint, groups, Group.fromJSON, selfprocessError); + await getList(endpoint, groups, Group.fromJSON, selfProcessError); } - async function getGroupsByStudent(studentId: string, selfprocessError: boolean = true): Promise { + async function getGroupsByStudent(studentId: string, selfProcessError: boolean = true): Promise { const endpoint = endpoints.groups.byStudent.replace('{studentId}', studentId); - await getList(endpoint, groups, Group.fromJSON, selfprocessError); + await getList(endpoint, groups, Group.fromJSON, selfProcessError); } - async function createGroup(groupData: Group, projectId: string, selfprocessError: boolean = true): Promise { + async function createGroup(groupData: Group, projectId: string, selfProcessError: boolean = true): Promise { const endpoint = endpoints.groups.byProject.replace('{projectId}', projectId); await create( endpoint, @@ -43,13 +43,13 @@ export function useGroup(): GroupState { group, Group.fromJSON, undefined, - selfprocessError, + selfProcessError, ); } - async function deleteGroup(id: string, selfprocessError: boolean = true): Promise { + async function deleteGroup(id: string, selfProcessError: boolean = true): Promise { const endpoint = endpoints.groups.retrieve.replace('{id}', id); - await deleteId(endpoint, group, Group.fromJSON, selfprocessError); + await deleteId(endpoint, group, Group.fromJSON, selfProcessError); } return { diff --git a/frontend/src/composables/services/helpers.ts b/frontend/src/composables/services/helpers.ts index e3a4a2ca..31f9d0f3 100644 --- a/frontend/src/composables/services/helpers.ts +++ b/frontend/src/composables/services/helpers.ts @@ -18,13 +18,13 @@ export async function get( endpoint: string, ref: Ref, fromJson: (data: any) => T, - selfprocessError: boolean = true, + selfProcessError: boolean = true, ): Promise { try { const response = await client.get(endpoint); ref.value = fromJson(response.data); } catch (error: any) { - if (selfprocessError) { + if (selfProcessError) { processError(error); console.error(error); // Log the error for debugging } else { @@ -48,7 +48,7 @@ export async function create( ref: Ref, fromJson: (data: any) => T, contentType: string = 'application/json', - selfprocessError: boolean = true, + selfProcessError: boolean = true, ): Promise { try { const response = await client.post(endpoint, data, { @@ -58,7 +58,7 @@ export async function create( }); ref.value = fromJson(response.data); } catch (error: any) { - if (selfprocessError) { + if (selfProcessError) { processError(error); console.error(error); // Log the error for debugging } else { @@ -105,7 +105,7 @@ export async function patch( data: any, ref: Ref, contentType: string = 'application/json', - selfprocessError: boolean = true, + selfProcessError: boolean = true, ): Promise { try { const response: AxiosResponse = await client.patch(endpoint, data, { @@ -115,7 +115,7 @@ export async function patch( }); ref.value = Response.fromJSON(response.data); } catch (error: any) { - if (selfprocessError) { + if (selfProcessError) { processError(error); console.error(error); // Log the error for debugging } else { @@ -135,7 +135,7 @@ export async function put( endpoint: string, data: T | string, contentType: string = 'application/json', - selfprocessError: boolean = true, + selfProcessError: boolean = true, ): Promise { try { await client.put(endpoint, data, { @@ -144,7 +144,7 @@ export async function put( }, }); } catch (error: any) { - if (selfprocessError) { + if (selfProcessError) { processError(error); console.error(error); // Log the error for debugging } else { @@ -164,13 +164,13 @@ export async function deleteId( endpoint: string, ref: Ref, fromJson: (data: any) => T, - selfprocessError: boolean = true, + selfProcessError: boolean = true, ): Promise { try { const response = await client.delete(endpoint); ref.value = fromJson(response.data); } catch (error: any) { - if (selfprocessError) { + if (selfProcessError) { processError(error); console.error(error); // Log the error for debugging } else { @@ -192,13 +192,13 @@ export async function deleteIdWithData( data: any, ref: Ref, fromJson: (data: any) => T, - selfprocessError: boolean = true, + selfProcessError: boolean = true, ): Promise { try { const response = await client.delete(endpoint, { data }); ref.value = fromJson(response.data); } catch (error: any) { - if (selfprocessError) { + if (selfProcessError) { processError(error); console.error(error); // Log the error for debugging } else { @@ -218,14 +218,14 @@ export async function getList( endpoint: string, ref: Ref, fromJson: (data: any) => T, - selfprocessError: boolean = true, + selfProcessError: boolean = true, ): Promise { try { const response = await client.get(endpoint); ref.value = response.data.map((data: T) => fromJson(data)); } catch (error: any) { ref.value = []; // Set the ref to an empty array - if (selfprocessError) { + if (selfProcessError) { processError(error); console.error(error); // Log the error for debugging } else { @@ -251,7 +251,7 @@ export async function getPaginatedList( pageSize: number, pagination: Ref | null>, fromJson: (data: any) => T, - selfprocessError: boolean = true, + selfProcessError: boolean = true, ): Promise { try { const response = await client.get(endpoint, { @@ -274,7 +274,7 @@ export async function getPaginatedList( results: [], }; - if (selfprocessError) { + if (selfProcessError) { processError(error); console.error(error); // Log the error for debugging } else { diff --git a/frontend/src/composables/services/project.service.ts b/frontend/src/composables/services/project.service.ts index d6664d17..97d8a81d 100644 --- a/frontend/src/composables/services/project.service.ts +++ b/frontend/src/composables/services/project.service.ts @@ -10,20 +10,20 @@ import { useMessagesStore } from '@/store/messages.store.ts'; interface ProjectState { projects: Ref; project: Ref; - getProjectByID: (id: string, selfprocessError?: boolean) => Promise; - getProjectsByCourse: (courseId: string, selfprocessError?: boolean) => Promise; - getProjectsByStudent: (studentId: string, selfprocessError?: boolean) => Promise; - getProjectsByAssistant: (assistantId: string, selfprocessError?: boolean) => Promise; - getProjectsByTeacher: (teacherId: string, selfprocessError?: boolean) => Promise; - getProjectsByCourseAndDeadline: (courseId: string, deadlineDate: Date, selfprocessError?: boolean) => Promise; + getProjectByID: (id: string, selfProcessError?: boolean) => Promise; + getProjectsByCourse: (courseId: string, selfProcessError?: boolean) => Promise; + getProjectsByStudent: (studentId: string, selfProcessError?: boolean) => Promise; + getProjectsByAssistant: (assistantId: string, selfProcessError?: boolean) => Promise; + getProjectsByTeacher: (teacherId: string, selfProcessError?: boolean) => Promise; + getProjectsByCourseAndDeadline: (courseId: string, deadlineDate: Date, selfProcessError?: boolean) => Promise; createProject: ( projectData: Project, courseId: string, numberOfGroups: number, - selfprocessError?: boolean, + selfProcessError?: boolean, ) => Promise; - updateProject: (projectData: Project, selfprocessError?: boolean) => Promise; - deleteProject: (id: string, selfprocessError?: boolean) => Promise; + updateProject: (projectData: Project, selfProcessError?: boolean) => Promise; + deleteProject: (id: string, selfProcessError?: boolean) => Promise; } export function useProject(): ProjectState { @@ -31,48 +31,50 @@ export function useProject(): ProjectState { const project = ref(null); const response = ref(null); - async function getProjectByID(id: string, selfprocessError: boolean = true): Promise { + async function getProjectByID(id: string, selfProcessError: boolean = true): Promise { const endpoint = endpoints.projects.retrieve.replace('{id}', id); - await get(endpoint, project, Project.fromJSON, selfprocessError); + await get(endpoint, project, Project.fromJSON, selfProcessError); } - async function getProjectsByCourse(courseId: string, selfprocessError: boolean = true): Promise { + async function getProjectsByCourse(courseId: string, selfProcessError: boolean = true): Promise { const endpoint = endpoints.projects.byCourse.replace('{courseId}', courseId); - await getList(endpoint, projects, Project.fromJSON, selfprocessError); + await getList(endpoint, projects, Project.fromJSON, selfProcessError); } - async function getProjectsByStudent(studentId: string, selfprocessError: boolean = true): Promise { + async function getProjectsByStudent(studentId: string, selfProcessError: boolean = true): Promise { const endpoint = endpoints.projects.byStudent.replace('{studentId}', studentId); - await getList(endpoint, projects, Project.fromJSON, selfprocessError); + await getList(endpoint, projects, Project.fromJSON, selfProcessError); } - async function getProjectsByAssistant(assistantId: string, selfprocessError: boolean = true): Promise { + async function getProjectsByAssistant(assistantId: string, selfProcessError: boolean = true): Promise { const endpoint = endpoints.projects.byAssistant.replace('{assistantId}', assistantId); - await getList(endpoint, projects, Project.fromJSON, selfprocessError); + await getList(endpoint, projects, Project.fromJSON, selfProcessError); } - async function getProjectsByTeacher(teacherId: string, selfprocessError: boolean = true): Promise { + async function getProjectsByTeacher(teacherId: string, selfProcessError: boolean = true): Promise { const endpoint = endpoints.projects.byTeacher.replace('{teacherId}', teacherId); - await getList(endpoint, projects, Project.fromJSON, selfprocessError); + await getList(endpoint, projects, Project.fromJSON, selfProcessError); } async function getProjectsByCourseAndDeadline( courseId: string, deadlineDate: Date, - selfprocessError: boolean = true, + selfProcessError: boolean = true, ): Promise { - await getProjectsByCourse(courseId, selfprocessError); - const allProjects = (projects.value ?? []).map((projectData: ProjectJSON) => Project.fromJSON(projectData)); - projects.value = allProjects.filter((project: Project) => { - return project.deadline.toDateString() === deadlineDate.toDateString(); - }); + await getProjectsByCourse(courseId, selfProcessError); + + if (projects.value !== null) { + projects.value = projects.value.filter((project: Project) => { + return project.deadline.toDateString() === deadlineDate.toDateString(); + }); + } } async function createProject( projectData: Project, courseId: string, numberOfGroups: number, - selfprocessError: boolean = true, + selfProcessError: boolean = true, ): Promise { const { t } = i18n.global; const { addSuccessMessage } = useMessagesStore(); @@ -104,7 +106,7 @@ export function useProject(): ProjectState { project, Project.fromJSON, 'multipart/form-data', - selfprocessError, + selfProcessError, ); addSuccessMessage( t('toasts.messages.success'), @@ -112,7 +114,7 @@ export function useProject(): ProjectState { ); } - async function updateProject(projectData: Project, selfprocessError: boolean = true): Promise { + async function updateProject(projectData: Project, selfProcessError: boolean = true): Promise { const endpoint = endpoints.projects.retrieve.replace('{id}', projectData.id); await patch( endpoint, @@ -130,13 +132,13 @@ export function useProject(): ProjectState { }, response, 'multipart/form-data', - selfprocessError, + selfProcessError, ); } - async function deleteProject(id: string, selfprocessError: boolean = true): Promise { + async function deleteProject(id: string, selfProcessError: boolean = true): Promise { const endpoint = endpoints.projects.retrieve.replace('{id}', id); - await deleteId(endpoint, project, Project.fromJSON, selfprocessError); + await deleteId(endpoint, project, Project.fromJSON, selfProcessError); } return { diff --git a/frontend/src/composables/services/structure_check.service.ts b/frontend/src/composables/services/structure_check.service.ts index b50833a8..fa1df7fe 100644 --- a/frontend/src/composables/services/structure_check.service.ts +++ b/frontend/src/composables/services/structure_check.service.ts @@ -7,39 +7,39 @@ interface StructureCheckState { structureChecks: Ref; structureCheck: Ref; - getStructureCheckByID: (id: string, selfprocessError?: boolean) => Promise; - getStructureCheckByProject: (projectId: string, selfprocessError?: boolean) => Promise; + getStructureCheckByID: (id: string, selfProcessError?: boolean) => Promise; + getStructureCheckByProject: (projectId: string, selfProcessError?: boolean) => Promise; createStructureCheck: ( structureCheckData: StructureCheck, projectId: string, - selfprocessError?: boolean, + selfProcessError?: boolean, ) => Promise; setStructureChecks: ( structureChecks: StructureCheck[], projectId: string, - selfprocessError?: boolean, + selfProcessError?: boolean, ) => Promise; - deleteStructureCheck: (id: string, selfprocessError?: boolean) => Promise; + deleteStructureCheck: (id: string, selfProcessError?: boolean) => Promise; } export function useStructureCheck(): StructureCheckState { const structureChecks = ref(null); const structureCheck = ref(null); - async function getStructureCheckByID(id: string, selfprocessError: boolean = true): Promise { + async function getStructureCheckByID(id: string, selfProcessError: boolean = true): Promise { const endpoint = endpoints.structureChecks.retrieve.replace('{id}', id); - await get(endpoint, structureCheck, StructureCheck.fromJSON, selfprocessError); + await get(endpoint, structureCheck, StructureCheck.fromJSON, selfProcessError); } - async function getStructureCheckByProject(projectId: string, selfprocessError: boolean = true): Promise { + async function getStructureCheckByProject(projectId: string, selfProcessError: boolean = true): Promise { const endpoint = endpoints.structureChecks.byProject.replace('{projectId}', projectId); - await getList(endpoint, structureChecks, StructureCheck.fromJSON, selfprocessError); + await getList(endpoint, structureChecks, StructureCheck.fromJSON, selfProcessError); } async function createStructureCheck( structureCheckData: StructureCheck, projectId: string, - selfprocessError: boolean = true, + selfProcessError: boolean = true, ): Promise { const endpoint = endpoints.structureChecks.byProject.replace('{projectId}', projectId); await createToast( @@ -51,22 +51,22 @@ export function useStructureCheck(): StructureCheckState { structureCheck, StructureCheck.fromJSON, undefined, - selfprocessError, + selfProcessError, ); } async function setStructureChecks( structureChecks: StructureCheck[], projectId: string, - selfprocessError: boolean = true, + selfProcessError: boolean = true, ): Promise { const endpoint = endpoints.structureChecks.byProject.replace('{projectId}', projectId); - await put(endpoint, structureChecks, undefined, selfprocessError); + await put(endpoint, structureChecks, undefined, selfProcessError); } - async function deleteStructureCheck(id: string, selfprocessError: boolean = true): Promise { + async function deleteStructureCheck(id: string, selfProcessError: boolean = true): Promise { const endpoint = endpoints.structureChecks.retrieve.replace('{id}', id); - await deleteId(endpoint, structureCheck, StructureCheck.fromJSON, selfprocessError); + await deleteId(endpoint, structureCheck, StructureCheck.fromJSON, selfProcessError); } return { diff --git a/frontend/src/composables/services/student.service.ts b/frontend/src/composables/services/student.service.ts index 49b80ee0..f12cf6d6 100644 --- a/frontend/src/composables/services/student.service.ts +++ b/frontend/src/composables/services/student.service.ts @@ -8,16 +8,16 @@ interface StudentsState { students: Ref; student: Ref; response: Ref; - getStudentByID: (id: string, init?: boolean, selfprocessError?: boolean) => Promise; - getStudents: (selfprocessError?: boolean) => Promise; - getStudentsByCourse: (courseId: string, selfprocessError?: boolean) => Promise; - getStudentsByGroup: (groupId: string, selfprocessError?: boolean) => Promise; - createStudent: (studentData: Student, selfprocessError?: boolean) => Promise; - deleteStudent: (id: string, selfprocessError?: boolean) => Promise; - studentJoinCourse: (courseId: string, studentId: string, selfprocessError?: boolean) => Promise; - studentLeaveCourse: (courseId: string, studentId: string, selfprocessError?: boolean) => Promise; - studentJoinGroup: (groupId: string, studentId: string, selfprocessError?: boolean) => Promise; - studentLeaveGroup: (groupId: string, studentId: string, selfprocessError?: boolean) => Promise; + getStudentByID: (id: string, init?: boolean, selfProcessError?: boolean) => Promise; + getStudents: (selfProcessError?: boolean) => Promise; + getStudentsByCourse: (courseId: string, selfProcessError?: boolean) => Promise; + getStudentsByGroup: (groupId: string, selfProcessError?: boolean) => Promise; + createStudent: (studentData: Student, selfProcessError?: boolean) => Promise; + deleteStudent: (id: string, selfProcessError?: boolean) => Promise; + studentJoinCourse: (courseId: string, studentId: string, selfProcessError?: boolean) => Promise; + studentLeaveCourse: (courseId: string, studentId: string, selfProcessError?: boolean) => Promise; + studentJoinGroup: (groupId: string, studentId: string, selfProcessError?: boolean) => Promise; + studentLeaveGroup: (groupId: string, studentId: string, selfProcessError?: boolean) => Promise; } export function useStudents(): StudentsState { @@ -26,30 +26,30 @@ export function useStudents(): StudentsState { const student = ref(null); const response = ref(null); - async function getStudentByID(id: string, selfprocessError: boolean = true): Promise { + async function getStudentByID(id: string, selfProcessError: boolean = true): Promise { const endpoint = endpoints.students.retrieve.replace('{id}', id); - await get(endpoint, student, Student.fromJSON, selfprocessError); + await get(endpoint, student, Student.fromJSON, selfProcessError); } - async function getStudents(selfprocessError: boolean = true): Promise { + async function getStudents(selfProcessError: boolean = true): Promise { const endpoint = endpoints.students.index; - await getList(endpoint, students, Student.fromJSON, selfprocessError); + await getList(endpoint, students, Student.fromJSON, selfProcessError); } - async function getStudentsByCourse(courseId: string, selfprocessError: boolean = true): Promise { + async function getStudentsByCourse(courseId: string, selfProcessError: boolean = true): Promise { const endpoint = endpoints.students.byCourse.replace('{courseId}', courseId); - await getList(endpoint, students, Student.fromJSON, selfprocessError); + await getList(endpoint, students, Student.fromJSON, selfProcessError); } - async function getStudentsByGroup(groupId: string, selfprocessError: boolean = true): Promise { + async function getStudentsByGroup(groupId: string, selfProcessError: boolean = true): Promise { const endpoint = endpoints.students.byGroup.replace('{groupId}', groupId); - await getList(endpoint, students, Student.fromJSON, selfprocessError); + await getList(endpoint, students, Student.fromJSON, selfProcessError); } async function studentJoinCourse( courseId: string, studentId: string, - selfprocessError: boolean = true, + selfProcessError: boolean = true, ): Promise { const endpoint = endpoints.students.byCourse.replace('{courseId}', courseId); await create( @@ -58,14 +58,14 @@ export function useStudents(): StudentsState { response, Response.fromJSON, undefined, - selfprocessError, + selfProcessError, ); } async function studentLeaveCourse( courseId: string, studentId: string, - selfprocessError: boolean = true, + selfProcessError: boolean = true, ): Promise { const endpoint = endpoints.students.byCourse.replace('{courseId}', courseId); await deleteIdWithData( @@ -73,14 +73,14 @@ export function useStudents(): StudentsState { { student: studentId }, response, Response.fromJSON, - selfprocessError, + selfProcessError, ); } async function studentJoinGroup( groupId: string, studentId: string, - selfprocessError: boolean = true, + selfProcessError: boolean = true, ): Promise { const endpoint = endpoints.students.byGroup.replace('{groupId}', groupId); await create( @@ -89,14 +89,14 @@ export function useStudents(): StudentsState { response, Response.fromJSON, undefined, - selfprocessError, + selfProcessError, ); } async function studentLeaveGroup( groupId: string, studentId: string, - selfprocessError: boolean = true, + selfProcessError: boolean = true, ): Promise { const endpoint = endpoints.students.byGroup.replace('{groupId}', groupId); await deleteIdWithData( @@ -104,11 +104,11 @@ export function useStudents(): StudentsState { { student: studentId }, response, Response.fromJSON, - selfprocessError, + selfProcessError, ); } - async function createStudent(studentData: Student, selfprocessError: boolean = true): Promise { + async function createStudent(studentData: Student, selfProcessError: boolean = true): Promise { const endpoint = endpoints.students.index; await createToast( @@ -121,13 +121,13 @@ export function useStudents(): StudentsState { student, Student.fromJSON, undefined, - selfprocessError, + selfProcessError, ); } - async function deleteStudent(id: string, selfprocessError: boolean = true): Promise { + async function deleteStudent(id: string, selfProcessError: boolean = true): Promise { const endpoint = endpoints.students.retrieve.replace('{id}', id); - await deleteId(endpoint, student, Student.fromJSON, selfprocessError); + await deleteId(endpoint, student, Student.fromJSON, selfProcessError); } return { diff --git a/frontend/src/composables/services/submission.service.ts b/frontend/src/composables/services/submission.service.ts index ae3dd779..2387d0a2 100644 --- a/frontend/src/composables/services/submission.service.ts +++ b/frontend/src/composables/services/submission.service.ts @@ -8,36 +8,36 @@ import { useMessagesStore } from '@/store/messages.store.ts'; interface SubmissionState { submissions: Ref; submission: Ref; - getSubmissionByID: (id: string, selfprocessError?: boolean) => Promise; - getSubmissionByProject: (projectId: string, selfprocessError?: boolean) => Promise; - getSubmissionByGroup: (groupId: string, selfprocessError?: boolean) => Promise; - createSubmission: (submissionData: UnwrapRef, groupId: string, selfprocessError?: boolean) => Promise; - deleteSubmission: (id: string, selfprocessError?: boolean) => Promise; + getSubmissionByID: (id: string, selfProcessError?: boolean) => Promise; + getSubmissionByProject: (projectId: string, selfProcessError?: boolean) => Promise; + getSubmissionByGroup: (groupId: string, selfProcessError?: boolean) => Promise; + createSubmission: (submissionData: UnwrapRef, groupId: string, selfProcessError?: boolean) => Promise; + deleteSubmission: (id: string, selfProcessError?: boolean) => Promise; } export function useSubmission(): SubmissionState { const submissions = ref(null); const submission = ref(null); - async function getSubmissionByID(id: string, selfprocessError: boolean = true): Promise { + async function getSubmissionByID(id: string, selfProcessError: boolean = true): Promise { const endpoint = endpoints.submissions.retrieve.replace('{id}', id); - await get(endpoint, submission, Submission.fromJSON, selfprocessError); + await get(endpoint, submission, Submission.fromJSON, selfProcessError); } - async function getSubmissionByProject(projectId: string, selfprocessError: boolean = true): Promise { + async function getSubmissionByProject(projectId: string, selfProcessError: boolean = true): Promise { const endpoint = endpoints.submissions.byProject.replace('{projectId}', projectId); - await getList(endpoint, submissions, Submission.fromJSON, selfprocessError); + await getList(endpoint, submissions, Submission.fromJSON, selfProcessError); } - async function getSubmissionByGroup(groupId: string, selfprocessError: boolean = true): Promise { + async function getSubmissionByGroup(groupId: string, selfProcessError: boolean = true): Promise { const endpoint = endpoints.submissions.byGroup.replace('{groupId}', groupId); - await getList(endpoint, submissions, Submission.fromJSON, selfprocessError); + await getList(endpoint, submissions, Submission.fromJSON, selfProcessError); } async function createSubmission( uploadedFiles: File[], groupId: string, - selfprocessError: boolean = true, + selfProcessError: boolean = true, ): Promise { const { t } = i18n.global; const { addSuccessMessage } = useMessagesStore(); @@ -48,13 +48,13 @@ export function useSubmission(): SubmissionState { uploadedFiles.forEach((file: File) => { formData.append('files', file); // Gebruik 'files' in plaats van 'files[]' }); - await create(endpoint, formData, submission, Submission.fromJSON, 'multipart/form-data', selfprocessError); + await create(endpoint, formData, submission, Submission.fromJSON, 'multipart/form-data', selfProcessError); addSuccessMessage(t('toasts.messages.success'), t('toasts.messages.submissions.create.success')); } - async function deleteSubmission(id: string, selfprocessError: boolean = true): Promise { + async function deleteSubmission(id: string, selfProcessError: boolean = true): Promise { const endpoint = endpoints.submissions.retrieve.replace('{id}', id); - await deleteId(endpoint, submission, Submission.fromJSON, selfprocessError); + await deleteId(endpoint, submission, Submission.fromJSON, selfProcessError); } return { diff --git a/frontend/src/composables/services/submission_status.service.ts b/frontend/src/composables/services/submission_status.service.ts index 5e9e2e84..e63cb176 100644 --- a/frontend/src/composables/services/submission_status.service.ts +++ b/frontend/src/composables/services/submission_status.service.ts @@ -5,15 +5,15 @@ import { SubmissionStatus } from '@/types/SubmisionStatus'; interface SubmissionStatusState { submissionStatus: Ref; - getSubmissionStatusByProject: (projectId: string, selfprocessError?: boolean) => Promise; + getSubmissionStatusByProject: (projectId: string, selfProcessError?: boolean) => Promise; } export function useSubmissionStatus(): SubmissionStatusState { const submissionStatus = ref(null); - async function getSubmissionStatusByProject(projectId: string, selfprocessError: boolean = true): Promise { + async function getSubmissionStatusByProject(projectId: string, selfProcessError: boolean = true): Promise { const endpoint = endpoints.submissions.status.replace('{projectId}', projectId); - await get(endpoint, submissionStatus, SubmissionStatus.fromJSON, selfprocessError); + await get(endpoint, submissionStatus, SubmissionStatus.fromJSON, selfProcessError); } return { diff --git a/frontend/src/composables/services/teacher.service.ts b/frontend/src/composables/services/teacher.service.ts index 66101d32..f25583c5 100644 --- a/frontend/src/composables/services/teacher.service.ts +++ b/frontend/src/composables/services/teacher.service.ts @@ -21,14 +21,14 @@ interface TeacherState { teacher: Ref; response: Ref; teacherPagination: Ref | null>; - getTeacherByID: (id: string, init?: boolean, selfprocessError?: boolean) => Promise; - getTeachersByCourse: (courseId: string, selfprocessError?: boolean) => Promise; - getTeachers: (selfprocessError?: boolean) => Promise; - searchTeachers: (filters: Filter, page: number, pageSize: number, selfprocessError?: boolean) => Promise; - teacherJoinCourse: (courseId: string, teacherId: string, selfprocessError?: boolean) => Promise; - teacherLeaveCourse: (courseId: string, teacherId: string, selfprocessError?: boolean) => Promise; - createTeacher: (teacherData: Teacher, selfprocessError?: boolean) => Promise; - deleteTeacher: (id: string, selfprocessError?: boolean) => Promise; + getTeacherByID: (id: string, init?: boolean, selfProcessError?: boolean) => Promise; + getTeachersByCourse: (courseId: string, selfProcessError?: boolean) => Promise; + getTeachers: (selfProcessError?: boolean) => Promise; + searchTeachers: (filters: Filter, page: number, pageSize: number, selfProcessError?: boolean) => Promise; + teacherJoinCourse: (courseId: string, teacherId: string, selfProcessError?: boolean) => Promise; + teacherLeaveCourse: (courseId: string, teacherId: string, selfProcessError?: boolean) => Promise; + createTeacher: (teacherData: Teacher, selfProcessError?: boolean) => Promise; + deleteTeacher: (id: string, selfProcessError?: boolean) => Promise; } export function useTeacher(): TeacherState { @@ -38,26 +38,26 @@ export function useTeacher(): TeacherState { const response = ref(null); const teacherPagination = ref | null>(null); - async function getTeacherByID(id: string, selfprocessError: boolean = true): Promise { + async function getTeacherByID(id: string, selfProcessError: boolean = true): Promise { const endpoint = endpoints.teachers.retrieve.replace('{id}', id); - await get(endpoint, teacher, Teacher.fromJSON, selfprocessError); + await get(endpoint, teacher, Teacher.fromJSON, selfProcessError); } - async function getTeachersByCourse(courseId: string, selfprocessError: boolean = true): Promise { + async function getTeachersByCourse(courseId: string, selfProcessError: boolean = true): Promise { const endpoint = endpoints.teachers.byCourse.replace('{courseId}', courseId); - await getList(endpoint, teachers, Teacher.fromJSON, selfprocessError); + await getList(endpoint, teachers, Teacher.fromJSON, selfProcessError); } - async function getTeachers(selfprocessError: boolean = true): Promise { + async function getTeachers(selfProcessError: boolean = true): Promise { const endpoint = endpoints.teachers.index; - await getList(endpoint, teachers, Teacher.fromJSON, selfprocessError); + await getList(endpoint, teachers, Teacher.fromJSON, selfProcessError); } async function searchTeachers( filters: Filter, page: number, pageSize: number, - selfprocessError: boolean = true, + selfProcessError: boolean = true, ): Promise { const endpoint = endpoints.teachers.search; await getPaginatedList( @@ -67,14 +67,14 @@ export function useTeacher(): TeacherState { pageSize, teacherPagination, Teacher.fromJSON, - selfprocessError, + selfProcessError, ); } async function teacherJoinCourse( courseId: string, teacherId: string, - selfprocessError: boolean = true, + selfProcessError: boolean = true, ): Promise { const endpoint = endpoints.teachers.byCourse.replace('{courseId}', courseId); await create( @@ -83,14 +83,14 @@ export function useTeacher(): TeacherState { response, Response.fromJSON, undefined, - selfprocessError, + selfProcessError, ); } async function teacherLeaveCourse( courseId: string, teacherId: string, - selfprocessError: boolean = true, + selfProcessError: boolean = true, ): Promise { const endpoint = endpoints.teachers.byCourse.replace('{courseId}', courseId); await deleteIdWithData( @@ -98,11 +98,11 @@ export function useTeacher(): TeacherState { { teacher: teacherId }, response, Response.fromJSON, - selfprocessError, + selfProcessError, ); } - async function createTeacher(user: User, selfprocessError: boolean = true): Promise { + async function createTeacher(user: User, selfProcessError: boolean = true): Promise { const endpoint = endpoints.teachers.index; await createToast( 'teacher', @@ -113,13 +113,13 @@ export function useTeacher(): TeacherState { teacher, Teacher.fromJSON, undefined, - selfprocessError, + selfProcessError, ); } - async function deleteTeacher(id: string, selfprocessError: boolean = true): Promise { + async function deleteTeacher(id: string, selfProcessError: boolean = true): Promise { const endpoint = endpoints.teachers.retrieve.replace('{id}', id); - await deleteId(endpoint, teacher, Teacher.fromJSON, selfprocessError); + await deleteId(endpoint, teacher, Teacher.fromJSON, selfProcessError); } return { diff --git a/frontend/src/composables/services/users.service.ts b/frontend/src/composables/services/users.service.ts index 2d83e126..1f6bfaf9 100644 --- a/frontend/src/composables/services/users.service.ts +++ b/frontend/src/composables/services/users.service.ts @@ -10,11 +10,11 @@ interface userState { pagination: Ref | null>; users: Ref; user: Ref; - getUserByID: (id: string, selfprocessError?: boolean) => Promise; - getUsers: (selfprocessError?: boolean) => Promise; - searchUsers: (filters: Filter, page: number, pageSize: number, selfprocessError?: boolean) => Promise; - createUser: (user_data: User, selfprocessError?: boolean) => Promise; - toggleAdmin: (id: string, is_staff: boolean, selfprocessError?: boolean) => Promise; + getUserByID: (id: string, selfProcessError?: boolean) => Promise; + getUsers: (selfProcessError?: boolean) => Promise; + searchUsers: (filters: Filter, page: number, pageSize: number, selfProcessError?: boolean) => Promise; + createUser: (user_data: User, selfProcessError?: boolean) => Promise; + toggleAdmin: (id: string, is_staff: boolean, selfProcessError?: boolean) => Promise; } export function useUser(): userState { @@ -23,27 +23,27 @@ export function useUser(): userState { const user = ref(null); const response = ref(null); - async function getUserByID(id: string, selfprocessError: boolean = true): Promise { + async function getUserByID(id: string, selfProcessError: boolean = true): Promise { const endpoint = endpoints.users.retrieve.replace('{id}', id); - await get(endpoint, user, User.fromJSON, selfprocessError); + await get(endpoint, user, User.fromJSON, selfProcessError); } - async function getUsers(selfprocessError: boolean = true): Promise { + async function getUsers(selfProcessError: boolean = true): Promise { const endpoint = endpoints.users.index; - await getList(endpoint, users, User.fromJSON, selfprocessError); + await getList(endpoint, users, User.fromJSON, selfProcessError); } async function searchUsers( filters: Filter, page: number, pageSize: number, - selfprocessError: boolean = true, + selfProcessError: boolean = true, ): Promise { const endpoint = endpoints.users.search; - await getPaginatedList(endpoint, filters, page, pageSize, pagination, User.fromJSON, selfprocessError); + await getPaginatedList(endpoint, filters, page, pageSize, pagination, User.fromJSON, selfProcessError); } - async function createUser(userData: User, selfprocessError: boolean = true): Promise { + async function createUser(userData: User, selfProcessError: boolean = true): Promise { const endpoint = endpoints.users.index; await createToast( 'user', @@ -58,11 +58,11 @@ export function useUser(): userState { user, User.fromJSON, undefined, - selfprocessError, + selfProcessError, ); } - async function toggleAdmin(id: string, isStaff: boolean, selfprocessError: boolean = true): Promise { + async function toggleAdmin(id: string, isStaff: boolean, selfProcessError: boolean = true): Promise { const endpoint = endpoints.users.admin.replace('{id}', id); await patch( endpoint, @@ -71,7 +71,7 @@ export function useUser(): userState { }, response, undefined, - selfprocessError, + selfProcessError, ); }