mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 15:13:50 +00:00
interlocutors: actions, mutations, fetch request (wip)
This commit is contained in:
@@ -3,7 +3,8 @@ import { createStore } from 'vuex';
|
||||
import { getAccompanyingCourse,
|
||||
patchAccompanyingCourse,
|
||||
postParticipation,
|
||||
postRequestor } from '../api';
|
||||
postRequestor,
|
||||
postResource } from '../api';
|
||||
|
||||
const debug = process.env.NODE_ENV !== 'production';
|
||||
const id = window.accompanyingCourseId;
|
||||
@@ -38,21 +39,30 @@ let initPromise = getAccompanyingCourse(id)
|
||||
state.accompanyingCourse.participations.push(participation);
|
||||
},
|
||||
removeRequestor(state) {
|
||||
console.log('### mutation: removeRequestor');
|
||||
//console.log('### mutation: removeRequestor');
|
||||
state.accompanyingCourse.requestor = null;
|
||||
},
|
||||
addRequestor(state, requestor) {
|
||||
console.log('### mutation: addRequestor', requestor);
|
||||
//console.log('### mutation: addRequestor', requestor);
|
||||
state.accompanyingCourse.requestor = requestor;
|
||||
},
|
||||
requestorIsAnonymous(state, value) {
|
||||
console.log('### mutation: requestorIsAnonymous', value);
|
||||
//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);
|
||||
},
|
||||
addInterlocutor(state, interlocutor) {
|
||||
console.log('### mutation: addInterlocutor', interlocutor);
|
||||
state.accompanyingCourse.resources.push(interlocutor);
|
||||
},
|
||||
},
|
||||
actions: {
|
||||
removeParticipation({ commit }, payload) {
|
||||
commit('removeParticipation', payload);
|
||||
// fetch DELETE request...
|
||||
},
|
||||
closeParticipation({ commit }, payload) {
|
||||
console.log('## action: fetch delete participation: payload', payload);
|
||||
@@ -77,7 +87,7 @@ let initPromise = getAccompanyingCourse(id)
|
||||
});
|
||||
},
|
||||
removeRequestor({ commit }) {
|
||||
console.log('## action: fetch post requestor');
|
||||
console.log('## action: fetch delete requestor');
|
||||
postRequestor(id, null, 'DELETE')
|
||||
.then(requestor => new Promise((resolve, reject) => {
|
||||
commit('removeRequestor');
|
||||
@@ -109,7 +119,30 @@ let initPromise = getAccompanyingCourse(id)
|
||||
.catch((error) => {
|
||||
state.errorMsg.push(error.message);
|
||||
});
|
||||
}
|
||||
},
|
||||
removeInterlocutor({ commit }, payload) {
|
||||
console.log('## action: fetch postInterlocutor: payload', payload);
|
||||
postResource(id, payload, 'POST')
|
||||
.then(resource => new Promise((resolve, reject) => {
|
||||
commit('removeInterlocutor', resource)
|
||||
resolve();
|
||||
}))
|
||||
.catch((error) => {
|
||||
state.errorMsg.push(error.message);
|
||||
});
|
||||
},
|
||||
addInterlocutor({ commit }, payload) {
|
||||
console.log('## action: fetch postInterlocutor: payload', payload);
|
||||
postResource(id, payload, 'POST')
|
||||
.then(resource => new Promise((resolve, reject) => {
|
||||
commit('addInterlocutor', resource)
|
||||
resolve();
|
||||
}))
|
||||
.catch((error) => {
|
||||
state.errorMsg.push(error.message);
|
||||
});
|
||||
|
||||
},
|
||||
}
|
||||
});
|
||||
resolve(store);
|
||||
|
Reference in New Issue
Block a user