mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
adapt payload body to entity convention with type + id
This commit is contained in:
@@ -2,8 +2,8 @@
|
||||
const getBodyTypeId = (payload) => {
|
||||
const body = {};
|
||||
if (payload !== null) {
|
||||
const typeId = `${payload.result.type}_id`;
|
||||
body[typeId] = payload.result[typeId];
|
||||
body['type'] = payload.type;
|
||||
body['id'] = payload.id;
|
||||
};
|
||||
console.log('body', body);
|
||||
return body;
|
||||
@@ -52,17 +52,18 @@ const patchAccompanyingCourse = (id, body) => {
|
||||
* method POST/DELETE, add/close a participation to the accompanyingCourse
|
||||
*
|
||||
* @id integer - id of accompanyingCourse
|
||||
* @person_id integer - id of person
|
||||
* @payload integer - id of person
|
||||
* @method string - POST or DELETE
|
||||
*/
|
||||
const postParticipation = (id, person_id, method) => {
|
||||
const postParticipation = (id, payload, method) => {
|
||||
const body = getBodyTypeId(payload);
|
||||
const url = `/api/1.0/person/accompanying-course/${id}/participation.json`;
|
||||
return fetch(url, {
|
||||
method: method,
|
||||
headers: {
|
||||
'Content-Type': 'application/json;charset=utf-8'
|
||||
},
|
||||
body: JSON.stringify({person_id: person_id})
|
||||
body: JSON.stringify(body)
|
||||
})
|
||||
.then(response => {
|
||||
if (response.ok) { return response.json(); }
|
||||
|
Reference in New Issue
Block a user