mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-14 06:14:23 +00:00
37 lines
1.1 KiB
JavaScript
37 lines
1.1 KiB
JavaScript
const
|
|
locale = 'fr',
|
|
format = 'json'
|
|
, accompanying_period_id = window.accompanyingCourseId //tmp
|
|
;
|
|
|
|
// 1. chill_person_accompanying_course_api_show (GET)
|
|
let getAccompanyingCourse = (accompanying_period_id___) => { //tmp
|
|
const url = `/${locale}/person/api/1.0/accompanying-course/${accompanying_period_id}/show.${format}`;
|
|
return fetch(url)
|
|
.then(response => {
|
|
if (response.ok) { return response.json(); }
|
|
throw Error('Error with request resource response');
|
|
});
|
|
};
|
|
|
|
// 2. chill_person_accompanying_course_api_add_participation (POST)
|
|
let postParticipation = (accompanying_period_id, person_id) => {
|
|
const url = `/${locale}/person/api/1.0/accompanying-course/${accompanying_period_id}/participation.${format}`
|
|
return fetch(url, {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json;charset=utf-8'
|
|
},
|
|
body: JSON.stringify({id: person_id})
|
|
})
|
|
.then(response => {
|
|
if (response.ok) { return response.json(); }
|
|
throw Error('Error with request resource response');
|
|
});
|
|
};
|
|
|
|
export {
|
|
getAccompanyingCourse,
|
|
postParticipation
|
|
};
|