[user profile] handle errors in saving user profile edits
This commit is contained in:
parent
b81b6ad1c2
commit
6a040c2a96
|
@ -11,7 +11,7 @@ export const SAVE_USER_PROFILE_INFORMATION_FETCH_SUCCESS = 'SAVE_USER_PROFILE_IN
|
|||
export const SAVE_USER_PROFILE_INFORMATION_FETCH_FAIL = 'SAVE_USER_PROFILE_INFORMATION_FETCH_FAIL'
|
||||
export const RESEND_USER_CONFIRMATION_EMAIL_SUCCESS = 'RESEND_USER_CONFIRMATION_EMAIL_SUCCESS'
|
||||
|
||||
export const saveUserProfileInformation = (data) => {
|
||||
export const saveUserProfileInformation = (data, closer) => {
|
||||
return function (dispatch, getState) {
|
||||
if (!isObject(data) || !me) return
|
||||
|
||||
|
@ -31,6 +31,7 @@ export const saveUserProfileInformation = (data) => {
|
|||
}).then((response) => {
|
||||
dispatch(importFetchedAccount(response.data))
|
||||
dispatch(saveUserProfileInformationSuccess(response.data))
|
||||
closer()
|
||||
}).catch(error => {
|
||||
dispatch(saveUserProfileInformationFail(error))
|
||||
})
|
||||
|
|
|
@ -98,8 +98,8 @@ class EditProfileModal extends ImmutablePureComponent {
|
|||
if (account.get('avatar_static') !== avatarSrc) obj.avatar = avatarSrc
|
||||
if (account.get('header_static') !== headerSrc) obj.header = headerSrc
|
||||
|
||||
this.props.onSave(obj)
|
||||
this.handleOnClose()
|
||||
this.props.onSave(obj, this.handleOnClose)
|
||||
//this.handleOnClose()
|
||||
}
|
||||
|
||||
render() {
|
||||
|
@ -210,7 +210,7 @@ const mapStateToProps = (state) => ({
|
|||
})
|
||||
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
onSave: (data) => dispatch(saveUserProfileInformation(data)),
|
||||
onSave: (data, closer) => dispatch(saveUserProfileInformation(data, closer)),
|
||||
})
|
||||
|
||||
EditProfileModal.propTypes = {
|
||||
|
|
|
@ -19,6 +19,7 @@ export default function (state = initialState, action) {
|
|||
case SAVE_USER_PROFILE_INFORMATION_FETCH_SUCCESS:
|
||||
return state
|
||||
case SAVE_USER_PROFILE_INFORMATION_FETCH_FAIL:
|
||||
alert('Failed to update your profile. Max profile image size is 2MB. Please update and try again.')
|
||||
return state.set('isError', true)
|
||||
case RESEND_USER_CONFIRMATION_EMAIL_SUCCESS:
|
||||
return state.set('emailConfirmationResends', state.get('emailConfirmationResends') + 1)
|
||||
|
|
Loading…
Reference in New Issue