mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 15:13:50 +00:00
requestor logic, is_anonymous patch request
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
import 'es6-promise/auto';
|
||||
import { createStore } from 'vuex';
|
||||
import { getAccompanyingCourse, postParticipation, postRequestor } from '../api';
|
||||
import { getAccompanyingCourse,
|
||||
patchAccompanyingCourse,
|
||||
postParticipation,
|
||||
postRequestor } from '../api';
|
||||
|
||||
const debug = process.env.NODE_ENV !== 'production';
|
||||
const id = window.accompanyingCourseId;
|
||||
@@ -35,11 +38,16 @@ let initPromise = getAccompanyingCourse(id)
|
||||
state.accompanyingCourse.participations.push(participation);
|
||||
},
|
||||
removeRequestor(state) {
|
||||
console.log('### mutation: removeRequestor');
|
||||
state.accompanyingCourse.requestor = null;
|
||||
},
|
||||
addRequestor(state, requestor) {
|
||||
console.log(requestor);
|
||||
console.log('### mutation: addRequestor', requestor);
|
||||
state.accompanyingCourse.requestor = requestor;
|
||||
},
|
||||
requestorIsAnonymous(state, value) {
|
||||
console.log('### mutation: requestorIsAnonymous', value);
|
||||
state.accompanyingCourse.requestorAnonymous = value;
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
@@ -69,9 +77,11 @@ let initPromise = getAccompanyingCourse(id)
|
||||
});
|
||||
},
|
||||
removeRequestor({ commit }) {
|
||||
console.log('## action: fetch post requestor');
|
||||
postRequestor(id, null, 'DELETE')
|
||||
.then(requestor => new Promise((resolve, reject) => {
|
||||
commit('removeRequestor');
|
||||
commit('requestorIsAnonymous', false);
|
||||
resolve();
|
||||
}))
|
||||
.catch((error) => {
|
||||
@@ -79,7 +89,7 @@ let initPromise = getAccompanyingCourse(id)
|
||||
});
|
||||
},
|
||||
addRequestor({ commit }, payload) {
|
||||
console.log(payload);
|
||||
console.log('## action: fetch post requestor: payload', payload);
|
||||
postRequestor(id, payload, 'POST')
|
||||
.then(requestor => new Promise((resolve, reject) => {
|
||||
commit('addRequestor', requestor);
|
||||
@@ -90,7 +100,15 @@ let initPromise = getAccompanyingCourse(id)
|
||||
});
|
||||
},
|
||||
requestorIsAnonymous({ commit }, payload) {
|
||||
console.log('payload', payload);
|
||||
console.log('## action: fetch patch AccompanyingCourse: payload', payload);
|
||||
patchAccompanyingCourse(id, { requestorAnonymous: payload })
|
||||
.then(course => new Promise((resolve, reject) => {
|
||||
commit('requestorIsAnonymous', course.requestorAnonymous)
|
||||
resolve();
|
||||
}))
|
||||
.catch((error) => {
|
||||
state.errorMsg.push(error.message);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
Reference in New Issue
Block a user