Return the returns

This commit is contained in:
Chi Vinh Le
2017-06-21 20:04:38 +07:00
parent 9b26bc9d96
commit 4b063607ab
6 changed files with 13 additions and 14 deletions
+2 -2
View File
@@ -19,7 +19,7 @@ import t from 'coral-framework/services/i18n';
// Get comments to fill each of the three lists on the mod queue
export const fetchAssets = (skip = '', limit = '', search = '', sort = '', filter = '') => (dispatch) => {
dispatch({type: FETCH_ASSETS_REQUEST});
coralApi(`/assets?skip=${skip}&limit=${limit}&sort=${sort}&search=${search}&filter=${filter}`)
return coralApi(`/assets?skip=${skip}&limit=${limit}&sort=${sort}&search=${search}&filter=${filter}`)
.then(({result, count}) =>
dispatch({type: FETCH_ASSETS_SUCCESS,
assets: result,
@@ -36,7 +36,7 @@ export const fetchAssets = (skip = '', limit = '', search = '', sort = '', filte
// Get comments to fill each of the three lists on the mod queue
export const updateAssetState = (id, closedAt) => (dispatch) => {
dispatch({type: UPDATE_ASSET_STATE_REQUEST});
coralApi(`/assets/${id}/status`, {method: 'PUT', body: {closedAt}})
return coralApi(`/assets/${id}/status`, {method: 'PUT', body: {closedAt}})
.then(() => dispatch({type: UPDATE_ASSET_STATE_SUCCESS}))
.catch((error) => {
console.error(error);
+4 -5
View File
@@ -52,17 +52,16 @@ export const newPage = () => ({
});
export const setRole = (id, role) => (dispatch) => {
coralApi(`/users/${id}/role`, {method: 'POST', body: {role}})
return coralApi(`/users/${id}/role`, {method: 'POST', body: {role}})
.then(() => {
dispatch({type: SET_ROLE, id, role});
return dispatch({type: SET_ROLE, id, role});
});
};
export const setCommenterStatus = (id, status) => (dispatch) => {
coralApi(`/users/${id}/status`, {method: 'POST', body: {status}})
return coralApi(`/users/${id}/status`, {method: 'POST', body: {status}})
.then(() => {
dispatch({type: SET_COMMENTER_STATUS, id, status});
return dispatch({type: SET_COMMENTER_STATUS, id, status});
});
};
+1 -1
View File
@@ -87,7 +87,7 @@ export const submitUser = () => (dispatch, getState) => {
export const finishInstall = () => (dispatch, getState) => {
const data = getState().install.toJS().data;
dispatch(installRequest());
coralApi('/setup', {method: 'POST', body: data})
return coralApi('/setup', {method: 'POST', body: data})
.then(() => {
dispatch(installSuccess());
dispatch(nextStep());
+3 -3
View File
@@ -9,7 +9,7 @@ import t from 'coral-framework/services/i18n';
export const userStatusUpdate = (status, userId, commentId) => {
return (dispatch) => {
dispatch({type: userTypes.UPDATE_STATUS_REQUEST});
coralApi(`/users/${userId}/status`, {method: 'POST', body: {status: status, comment_id: commentId}})
return coralApi(`/users/${userId}/status`, {method: 'POST', body: {status: status, comment_id: commentId}})
.then((res) => dispatch({type: userTypes.UPDATE_STATUS_SUCCESS, res}))
.catch((error) => {
console.error(error);
@@ -22,7 +22,7 @@ export const userStatusUpdate = (status, userId, commentId) => {
// change status of a user
export const sendNotificationEmail = (userId, subject, body) => {
return (dispatch) => {
coralApi(`/users/${userId}/email`, {method: 'POST', body: {subject, body}})
return coralApi(`/users/${userId}/email`, {method: 'POST', body: {subject, body}})
.catch((error) => {
console.error(error);
const errorMessage = error.translation_key ? t(`error.${error.translation_key}`) : error.toString();
@@ -34,7 +34,7 @@ export const sendNotificationEmail = (userId, subject, body) => {
// let a user edit their username
export const enableUsernameEdit = (userId) => {
return (dispatch) => {
coralApi(`/users/${userId}/username-enable`, {method: 'POST'})
return coralApi(`/users/${userId}/username-enable`, {method: 'POST'})
.catch((error) => {
console.error(error);
const errorMessage = error.translation_key ? t(`error.${error.translation_key}`) : error.toString();
+2 -2
View File
@@ -133,7 +133,7 @@ export const fetchSignIn = (formData) => {
return (dispatch) => {
dispatch(signInRequest());
coralApi('/auth/local', {method: 'POST', body: formData})
return coralApi('/auth/local', {method: 'POST', body: formData})
.then(({token}) => {
if (!bowser.safari && !bowser.ios) {
dispatch(handleAuthToken(token));
@@ -360,7 +360,7 @@ const verifyEmailFailure = () => ({
export const requestConfirmEmail = (email) => (dispatch, getState) => {
const redirectUri = getState().auth.toJS().redirectUri;
dispatch(verifyEmailRequest());
coralApi('/users/resend-verify', {
return coralApi('/users/resend-verify', {
method: 'POST',
body: {email},
headers: {'X-Pym-Url': redirectUri}
+1 -1
View File
@@ -8,7 +8,7 @@ const editUsernameFailure = (error) => ({type: actions.EDIT_USERNAME_FAILURE, er
const editUsernameSuccess = () => ({type: actions.EDIT_USERNAME_SUCCESS});
export const editName = (username) => (dispatch) => {
coralApi('/account/username', {method: 'PUT', body: {username}})
return coralApi('/account/username', {method: 'PUT', body: {username}})
.then(() => {
dispatch(editUsernameSuccess());
dispatch(addNotification('success', t('framework.success_name_update')));