add Comment component, make POST comment request

This commit is contained in:
2021-05-17 15:56:58 +02:00
parent 2aa13dceff
commit e0dc0a8fdb
6 changed files with 111 additions and 9 deletions

View File

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