diff --git a/frontend/src/views/courses/UpdateCourseView.vue b/frontend/src/views/courses/UpdateCourseView.vue index 6f1bd218..37042792 100644 --- a/frontend/src/views/courses/UpdateCourseView.vue +++ b/frontend/src/views/courses/UpdateCourseView.vue @@ -3,7 +3,6 @@ import BaseLayout from '@/components/layout/base/BaseLayout.vue'; import Title from '@/components/layout/Title.vue'; import InputText from 'primevue/inputtext'; import Textarea from 'primevue/textarea'; -import ErrorMessage from '@/components/forms/ErrorMessage.vue'; import Editor from '@/components/forms/Editor.vue'; import Button from 'primevue/button'; import Dropdown from 'primevue/dropdown'; @@ -15,12 +14,14 @@ import { useFaculty } from '@/composables/services/faculty.service.ts'; import { Faculty } from '@/types/Faculty'; import { required, helpers } from '@vuelidate/validators'; import { useVuelidate } from '@vuelidate/core'; +import ErrorMessage from '@/components/forms/ErrorMessage.vue'; +import { Course } from '@/types/Course'; /* Composable injections */ const { params } = useRoute(); const { t } = useI18n(); const { push } = useRouter(); -const { course, getCourseByID } = useCourses(); +const { course, getCourseByID, updateCourse } = useCourses(); const { faculties, getFaculties } = useFaculty(); /* Load course data */ @@ -63,17 +64,20 @@ const submitCourse = async (): Promise => { const result = await v$.value.$validate(); // Only submit the form if the validation was successful - if (result) { + if (result && course.value !== null) { // Pass the course data to the service - // TODO: Update course service - // await createCourse( - // new Course( - // '', // ID not needed for creation, will be generated by the backend - // form.name, - // form.description, - // form.year.getFullYear(), - // ), - // ); + await updateCourse( + new Course( + course.value.id, + form.name, + form.description, + form.excerpt, + course.value.academic_startyear, + course.value.parent_course, + form.faculty, + ), + ); + // Redirect to the course overview // Redirect to the dashboard overview await push({ name: 'course', params: { courseId: params.courseId as string } });