ProfileSettingsPage and form use storableError func and correct proptype validation.

This commit is contained in:
Vesa Luusua 2017-10-17 19:45:54 +03:00
parent 54e2a9a44e
commit d8520f8e6d
3 changed files with 13 additions and 11 deletions

View file

@ -5,6 +5,7 @@ import { FormattedMessage, injectIntl, intlShape } from 'react-intl';
import { Field, reduxForm, propTypes as formPropTypes } from 'redux-form';
import classNames from 'classnames';
import { ensureCurrentUser } from '../../util/data';
import * as propTypes from '../../util/propTypes';
import * as validators from '../../util/validators';
import { isUploadProfileImageOverLimitError } from '../../util/errors';
import { Form, Avatar, Button, ImageFromFile, IconSpinner, TextInputField } from '../../components';
@ -60,7 +61,7 @@ const RenderAvatar = props => {
};
RenderAvatar.defaultProps = { uploadImageError: null };
const { bool, func, instanceOf, node, object, shape, string } = PropTypes;
const { bool, func, node, object, shape, string } = PropTypes;
RenderAvatar.propTypes = {
accept: string.isRequired,
@ -73,7 +74,7 @@ RenderAvatar.propTypes = {
}).isRequired,
label: node.isRequired,
type: string.isRequired,
uploadImageError: instanceOf(Error),
uploadImageError: propTypes.error,
};
class ProfileSettingsFormComponent extends Component {
@ -293,10 +294,10 @@ ProfileSettingsFormComponent.propTypes = {
rootClassName: string,
className: string,
uploadImageError: instanceOf(Error),
uploadImageError: propTypes.error,
uploadInProgress: bool.isRequired,
updateInProgress: bool.isRequired,
updateProfileError: instanceOf(Error),
updateProfileError: propTypes.error,
updateProfileReady: bool,
// from injectIntl

View file

@ -1,4 +1,5 @@
import { updatedEntities, denormalisedEntities } from '../../util/data';
import { storableError } from '../../util/errors';
import { currentUserShowSuccess } from '../../ducks/user.duck';
// ================ Action types ================ //
@ -120,7 +121,7 @@ export function uploadImage(actionPayload) {
const uploadedImage = resp.data.data;
dispatch(uploadImageSuccess({ data: { id, uploadedImage } }));
})
.catch(e => dispatch(uploadImageError({ id, error: e })));
.catch(e => dispatch(uploadImageError({ id, error: storableError(e) })));
};
}
@ -142,6 +143,6 @@ export const updateProfile = actionPayload => {
// Update current user in state.user.currentUser through user.duck.js
dispatch(currentUserShowSuccess(currentUser));
})
.catch(e => dispatch(updateProfileError(e)));
.catch(e => dispatch(updateProfileError(storableError(e))));
};
};

View file

@ -114,10 +114,10 @@ ProfileSettingsPageComponent.defaultProps = {
image: null,
};
const { bool, func, instanceOf, object, shape, string } = PropTypes;
const { bool, func, object, shape, string } = PropTypes;
ProfileSettingsPageComponent.propTypes = {
authInfoError: instanceOf(Error),
authInfoError: propTypes.error,
currentUser: propTypes.currentUser,
image: shape({
id: string,
@ -125,14 +125,14 @@ ProfileSettingsPageComponent.propTypes = {
file: object,
uploadedImage: propTypes.image,
}),
logoutError: instanceOf(Error),
logoutError: propTypes.error,
onChange: func.isRequired,
onImageUpload: func.isRequired,
onUpdateProfile: func.isRequired,
scrollingDisabled: bool.isRequired,
updateInProgress: bool.isRequired,
updateProfileError: instanceOf(Error),
uploadImageError: instanceOf(Error),
updateProfileError: propTypes.error,
uploadImageError: propTypes.error,
uploadInProgress: bool.isRequired,
};