Merge pull request #40 from coralproject/flagging-adapt-api

api-adapt(coral-admin): Get flagging mod queue working with the backend
This commit is contained in:
David Erwin
2016-11-09 16:46:56 -05:00
committed by GitHub
3 changed files with 11 additions and 4 deletions
+1 -1
View File
@@ -39,7 +39,7 @@ const updateStatus = (state, action) => {
// Flag a comment
const flag = (state, action) => {
const byId = state.get('byId');
const data = byId.get(action.id).get('data').set('flagged', true);
const data = byId.get(action.id).set('flagged', true);
const comment = byId.get(action.id).set('data', data);
return state.set('byId', byId.set(action.id, comment));
};
@@ -29,15 +29,20 @@ export default store => next => action => {
// Get comments to fill each of the three lists on the mod queue
const fetchModerationQueueComments = store =>
fetch('/api/v1/queue')
.then(res => res.json())
Promise.all([fetch('/api/v1/comments/status/pending'), fetch('/api/v1/comments/status/rejected'), fetch('/api/v1/comments/action/flag')])
.then(res => Promise.all(res.map(r => r.json())))
.then(res => {
res[2] = res[2].map(comment => { comment.flagged = true; return comment; });
return res.reduce((prev, curr) => prev.concat(curr), []);
})
.then(res => store.dispatch({type: 'COMMENTS_MODERATION_QUEUE_FETCH_SUCCESS',
comments: res}))
.catch(error => store.dispatch({type: 'COMMENTS_MODERATION_QUEUE_FETCH_FAILED', error}));
// Update a comment. Now to update a comment we need to send back the whole object
const updateComment = (store, comment) =>
fetch(`/api/v1/comments/${comment._id}/status`, {
fetch('/api/v1/comments/${comment._id}/status', {
method: 'POST',
body: JSON.stringify({status: comment.status})
})
+2
View File
@@ -58,8 +58,10 @@
"babel-core": "^6.18.2",
"babel-loader": "^6.2.7",
"babel-plugin-transform-async-to-generator": "^6.16.0",
"babel-plugin-transform-class-properties": "^6.18.0",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-plugin-transform-object-assign": "^6.8.0",
"babel-plugin-transform-object-rest-spread": "^6.16.0",
"babel-plugin-transform-react-jsx": "^6.8.0",
"babel-polyfill": "^6.16.0",
"babel-preset-es2015": "^6.18.0",