1
0
forked from PGL/Clyde

link backend Post Patch Delete Lesson

This commit is contained in:
2024-04-16 22:03:48 +02:00
parent 9112004326
commit a2be04bfb3
17 changed files with 282 additions and 79 deletions

View File

@ -3,8 +3,8 @@ import {restGet,restPatch,restPost,restDelete} from "@/rest/restConsumer.js";
/**
* Create a new lesson
*/
export async function createLesson(course, lessonStart, lessonEnd, lessonType, color, local){
return restPost("/lesson", {course: course , lessonStart: lessonStart, lessonEnd: lessonEnd,lessonType:lessonType ,color : color , local : local} )
export async function createLesson(datas){
return restPost("/lesson", datas )
}
/**

View File

@ -20,6 +20,10 @@ export async function restDelete(endPoint) {
return await _rest(endPoint, {method: "DELETE"});
}
export async function restDeleteItem(endPoint, data){
return await _rest(endPoint, {method: "DELETE", credentials: 'include', body: JSON.stringify(data)});
}
export async function restPatch(endPoint, data) {
return await _rest(endPoint, {method: "PATCH", credentials: 'include', body: JSON.stringify(data)});
}
@ -41,8 +45,9 @@ async function _rest(endPoint, config){
'Content-Type': 'application/json',
});
config['headers'] = config['headers'] == null ? headers : config['headers'];
console.log(config)
return toast.promise(fetch(restURL + endPoint, config),
{
{
pending: config['pending'] != null ? config['pending'] : 'pending',
error: config['error'] != null ? config['error'] : 'Network Failure...',
success: config['success'] != null ? config['success'] : {render(res){

View File

@ -1,4 +1,4 @@
import {restGet,restPost,restPatch} from "@/rest/restConsumer.js";
import {restGet, restPost, restPatch, restDelete, restDeleteItem} from "@/rest/restConsumer.js";
export async function getAllSchedule(){
return restGet('/schedules');
@ -19,3 +19,12 @@ export async function getCurriculumSchedule(id){
export async function addLessonToSchedule(id,lessonId){
return restPost('/schedule/' + id, lessonId)
}
export async function getSchedule(id){
return restGet('/schedule/' + id);
}
export async function deleteLessonFromSchedule(id,lessonId){
return restDeleteItem('/schedule/lesson/'+ id, lessonId)
}