fetch post resource

This commit is contained in:
2021-05-13 10:05:08 +02:00
parent 87e2ac9386
commit aef97cca32
4 changed files with 39 additions and 36 deletions

View File

@@ -23,9 +23,9 @@ let initPromise = getAccompanyingCourse(id)
getters: {
},
mutations: {
removeParticipation(state, item) {
//console.log('### mutation: remove item', item.id);
state.accompanyingCourse.participations = state.accompanyingCourse.participations.filter(participation => participation !== item);
removeParticipation(state, participation) {
//console.log('### mutation: remove participation', participation.id);
state.accompanyingCourse.participations = state.accompanyingCourse.participations.filter(element => element !== participation);
},
closeParticipation(state, { participation, payload }) {
//console.log('### mutation: close item', { participation, payload });
@@ -50,13 +50,13 @@ let initPromise = getAccompanyingCourse(id)
//console.log('### mutation: requestorIsAnonymous', value);
state.accompanyingCourse.requestorAnonymous = value;
},
removeInterlocutor(state, interlocutor) {
console.log('### mutation: removeInterlocutor', interlocutor);
state.accompanyingCourse.resources = state.accompanyingCourse.resources.filter(resource => resource !== interlocutor);
removeInterlocutor(state, resource) {
console.log('### mutation: removeInterlocutor', resource);
state.accompanyingCourse.resources = state.accompanyingCourse.resources.filter(element => element !== resource);
},
addInterlocutor(state, interlocutor) {
console.log('### mutation: addInterlocutor', interlocutor);
state.accompanyingCourse.resources.push(interlocutor);
addInterlocutor(state, resource) {
console.log('### mutation: addInterlocutor', resource);
state.accompanyingCourse.resources.push(resource);
},
},
actions: {
@@ -122,9 +122,9 @@ let initPromise = getAccompanyingCourse(id)
},
removeInterlocutor({ commit }, payload) {
console.log('## action: fetch postInterlocutor: payload', payload);
postResource(id, payload, 'POST')
postResource(id, payload, 'DELETE')
.then(resource => new Promise((resolve, reject) => {
commit('removeInterlocutor', resource)
commit('removeInterlocutor', payload) // mieux un retour de l'objet !
resolve();
}))
.catch((error) => {