rdv: edit calendar ranges: create and update calendar ranges

This commit is contained in:
nobohan
2021-08-30 17:44:52 +02:00
parent 0fe6d7d00b
commit 6d607e3939
4 changed files with 127 additions and 9 deletions

View File

@@ -35,8 +35,49 @@ const fetchCalendar = (mainUserId) => {
});
};
/*
* Endpoint chill_api_single_calendar_range__entity_create
* method POST or DELETE, post CalendarRange entity
*/
const postCalendarRange = (body, method) => {
const url = `/api/1.0/calendar/calendar-range.json?`;
return fetch(url, {
method: method,
headers: {
'Content-Type': 'application/json;charset=utf-8'
},
body: JSON.stringify(body)
}).then(response => {
if (response.ok) { return response.json(); }
throw Error('Error with request resource response');
});
};
/*
* Endpoint chill_api_single_calendar_range__entity
* method PATCH, patch CalendarRange entity
*/
const patchCalendarRange = (id, body) => {
console.log(body)
const url = `/api/1.0/calendar/calendar-range/${id}.json`;
return fetch(url, {
method: 'PATCH',
headers: {
'Content-Type': 'application/json;charset=utf-8'
},
body: JSON.stringify(body)
}).then(response => {
if (response.ok) { return response.json(); }
throw Error('Error with request resource response');
});
};
export {
fetchCalendarRanges,
fetchCalendar,
fetchCalendarRangesByUser
fetchCalendarRangesByUser,
postCalendarRange,
patchCalendarRange
};