From c1e3c6f65736e2482f2584d3ad7108deb4139818 Mon Sep 17 00:00:00 2001 From: Anthony Debucquoy Date: Wed, 6 Mar 2024 22:57:01 +0100 Subject: [PATCH 1/2] stub for courses --- frontend/src/rest/courses.js | 52 ++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 frontend/src/rest/courses.js diff --git a/frontend/src/rest/courses.js b/frontend/src/rest/courses.js new file mode 100644 index 0000000..0d21eaf --- /dev/null +++ b/frontend/src/rest/courses.js @@ -0,0 +1,52 @@ +/** + * Courses API + */ + +import { restGet, restPost } from './restConsumer.js' + +/** + * Create a new course + */ +export async function createCourse(name, credits, faculty, teacher, assistants){ + return restPost("/courses", {name: name, credits: credits, faculty: faculty, teacher: teacher, assistants: assistants} ) +} + +/** + * Delete the specified course + */ +export async function deleteCourse(id){ + return restDelete("/course/" + id); +} + +/** + * Get informations on a particular course + * + * @param id identification of the course + * + * @return all atribute of the specified course + * - name + * - credits + * - faculty + * - teacher + * - assistants : list + */ +export async function getCourse(id){ + return restGet("/course/" + id); +} + +/** + * Change the options of a course + * + * @param id the id of the course + * @param changes Object with value to changes + * + * The changes object can contain: + * - name + * - credits + * - faculty + * - teacher + * - assistants: should be a list and will replace all assistants + */ +export async function alterCourse(id, changes){ + return restPatch("/course/" + id, changes); +} -- 2.46.0 From 674409d9482f121f89ed44e7cd078a9b8a7256b6 Mon Sep 17 00:00:00 2001 From: Anthony Debucquoy Date: Wed, 6 Mar 2024 23:11:00 +0100 Subject: [PATCH 2/2] adding the right dependencies --- frontend/src/rest/courses.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/rest/courses.js b/frontend/src/rest/courses.js index 0d21eaf..0b98284 100644 --- a/frontend/src/rest/courses.js +++ b/frontend/src/rest/courses.js @@ -2,7 +2,7 @@ * Courses API */ -import { restGet, restPost } from './restConsumer.js' +import { restGet, restPost, restDelete, restPatch } from './restConsumer.js' /** * Create a new course -- 2.46.0