mirror of
https://github.com/kingomarnajjar/flex-template-web.git
synced 2026-07-28 20:53:24 +10:00
ProfileSettingsPage and form use storableError func and correct proptype validation.
This commit is contained in:
parent
54e2a9a44e
commit
d8520f8e6d
3 changed files with 13 additions and 11 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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))));
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue