fix initialComment with patch endpoint

This commit is contained in:
2021-05-19 10:34:17 +02:00
parent 9ef397e935
commit 27f49b2aa3
3 changed files with 30 additions and 54 deletions

View File

@@ -4,8 +4,7 @@ import { getAccompanyingCourse,
patchAccompanyingCourse,
postParticipation,
postRequestor,
postResource,
postComment } from '../api';
postResource } from '../api';
const debug = process.env.NODE_ENV !== 'production';
const id = window.accompanyingCourseId;
@@ -74,7 +73,8 @@ let initPromise = getAccompanyingCourse(id)
state.accompanyingCourse.confidential = value;
},
postFirstComment(state, comment) {
state.accompanyingCourse.comments.push(comment);
console.log('### mutation: postFirstComment', comment);
state.accompanyingCourse.initialComment = comment;
}
},
actions: {
@@ -162,9 +162,10 @@ let initPromise = getAccompanyingCourse(id)
})).catch((error) => { commit('catchError', error) });
},
postFirstComment({ commit }, payload) {
postComment(id, payload)
.then(comment => new Promise((resolve, reject) => {
commit('postFirstComment', comment);
console.log('## action: postFirstComment: payload', payload);
patchAccompanyingCourse(id, { type: "accompanying_period", initialComment: payload })
.then(course => new Promise((resolve, reject) => {
commit('postFirstComment', course.initialComment);
resolve();
})).catch((error) => { commit('catchError', error) });
}