diff --git a/client/coral-admin/src/actions/comments.js b/client/coral-admin/src/actions/comments.js index 89cd87d89..e755f1ed1 100644 --- a/client/coral-admin/src/actions/comments.js +++ b/client/coral-admin/src/actions/comments.js @@ -20,7 +20,7 @@ export const fetchModerationQueueComments = () => { actions: [...pending.actions, ...rejected.actions, ...flagged.actions] }; }) - .then(({comments, users, actions}) => { + .then(({comments, users}) => { /* Post comments and users to redux store. Actions will be posted when they are needed. */ dispatch({type: commentActions.USERS_MODERATION_QUEUE_FETCH_SUCCESS, users}); diff --git a/client/coral-admin/src/actions/users.js b/client/coral-admin/src/actions/users.js index 07d7dff3a..bc42a7a4c 100644 --- a/client/coral-admin/src/actions/users.js +++ b/client/coral-admin/src/actions/users.js @@ -1,4 +1,5 @@ import coralApi from '../../../coral-framework/helpers/response'; +import * as actions from '../constants/user'; /** * Action disptacher related to users @@ -6,8 +7,9 @@ import coralApi from '../../../coral-framework/helpers/response'; // change status of a user export const userStatusUpdate = (status, userId, commentId) => { return dispatch => { + dispatch({type: actions.UPDATE_STATUS_REQUEST}); return coralApi(`/users/${userId}/status`, {method: 'POST', body: {status: status, comment_id: commentId}}) - .then(res => dispatch({type: 'USER_BAN_SUCESS', res})) - .catch(error => dispatch({type: 'USER_BAN_FAILED', error})); + .then(res => dispatch({type: actions.UPDATE_STATUS_SUCCESS, res})) + .catch(error => dispatch({type: actions.UPDATE_STATUS_FAILURE, error})); }; }; diff --git a/client/coral-admin/src/constants/user.js b/client/coral-admin/src/constants/user.js new file mode 100644 index 000000000..8c0563237 --- /dev/null +++ b/client/coral-admin/src/constants/user.js @@ -0,0 +1,3 @@ +export const UPDATE_STATUS_REQUEST = 'UPDATE_STATUS_REQUEST'; +export const UPDATE_STATUS_SUCCESS = 'UPDATE_STATUS_SUCCESS'; +export const UPDATE_STATUS_FAILURE = 'UPDATE_STATUS_FAILURE'; diff --git a/client/coral-admin/src/reducers/comments.js b/client/coral-admin/src/reducers/comments.js index 1ab341595..2856b0a34 100644 --- a/client/coral-admin/src/reducers/comments.js +++ b/client/coral-admin/src/reducers/comments.js @@ -1,4 +1,5 @@ import * as actions from '../constants/comments'; +import * as userActions from '../constants/user'; import {Map, List, fromJS} from 'immutable'; /** @@ -32,7 +33,7 @@ export default (state = initialState, action) => { case actions.COMMENT_STREAM_FETCH_SUCCESS: return replaceComments(action, state); case actions.SHOW_BANUSER_DIALOG: return setBanUser(state, true, action); case actions.HIDE_BANUSER_DIALOG: return setBanUser(state, false, action); - case actions.USER_BAN_SUCESS: return setBanUser(state, false, action); + case userActions.UPDATE_STATUS_SUCCESS: return setBanUser(state, false, action); default: return state; } };