mirror of
https://github.com/kingomarnajjar/flex-template-web.git
synced 2026-07-28 03:43:28 +10:00
Merge pull request #469 from sharetribe/handle-avatar-image-over-limit-error
Handle upload-over-limit error for profile image
This commit is contained in:
commit
e2a2fb5a7b
3 changed files with 24 additions and 5 deletions
|
|
@ -5,6 +5,7 @@ import { Field, reduxForm, propTypes as formPropTypes } from 'redux-form';
|
|||
import classNames from 'classnames';
|
||||
import { ensureCurrentUser } from '../../util/data';
|
||||
import * as validators from '../../util/validators';
|
||||
import { isUploadProfileImageOverLimitError } from '../../util/errors';
|
||||
import { Form, Avatar, Button, ImageFromFile, IconSpinner, TextInputField } from '../../components';
|
||||
|
||||
import css from './ProfileSettingsForm.css';
|
||||
|
|
@ -15,11 +16,22 @@ const UPLOAD_CHANGE_DELAY = 2000; // Show spinner so that browser has time to lo
|
|||
const RenderAvatar = props => {
|
||||
const { accept, id, input, label, type, disabled, uploadImageError } = props;
|
||||
const { name, onChange } = input;
|
||||
const error = uploadImageError
|
||||
? <div className={css.error}>
|
||||
|
||||
let error = null;
|
||||
|
||||
if (isUploadProfileImageOverLimitError(uploadImageError)) {
|
||||
error = (
|
||||
<div className={css.error}>
|
||||
<FormattedMessage id="ProfileSettingsForm.imageUploadFailedFileTooLarge" />
|
||||
</div>
|
||||
);
|
||||
} else if (uploadImageError) {
|
||||
error = (
|
||||
<div className={css.error}>
|
||||
<FormattedMessage id="ProfileSettingsForm.imageUploadFailed" />
|
||||
</div>
|
||||
: null;
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={css.uploadAvatarWrapper}>
|
||||
|
|
|
|||
|
|
@ -22,10 +22,10 @@
|
|||
"BookingBreakdown.commission": "Saunatime fee",
|
||||
"BookingBreakdown.nightCount": "{count, number} {count, plural, one {night} other {nights}}",
|
||||
"BookingBreakdown.pricePerNight": "Price per night",
|
||||
"BookingBreakdown.providerTotalCanceled": "Total price",
|
||||
"BookingBreakdown.providerTotalDefault": "You'll make",
|
||||
"BookingBreakdown.providerTotalDelivered": "You made",
|
||||
"BookingBreakdown.providerTotalRejected": "You would have made",
|
||||
"BookingBreakdown.providerTotalCanceled": "Total price",
|
||||
"BookingBreakdown.subTotal": "Subtotal",
|
||||
"BookingBreakdown.total": "Total price",
|
||||
"BookingDatesForm.bookingEndTitle": "End date",
|
||||
|
|
@ -367,6 +367,7 @@
|
|||
"ProfileSettingsForm.firstNamePlaceholder": "John",
|
||||
"ProfileSettingsForm.firstNameRequired": "This field is required",
|
||||
"ProfileSettingsForm.imageUploadFailed": "Whoopsie, something went wrong - please try again.",
|
||||
"ProfileSettingsForm.imageUploadFailedFileTooLarge": "Image was too big. Maximum size is 10 MB.",
|
||||
"ProfileSettingsForm.lastNameLabel": "Last name",
|
||||
"ProfileSettingsForm.lastNamePlaceholder": "Doe",
|
||||
"ProfileSettingsForm.lastNameRequired": "This field is required",
|
||||
|
|
|
|||
|
|
@ -59,7 +59,13 @@ export const isTooManyEmailVerificationRequestsError = apiError =>
|
|||
export const isUploadListingImageOverLimitError = apiError =>
|
||||
hasErrorWithCode(apiError, ERROR_CODE_UPLOAD_OVER_LIMIT);
|
||||
|
||||
// TODO: avatar upload over limit
|
||||
/**
|
||||
* Check if the given API error (from
|
||||
* `sdk.images.uploadProfileImage()`) is due to the image being over
|
||||
* the size limit.
|
||||
*/
|
||||
export const isUploadProfileImageOverLimitError = apiError =>
|
||||
hasErrorWithCode(apiError, ERROR_CODE_UPLOAD_OVER_LIMIT);
|
||||
|
||||
/**
|
||||
* Check if the given API error (from `sdk.passwordReset.request()`)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue