mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
add Comment component, make POST comment request
This commit is contained in:
@@ -121,18 +121,27 @@ const postResource = (id, payload, method) => {
|
||||
|
||||
/*
|
||||
* Endpoint v.2 chill_api_single_accompanying_course_comment,
|
||||
* method POST/DELETE, add/remove a comment to the accompanyingCourse
|
||||
* method POST/DELETE/PATCH, add/remove a comment to the accompanyingCourse
|
||||
*
|
||||
* @id integer - id of accompanyingCourse
|
||||
* @payload
|
||||
* @method string - POST or DELETE
|
||||
* @method string - POST, DELETE or PATCH
|
||||
*/
|
||||
const postComment = (id, payload, method) => {
|
||||
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 = `/1.0/person/accompanying-course/${id}/comment.json`;
|
||||
const url = `/api/1.0/person/accompanying-course/${id}/comment.json`;
|
||||
return fetch(url, {
|
||||
method: method,
|
||||
method: payload.method,
|
||||
headers: {
|
||||
'Content-Type': 'application/json;charset=utf-8'
|
||||
},
|
||||
@@ -142,7 +151,7 @@ const postComment = (id, payload, method) => {
|
||||
if (response.ok) { return response.json(); }
|
||||
throw Error('Error with request resource response');
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export {
|
||||
getAccompanyingCourse,
|
||||
|
Reference in New Issue
Block a user