From 0603a61cec55e46dd73fbaff7dc3bd7aeb0b9aad Mon Sep 17 00:00:00 2001 From: bsilkyn Date: Mon, 25 Mar 2024 20:19:52 +0100 Subject: [PATCH 1/4] chore: translations of errors #149 --- frontend/src/assets/lang/en.json | 17 +++++++++++++++++ frontend/src/assets/lang/nl.json | 17 +++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/frontend/src/assets/lang/en.json b/frontend/src/assets/lang/en.json index a790cc13..4346605d 100644 --- a/frontend/src/assets/lang/en.json +++ b/frontend/src/assets/lang/en.json @@ -24,6 +24,23 @@ "title": "Calendar" } }, + "composables": { + "helpers": { + "errors": { + "error": "error", + "notFound": "Not Found", + "notFoundDetail": "Resource not found.", + "unauthorized": "Unauthorized", + "unauthorizedDetail": "You are not authorized to access this resource.", + "server": "Server Error", + "serverDetail": "An error occurred on the server.", + "network": "Network Error", + "networkDetail": "Unable to connect to the server.", + "request": "Request Error", + "requestDetail": "An error occurred while making the request." + } + } + }, "components": { "buttons": { "academic_year": "Academic year {0}" diff --git a/frontend/src/assets/lang/nl.json b/frontend/src/assets/lang/nl.json index 1ff23e63..b9801cb4 100644 --- a/frontend/src/assets/lang/nl.json +++ b/frontend/src/assets/lang/nl.json @@ -33,6 +33,23 @@ "title": "Kalender" } }, + "composables": { + "helpers": { + "errors": { + "error": "fout", + "notFound": "Niet Gevonden", + "notFoundDetail": "Resource niet gevonden.", + "unauthorized": "Onbevoegd", + "unauthorizedDetail": "Je bent niet bevoegd om deze resource te bereiken.", + "server": "Server Fout", + "serverDetail": "Er vond een fout plaats op de server.", + "network": "Netwerk Fout", + "networkDetail": "Kan de server niet bereiken.", + "request": "Verzoek Fout", + "requestDetail": "Een fout vond plaats tijdens het maken van het verzoek." + } + } + }, "components": { "buttons": { "academic_year": "Academiejaar {0}" From 916a4f12ce59110bb3a34e3fad2b3f0b29c87414 Mon Sep 17 00:00:00 2001 From: bsilkyn Date: Mon, 25 Mar 2024 20:35:18 +0100 Subject: [PATCH 2/4] chore: ComposerTranslation object gets passed through service functions #149 --- .../composables/services/admins.service.ts | 9 +++--- .../composables/services/assistant.service.ts | 9 +++--- .../composables/services/courses.service.ts | 13 +++++---- .../composables/services/faculties.service.ts | 9 +++--- .../composables/services/groups.service.ts | 9 +++--- frontend/src/composables/services/helpers.ts | 28 +++++++++++-------- frontend/src/views/calendar/CalendarView.vue | 2 +- frontend/src/views/courses/CourseView.vue | 5 +++- .../src/views/dashboard/DashboardView.vue | 2 +- 9 files changed, 49 insertions(+), 37 deletions(-) diff --git a/frontend/src/composables/services/admins.service.ts b/frontend/src/composables/services/admins.service.ts index 8cb75e4c..83fc72c5 100644 --- a/frontend/src/composables/services/admins.service.ts +++ b/frontend/src/composables/services/admins.service.ts @@ -3,21 +3,22 @@ import {ref} from 'vue'; import {endpoints} from '@/config/endpoints.ts'; import { get, getList } from '@/composables/services/helpers.ts'; import { useToast } from 'primevue/usetoast'; +import {ComposerTranslation} from "vue-i18n"; export function useAdmin() { const admins = ref(null); const admin = ref(null); const toast = useToast(); - async function getAdminByID(id: number) { + async function getAdminByID(id: number, t: ComposerTranslation) { const endpoint = endpoints.admins.retrieve.replace('{id}', id.toString()); - get(endpoint, admin, Admin.fromJSON, toast); + get(endpoint, admin, Admin.fromJSON, toast, t); console.log(admin) } - async function getAdmins() { + async function getAdmins(t: ComposerTranslation) { const endpoint = endpoints.admins.index; - getList(endpoint, admins, Admin.fromJSON, toast); + getList(endpoint, admins, Admin.fromJSON, toast, t); console.log(admins.value ? admins.value.map((admin, index) => `Admin ${index + 1}: ${JSON.stringify(admin)}`) : 'Admins is null'); } diff --git a/frontend/src/composables/services/assistant.service.ts b/frontend/src/composables/services/assistant.service.ts index 91d0faec..1c305331 100644 --- a/frontend/src/composables/services/assistant.service.ts +++ b/frontend/src/composables/services/assistant.service.ts @@ -3,21 +3,22 @@ import {ref} from 'vue'; import {endpoints} from '@/config/endpoints.ts'; import { get, getList } from '@/composables/services/helpers.ts'; import { useToast } from 'primevue/usetoast'; +import {ComposerTranslation} from "vue-i18n"; export function useAssistant() { const assistants = ref(null); const assistant = ref(null); const toast = useToast(); - async function getAssistantByID(id: number) { + async function getAssistantByID(id: number, t: ComposerTranslation) { const endpoint = endpoints.assistants.retrieve.replace('{id}', id.toString()); - get(endpoint, assistant, Assistant.fromJSON, toast); + get(endpoint, assistant, Assistant.fromJSON, toast, t); console.log(assistant) } - async function getAssistants() { + async function getAssistants(t: ComposerTranslation) { const endpoint = endpoints.assistants.index; - getList(endpoint, assistants, Assistant.fromJSON, toast); + getList(endpoint, assistants, Assistant.fromJSON, toast, t); console.log(assistants.value ? assistants.value.map((assistant, index) => `Assistant ${index + 1}: ${JSON.stringify(assistant)}`) : 'assistants is null'); } diff --git a/frontend/src/composables/services/courses.service.ts b/frontend/src/composables/services/courses.service.ts index 9a559a9d..6f548e07 100644 --- a/frontend/src/composables/services/courses.service.ts +++ b/frontend/src/composables/services/courses.service.ts @@ -3,27 +3,28 @@ import {ref} from 'vue'; import {endpoints} from '@/config/endpoints.ts'; import { get, getList } from '@/composables/services/helpers.ts'; import { useToast } from 'primevue/usetoast'; +import {ComposerTranslation} from "vue-i18n"; export function useCourses() { const courses = ref(null); const course = ref(null); const toast = useToast(); - async function getCourseByID(id: number) { + async function getCourseByID(id: number, t: ComposerTranslation) { const endpoint = endpoints.courses.retrieve.replace('{id}', id.toString()); - get(endpoint, course, Course.fromJSON, toast); + get(endpoint, course, Course.fromJSON, toast, t); console.log(course.value); } - async function getCourses() { + async function getCourses(t: ComposerTranslation) { const endpoint = endpoints.courses.index; - getList(endpoint, courses, Course.fromJSON, toast); + getList(endpoint, courses, Course.fromJSON, toast, t); console.log(courses.value ? courses.value.map((course, index) => `Course ${index + 1}: ${JSON.stringify(course)}`) : 'Courses is null'); } - async function getCoursesByStudent(student_id: number) { + async function getCoursesByStudent(student_id: number, t: ComposerTranslation) { const endpoint = endpoints.courses.byStudent.replace('{student_id}', student_id.toString()); - getList(endpoint, courses, Course.fromJSON, toast); + getList(endpoint, courses, Course.fromJSON, toast, t); console.log(courses.value ? courses.value.map((course, index) => `Course ${index + 1}: ${JSON.stringify(course)}`) : 'Courses is null'); } diff --git a/frontend/src/composables/services/faculties.service.ts b/frontend/src/composables/services/faculties.service.ts index f94bf559..d236ab2b 100644 --- a/frontend/src/composables/services/faculties.service.ts +++ b/frontend/src/composables/services/faculties.service.ts @@ -3,21 +3,22 @@ import {ref} from 'vue'; import {endpoints} from '@/config/endpoints.ts'; import { get, getList } from '@/composables/services/helpers.ts'; import { useToast } from 'primevue/usetoast'; +import {ComposerTranslation} from "vue-i18n"; export function useFaculty() { const faculties = ref(null); const faculty = ref(null); const toast = useToast(); - async function getFacultyByID(name: string) { + async function getFacultyByID(name: string, t: ComposerTranslation) { const endpoint = endpoints.faculties.retrieve.replace('{name}', name); - get(endpoint, faculty, Faculty.fromJSON, toast); + get(endpoint, faculty, Faculty.fromJSON, toast, t); console.log(faculty) } - async function getFacultys() { + async function getFacultys(t: ComposerTranslation) { const endpoint = endpoints.faculties.index; - getList(endpoint, faculties, Faculty.fromJSON, toast); + getList(endpoint, faculties, Faculty.fromJSON, toast, t); console.log(faculties.value ? faculties.value.map((faculty, index) => `Faculty ${index + 1}: ${JSON.stringify(faculty)}`) : 'Facultys is null'); } diff --git a/frontend/src/composables/services/groups.service.ts b/frontend/src/composables/services/groups.service.ts index 0125e746..db53f6ec 100644 --- a/frontend/src/composables/services/groups.service.ts +++ b/frontend/src/composables/services/groups.service.ts @@ -3,21 +3,22 @@ import {ref} from 'vue'; import {endpoints} from '@/config/endpoints.ts'; import { get, getList } from '@/composables/services/helpers.ts'; import { useToast } from 'primevue/usetoast'; +import {ComposerTranslation} from "vue-i18n"; export function useGroup() { const groups = ref(null); const group = ref(null); const toast = useToast(); - async function getGroupByID(id: number) { + async function getGroupByID(id: number, t: ComposerTranslation) { const endpoint = endpoints.groups.retrieve.replace('{id}', id.toString()); - get(endpoint, group, Group.fromJSON, toast); + get(endpoint, group, Group.fromJSON, toast, t); console.log(group) } - async function getGroupsByProject(project_id: number) { + async function getGroupsByProject(project_id: number, t: ComposerTranslation) { const endpoint = endpoints.groups.byProject.replace('{project_id}', project_id.toString()); - getList(endpoint, groups, Group.fromJSON, toast); + getList(endpoint, groups, Group.fromJSON, toast, t); console.log(groups.value ? groups.value.map((group, index) => `Group ${index + 1}: ${JSON.stringify(group)}`) : 'Groups is null'); } diff --git a/frontend/src/composables/services/helpers.ts b/frontend/src/composables/services/helpers.ts index 3f5a96ca..026f06fa 100644 --- a/frontend/src/composables/services/helpers.ts +++ b/frontend/src/composables/services/helpers.ts @@ -1,18 +1,22 @@ import axios, { AxiosError, AxiosResponse } from 'axios'; +// import { useI18n } from 'vue-i18n'; import {Ref} from 'vue'; +import {ComposerTranslation} from "vue-i18n"; const lifeTime = 3000; -export async function get(endpoint: string, ref: Ref, fromJson: (data: any) => T, toast:any): Promise { +// const { t } = useI18n(); + +export async function get(endpoint: string, ref: Ref, fromJson: (data: any) => T, toast:any, t: ComposerTranslation): Promise { await axios.get(endpoint).then((response: AxiosResponse) => { ref.value = fromJson(response.data); //toast.add({severity: "success", summary: "Success Message", detail: "Order submitted", life: lifeTime}); }).catch((error: AxiosError) => { - processError(error, toast); + processError(error, toast, t); console.error(error); // Log the error for debugging }); } -export async function getList(endpoint: string, ref: Ref, fromJson: (data: any) => T, toast:any): Promise { +export async function getList(endpoint: string, ref: Ref, fromJson: (data: any) => T, toast:any, t: ComposerTranslation): Promise { await axios.get(endpoint).then(response => { ref.value = response.data.map((data: T) => fromJson(data)); @@ -20,12 +24,12 @@ export async function getList(endpoint: string, ref: Ref, fromJson: console.log(ref.value); } ).catch((error: AxiosError) => { - processError(error, toast); + processError(error, toast, t); console.error(error); // Log the error for debugging }); } -export async function getListMerged(endpoints: string[], ref: Ref, fromJson: (data: any) => T, toast:any): Promise { +export async function getListMerged(endpoints: string[], ref: Ref, fromJson: (data: any) => T, toast:any, t: ComposerTranslation): Promise { // Create an array to accumulate all response data const allData: T[] = []; @@ -38,29 +42,29 @@ export async function getListMerged(endpoints: string[], ref: Ref, // toast.add({severity: "success", summary: "Success Message", detail: "Order submitted", life: lifeTime}); } ).catch((error: AxiosError) => { - processError(error, toast); + processError(error, toast, t); console.error(error); // Log the error for debugging }); } ref.value = allData; } -function processError(error: AxiosError, toast:any){ +function processError(error: AxiosError, toast:any, t: ComposerTranslation){ if (error.response) { console.log(error.response.status); // The request was made and the server responded with a status code if (error.response.status === 404) { - toast.add({ severity: 'error', summary: 'Not Found', detail: 'Resource not found.', life: lifeTime }); + toast.add({ severity: 'error', summary: t('composables.helpers.errors.notFound'), detail: t('composables.helpers.errors.notFoundDetail'), life: lifeTime }); } else if (error.response.status === 401) { - toast.add({ severity: 'error', summary: 'Unauthorized', detail: 'You are not authorized to access this resource.', life: lifeTime }); + toast.add({ severity: 'error', summary: t('composables.helpers.errors.unauthorized'), detail: t('composables.helpers.errors.unauthorizedDetail'), life: lifeTime }); } else { - toast.add({ severity: 'error', summary: 'Server Error', detail: 'An error occurred on the server.', life: lifeTime }); + toast.add({ severity: 'error', summary: t('composables.helpers.errors.server'), detail: t('composables.helpers.errors.serverDetail'), life: lifeTime }); } } else if (error.request) { // The request was made but no response was received - toast.add({ severity: 'error', summary: 'Network Error', detail: 'Unable to connect to the server.', life: lifeTime }); + toast.add({ severity: 'error', summary: t('composables.helpers.errors.network'), detail: t('composables.helpers.errors.networkDetail'), life: lifeTime }); } else { // Something happened in setting up the request that triggered an error - toast.add({ severity: 'error', summary: 'Request Error', detail: 'An error occurred while making the request.', life: lifeTime }); + toast.add({ severity: 'error', summary: t('composables.helpers.errors.request'), detail: t('composables.helpers.errors.requestDetail'), life: lifeTime }); } } \ No newline at end of file diff --git a/frontend/src/views/calendar/CalendarView.vue b/frontend/src/views/calendar/CalendarView.vue index fdf4cd4d..ec6f909c 100644 --- a/frontend/src/views/calendar/CalendarView.vue +++ b/frontend/src/views/calendar/CalendarView.vue @@ -24,7 +24,7 @@ const { projects, getProjectsByStudent } = useProject(); // TODO: Set correct user ID const loadProjects = async () => { - await getProjectsByStudent("1"); + await getProjectsByStudent("1", t); }; /* Load the projects when the component is mounted */ diff --git a/frontend/src/views/courses/CourseView.vue b/frontend/src/views/courses/CourseView.vue index ec3b74a0..e6151edc 100644 --- a/frontend/src/views/courses/CourseView.vue +++ b/frontend/src/views/courses/CourseView.vue @@ -6,13 +6,16 @@ import Title from '@/components/Title.vue'; import {onMounted} from 'vue'; import {useCourses} from '@/composables/services/courses.service.ts'; import {useRoute} from 'vue-router'; +import {useI18n} from "vue-i18n"; const { params } = useRoute(); const { course, getCourseByID } = useCourses(); +const { t } = useI18n() onMounted(() => { getCourseByID( - parseInt(params.courseId as string) + parseInt(params.courseId as string), + t ); }); diff --git a/frontend/src/views/dashboard/DashboardView.vue b/frontend/src/views/dashboard/DashboardView.vue index 7cd0fe90..a17899e2 100644 --- a/frontend/src/views/dashboard/DashboardView.vue +++ b/frontend/src/views/dashboard/DashboardView.vue @@ -18,7 +18,7 @@ const { courses, getCoursesByStudent } = useCourses(); onMounted(async () => { console.log("fetching courses"); - await getCoursesByStudent(1); // TODO make this the id of the logged in user + await getCoursesByStudent(1, t); // TODO make this the id of the logged in user }); From 7e662cb03424d472a2f0da8967ecdf00687bf094 Mon Sep 17 00:00:00 2001 From: bsilkyn Date: Mon, 25 Mar 2024 20:35:31 +0100 Subject: [PATCH 3/4] chore: ComposerTranslation object gets passed through service functions part2 #149 --- .../src/composables/services/project.service.ts | 15 ++++++++------- .../services/structure_check.service.ts | 9 +++++---- .../src/composables/services/students.service.ts | 9 +++++---- .../composables/services/submission.service.ts | 13 +++++++------ .../services/submissionStatus.service.ts | 5 +++-- .../src/composables/services/teachers.service.ts | 9 +++++---- 6 files changed, 33 insertions(+), 27 deletions(-) diff --git a/frontend/src/composables/services/project.service.ts b/frontend/src/composables/services/project.service.ts index 97737eae..8fad1e67 100644 --- a/frontend/src/composables/services/project.service.ts +++ b/frontend/src/composables/services/project.service.ts @@ -5,6 +5,7 @@ import axios from 'axios'; import { get, getList, getListMerged } from '@/composables/services/helpers.ts'; import { Course } from '@/types/Course'; import { useToast } from 'primevue/usetoast'; +import {ComposerTranslation} from "vue-i18n"; export function useProject() { @@ -12,28 +13,28 @@ export function useProject() { const project = ref(null); const toast = useToast(); - async function getProjectByID(id: number) { + async function getProjectByID(id: number, t: ComposerTranslation) { const endpoint = endpoints.projects.retrieve.replace('{id}', id.toString()); - get(endpoint, project, Project.fromJSON, toast); + get(endpoint, project, Project.fromJSON, toast, t); console.log(project) } - async function getProjectsByCourse(course_id: number) { + async function getProjectsByCourse(course_id: number, t: ComposerTranslation) { const endpoint = endpoints.projects.byCourse.replace('{course_id}', course_id.toString()); - getList(endpoint, projects, Project.fromJSON, toast); + getList(endpoint, projects, Project.fromJSON, toast, t); console.log(projects.value ? projects.value.map((project, index) => `Project ${index + 1}: ${JSON.stringify(project)}`) : 'Projects is null'); } - async function getProjectsByStudent(student_id: string) { + async function getProjectsByStudent(student_id: string, t: ComposerTranslation) { const endpoint = endpoints.courses.byStudent.replace('{student_id}', student_id); const courses = ref(null); - await getList(endpoint, courses, Course.fromJSON, toast); + await getList(endpoint, courses, Course.fromJSON, toast, t); const endpList = []; for (const course of courses.value?courses.value:[]){ endpList.push(endpoints.projects.byCourse.replace('{course_id}', course.id.toString())); } - await getListMerged(endpList, projects, Project.fromJSON, toast); + await getListMerged(endpList, projects, Project.fromJSON, toast, t); console.log(projects.value ? projects.value.map((project, index) => `Project ${index + 1}: ${JSON.stringify(project)}`) : 'Projects is null'); } diff --git a/frontend/src/composables/services/structure_check.service.ts b/frontend/src/composables/services/structure_check.service.ts index fa50521a..33286234 100644 --- a/frontend/src/composables/services/structure_check.service.ts +++ b/frontend/src/composables/services/structure_check.service.ts @@ -3,21 +3,22 @@ import {ref} from 'vue'; import {endpoints} from '@/config/endpoints.ts'; import { get, getList } from '@/composables/services/helpers.ts'; import { useToast } from 'primevue/usetoast'; +import {ComposerTranslation} from "vue-i18n"; export function useStructure_check() { const structure_checks = ref(null); const structure_check = ref(null); const toast = useToast(); - async function getStructure_checkByID(id: number) { + async function getStructure_checkByID(id: number, t: ComposerTranslation) { const endpoint = endpoints.structure_checks.retrieve.replace('{id}', id.toString()); - get(endpoint, structure_check, Structure_check.fromJSON, toast); + get(endpoint, structure_check, Structure_check.fromJSON, toast, t); console.log(structure_check) } - async function getStructure_checkByProject(project_id: number) { + async function getStructure_checkByProject(project_id: number, t: ComposerTranslation) { const endpoint = endpoints.structure_checks.byProject.replace('{project_id}', project_id.toString()); - getList(endpoint, structure_checks, Structure_check.fromJSON, toast); + getList(endpoint, structure_checks, Structure_check.fromJSON, toast, t); console.log(structure_checks.value ? structure_checks.value.map((structure_check, index) => `Structure_check ${index + 1}: ${JSON.stringify(structure_check)}`) : 'Structure_check is null'); } diff --git a/frontend/src/composables/services/students.service.ts b/frontend/src/composables/services/students.service.ts index 1812ef5a..3b2a5abd 100644 --- a/frontend/src/composables/services/students.service.ts +++ b/frontend/src/composables/services/students.service.ts @@ -3,21 +3,22 @@ import {ref} from 'vue'; import {endpoints} from '@/config/endpoints.ts'; import { get, getList } from '@/composables/services/helpers.ts'; import { useToast } from 'primevue/usetoast'; +import {ComposerTranslation} from "vue-i18n"; export function useStudents() { const students = ref(null); const student = ref(null); const toast = useToast(); - async function getStudentByID(id: number) { + async function getStudentByID(id: number, t: ComposerTranslation) { const endpoint = endpoints.students.retrieve.replace('{id}', id.toString()); - get(endpoint, student, Student.fromJSON, toast); + get(endpoint, student, Student.fromJSON, toast, t); console.log(student) } - async function getStudents() { + async function getStudents(t: ComposerTranslation) { const endpoint = endpoints.students.index; - getList(endpoint, students, Student.fromJSON, toast); + getList(endpoint, students, Student.fromJSON, toast, t); console.log(students.value ? students.value.map((student, index) => `Student ${index + 1}: ${JSON.stringify(student)}`) : 'Students is null'); } diff --git a/frontend/src/composables/services/submission.service.ts b/frontend/src/composables/services/submission.service.ts index 248d9124..ad11c10b 100644 --- a/frontend/src/composables/services/submission.service.ts +++ b/frontend/src/composables/services/submission.service.ts @@ -3,27 +3,28 @@ import {ref} from 'vue'; import {endpoints} from '@/config/endpoints.ts'; import { get, getList } from '@/composables/services/helpers.ts'; import { useToast } from 'primevue/usetoast'; +import {ComposerTranslation} from "vue-i18n"; export function useSubmission() { const submissions = ref(null); const submission = ref(null); const toast = useToast(); - async function getSubmissionByID(id: number) { + async function getSubmissionByID(id: number, t: ComposerTranslation) { const endpoint = endpoints.submissions.retrieve.replace('{id}', id.toString()); - get(endpoint, submission, Submission.fromJSON, toast); + get(endpoint, submission, Submission.fromJSON, toast, t); console.log(submission) } - async function getSubmissionByProject(project_id: number) { + async function getSubmissionByProject(project_id: number, t: ComposerTranslation) { const endpoint = endpoints.submissions.byProject.replace('{project_id}', project_id.toString()); - getList(endpoint, submissions, Submission.fromJSON, toast); + getList(endpoint, submissions, Submission.fromJSON, toast, t); console.log(submissions.value ? submissions.value.map((submission, index) => `Submission ${index + 1}: ${JSON.stringify(submission)}`) : 'Submission is null'); } - async function getSubmissionByGroup(group_id: number) { + async function getSubmissionByGroup(group_id: number, t: ComposerTranslation) { const endpoint = endpoints.submissions.byGroup.replace('{group_id}', group_id.toString()); - getList(endpoint, submissions, Submission.fromJSON, toast); + getList(endpoint, submissions, Submission.fromJSON, toast, t); console.log(submissions.value ? submissions.value.map((submission, index) => `Submission ${index + 1}: ${JSON.stringify(submission)}`) : 'Submission is null'); } diff --git a/frontend/src/composables/services/submissionStatus.service.ts b/frontend/src/composables/services/submissionStatus.service.ts index dada2f91..7167cf4e 100644 --- a/frontend/src/composables/services/submissionStatus.service.ts +++ b/frontend/src/composables/services/submissionStatus.service.ts @@ -3,14 +3,15 @@ import {endpoints} from '@/config/endpoints.ts'; import { get} from '@/composables/services/helpers.ts'; import { SubmissionStatus } from '@/types/SubmisionStatus'; import { useToast } from 'primevue/usetoast'; +import {ComposerTranslation} from "vue-i18n"; export function useSubmission() { const submissionStatus = ref(null); const toast = useToast(); - async function getSubmissionStatus(project_id: number) { + async function getSubmissionStatus(project_id: number, t: ComposerTranslation) { const endpoint = endpoints.submissions.status.replace('{project_id}', project_id.toString()); - get(endpoint, submissionStatus, SubmissionStatus.fromJSON, toast); + get(endpoint, submissionStatus, SubmissionStatus.fromJSON, toast, t); console.log(submissionStatus) } diff --git a/frontend/src/composables/services/teachers.service.ts b/frontend/src/composables/services/teachers.service.ts index 1b5d7252..3adca0fe 100644 --- a/frontend/src/composables/services/teachers.service.ts +++ b/frontend/src/composables/services/teachers.service.ts @@ -3,21 +3,22 @@ import {ref} from 'vue'; import {endpoints} from '@/config/endpoints.ts'; import { get, getList } from '@/composables/services/helpers.ts'; import { useToast } from 'primevue/usetoast'; +import {ComposerTranslation} from "vue-i18n"; export function useTeacher() { const teachers = ref(null); const teacher = ref(null); const toast = useToast(); - async function getTeacherByID(id: number) { + async function getTeacherByID(id: number, t: ComposerTranslation) { const endpoint = endpoints.teachers.retrieve.replace('{id}', id.toString()); - get(endpoint, teacher, Teacher.fromJSON, toast); + get(endpoint, teacher, Teacher.fromJSON, toast, t); console.log(teacher) } - async function getTeachers() { + async function getTeachers(t: ComposerTranslation) { const endpoint = endpoints.teachers.index; - getList(endpoint, teachers, Teacher.fromJSON, toast); + getList(endpoint, teachers, Teacher.fromJSON, toast, t); console.log(teachers.value ? teachers.value.map((teacher, index) => `Teacher ${index + 1}: ${JSON.stringify(teacher)}`) : 'Teachers is null'); } From f6efa3e5cfc619e87a1bb19c6bab8cafce5b5719 Mon Sep 17 00:00:00 2001 From: bsilkyn Date: Mon, 25 Mar 2024 21:23:34 +0100 Subject: [PATCH 4/4] chore: remove unnecessary translation #149 --- frontend/src/assets/lang/en.json | 1 - frontend/src/assets/lang/nl.json | 1 - 2 files changed, 2 deletions(-) diff --git a/frontend/src/assets/lang/en.json b/frontend/src/assets/lang/en.json index 4346605d..1a707f07 100644 --- a/frontend/src/assets/lang/en.json +++ b/frontend/src/assets/lang/en.json @@ -27,7 +27,6 @@ "composables": { "helpers": { "errors": { - "error": "error", "notFound": "Not Found", "notFoundDetail": "Resource not found.", "unauthorized": "Unauthorized", diff --git a/frontend/src/assets/lang/nl.json b/frontend/src/assets/lang/nl.json index b9801cb4..216684fa 100644 --- a/frontend/src/assets/lang/nl.json +++ b/frontend/src/assets/lang/nl.json @@ -36,7 +36,6 @@ "composables": { "helpers": { "errors": { - "error": "fout", "notFound": "Niet Gevonden", "notFoundDetail": "Resource niet gevonden.", "unauthorized": "Onbevoegd",