From aef97cca3219ac76610c99cdf2007aae7128f676 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Thu, 13 May 2021 10:05:08 +0200 Subject: [PATCH] fetch post resource --- .../public/vuejs/AccompanyingCourse/api.js | 15 +++++++++---- .../components/InterlocutorItem.vue | 16 +++++--------- .../components/Interlocutors.vue | 22 +++++++++---------- .../vuejs/AccompanyingCourse/store/index.js | 22 +++++++++---------- 4 files changed, 39 insertions(+), 36 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/api.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/api.js index 2c136ac16..8e49a2e21 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/api.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/api.js @@ -1,5 +1,5 @@ -const getBodyTypeId = (payload) => { +const getEntityTypeId = (payload) => { const body = {}; if (payload !== null) { body['type'] = payload.type; @@ -56,7 +56,7 @@ const patchAccompanyingCourse = (id, body) => { * @method string - POST or DELETE */ const postParticipation = (id, payload, method) => { - const body = getBodyTypeId(payload); + const body = getEntityTypeId(payload); const url = `/api/1.0/person/accompanying-course/${id}/participation.json`; return fetch(url, { method: method, @@ -80,7 +80,7 @@ const postParticipation = (id, payload, method) => { * @method string - POST or DELETE */ const postRequestor = (id, payload, method) => { - const body = getBodyTypeId(payload); + const body = getEntityTypeId(payload); const url = `/api/1.0/person/accompanying-course/${id}/requestor.json`; return fetch(url, { method: method, @@ -104,7 +104,14 @@ const postRequestor = (id, payload, method) => { * @method string - POST or DELETE */ const postResource = (id, payload, method) => { - const body = getBodyTypeId(payload); + console.log('payload', payload); + const body = { type: "accompanying_period_resource" }; + if (method === 'DELETE') { + body['id'] = payload.id; + } else { + body['resource'] = getEntityTypeId(payload); + } + console.log('body', body); const url = `/api/1.0/person/accompanying-course/${id}/resource.json`; return fetch(url, { method: method, diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/InterlocutorItem.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/InterlocutorItem.vue index 75222fc52..ecc0e7727 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/InterlocutorItem.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/InterlocutorItem.vue @@ -1,14 +1,10 @@