Skip to content

Commit

Permalink
Update UpdateCourseView.vue
Browse files Browse the repository at this point in the history
  • Loading branch information
tyboro2002 authored Apr 18, 2024
1 parent 8150bb0 commit bb49e91
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions frontend/src/views/courses/UpdateCourseView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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 */
Expand Down Expand Up @@ -63,17 +64,20 @@ const submitCourse = async (): Promise<void> => {
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 } });
Expand Down

0 comments on commit bb49e91

Please sign in to comment.