From 963014fcafcb7aacaec88f87bb1b484474ef9c41 Mon Sep 17 00:00:00 2001 From: Bram Meir Date: Sat, 6 Apr 2024 12:01:15 +0200 Subject: [PATCH 01/10] chore: project creation faculty --- frontend/src/assets/lang/en.json | 2 +- frontend/src/assets/lang/nl.json | 2 +- .../composables/services/courses.service.ts | 9 ++-- .../src/views/courses/CreateCourseView.vue | 47 +++++++++++-------- 4 files changed, 35 insertions(+), 25 deletions(-) diff --git a/frontend/src/assets/lang/en.json b/frontend/src/assets/lang/en.json index 5a5da5d3..5a0889bf 100644 --- a/frontend/src/assets/lang/en.json +++ b/frontend/src/assets/lang/en.json @@ -55,7 +55,7 @@ "create": "Create course", "name": "Course name", "description": "Description", - "year": "Academic year" + "faculty": "Faculty" } }, "composables": { diff --git a/frontend/src/assets/lang/nl.json b/frontend/src/assets/lang/nl.json index 38c5579c..b20bfff3 100644 --- a/frontend/src/assets/lang/nl.json +++ b/frontend/src/assets/lang/nl.json @@ -55,7 +55,7 @@ "create": "Creëer vak", "name": "Vaknaam", "description": "Beschrijving", - "year": "Academiejaar", + "faculty": "Faculteit", "search": { "search": "Zoeken", "faculty": "Faculteit", diff --git a/frontend/src/composables/services/courses.service.ts b/frontend/src/composables/services/courses.service.ts index 2cfe0620..a984e6d5 100644 --- a/frontend/src/composables/services/courses.service.ts +++ b/frontend/src/composables/services/courses.service.ts @@ -4,6 +4,7 @@ import { endpoints } from '@/config/endpoints.ts'; import { get, getList, create, deleteId, getPaginatedList } from '@/composables/services/helpers.ts'; import { type PaginatorResponse } from '@/types/filter/Paginator.ts'; import { type Filter } from '@/types/filter/Filter.ts'; +import { Response } from '@/types/Response.ts'; interface CoursesState { pagination: Ref | null>; @@ -24,6 +25,7 @@ export function useCourses(): CoursesState { const pagination = ref | null>(null); const courses = ref(null); const course = ref(null); + const response = ref(null); async function getCourseByID(id: string): Promise { const endpoint = endpoints.courses.retrieve.replace('{id}', id); @@ -57,15 +59,16 @@ export function useCourses(): CoursesState { async function createCourse(courseData: Course): Promise { const endpoint = endpoints.courses.index; - await create( + await create( endpoint, { name: courseData.name, description: courseData.description, academic_startyear: courseData.academic_startyear, + faculty: courseData.faculty?.id, }, - course, - Course.fromJSON, + response, + Response.fromJSON, ); } diff --git a/frontend/src/views/courses/CreateCourseView.vue b/frontend/src/views/courses/CreateCourseView.vue index 50f5b7cd..d05d1e20 100644 --- a/frontend/src/views/courses/CreateCourseView.vue +++ b/frontend/src/views/courses/CreateCourseView.vue @@ -1,42 +1,45 @@