mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
fix initialComment with patch endpoint
This commit is contained in:
@@ -119,45 +119,10 @@ const postResource = (id, payload, method) => {
|
||||
});
|
||||
};
|
||||
|
||||
/*
|
||||
* Endpoint v.2 chill_api_single_accompanying_course_comment,
|
||||
* method POST/DELETE/PATCH, add/remove a comment to the accompanyingCourse
|
||||
*
|
||||
* @id integer - id of accompanyingCourse
|
||||
* @payload
|
||||
* @method string - POST, DELETE or PATCH
|
||||
*/
|
||||
const postComment = (id, payload) => {
|
||||
console.log('payload', payload);
|
||||
const body = { type: "accompanying_period_comment" };
|
||||
switch (payload.method) {
|
||||
case 'POST':
|
||||
body['content'] = payload.content;
|
||||
break;
|
||||
case 'DELETE':
|
||||
body['id'] = 42;
|
||||
break;
|
||||
}
|
||||
console.log('body', body);
|
||||
const url = `/api/1.0/person/accompanying-course/${id}/comment.json`;
|
||||
return fetch(url, {
|
||||
method: payload.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');
|
||||
});
|
||||
};
|
||||
|
||||
export {
|
||||
getAccompanyingCourse,
|
||||
patchAccompanyingCourse,
|
||||
postParticipation,
|
||||
postRequestor,
|
||||
postResource,
|
||||
postComment
|
||||
};
|
||||
|
Reference in New Issue
Block a user