mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 15:13:50 +00:00
add and remove requestor functions
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import 'es6-promise/auto';
|
||||
import { createStore } from 'vuex';
|
||||
import { getAccompanyingCourse, postParticipation } from '../api';
|
||||
import { getAccompanyingCourse, postParticipation, postRequestor } from '../api';
|
||||
|
||||
const debug = process.env.NODE_ENV !== 'production';
|
||||
const id = window.accompanyingCourseId;
|
||||
@@ -34,9 +34,13 @@ let initPromise = getAccompanyingCourse(id)
|
||||
//console.log('### mutation: add participation', participation);
|
||||
state.accompanyingCourse.participations.push(participation);
|
||||
},
|
||||
removeRequestor(state) {
|
||||
state.accompanyingCourse.requestor = null;
|
||||
},
|
||||
addRequestor(state, requestor) {
|
||||
console.log(requestor);
|
||||
},
|
||||
state.accompanyingCourse.requestor = requestor;
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
removeParticipation({ commit }, payload) {
|
||||
@@ -58,7 +62,16 @@ let initPromise = getAccompanyingCourse(id)
|
||||
postParticipation(id, payload.result.person_id, 'POST')
|
||||
.then(participation => new Promise((resolve, reject) => {
|
||||
commit('addParticipation', participation);
|
||||
//addPersons.commit('resetState', payload);
|
||||
resolve();
|
||||
}))
|
||||
.catch((error) => {
|
||||
state.errorMsg.push(error.message);
|
||||
});
|
||||
},
|
||||
removeRequestor({ commit }) {
|
||||
postRequestor(id, null, 'DELETE')
|
||||
.then(requestor => new Promise((resolve, reject) => {
|
||||
commit('removeRequestor');
|
||||
resolve();
|
||||
}))
|
||||
.catch((error) => {
|
||||
@@ -67,7 +80,14 @@ let initPromise = getAccompanyingCourse(id)
|
||||
},
|
||||
addRequestor({ commit }, payload) {
|
||||
console.log(payload);
|
||||
commit('addRequestor', payload);
|
||||
postRequestor(id, payload, 'POST')
|
||||
.then(requestor => new Promise((resolve, reject) => {
|
||||
commit('addRequestor', requestor);
|
||||
resolve();
|
||||
}))
|
||||
.catch((error) => {
|
||||
state.errorMsg.push(error.message);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
Reference in New Issue
Block a user