Merge branch 'handle-error-messages-from-api' into 'develop'
Handle custom error messages from API See merge request soapbox-pub/soapbox-fe!1525
This commit is contained in:
commit
316818736e
1 changed files with 8 additions and 9 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
import { AxiosError } from 'axios';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { useIntl } from 'react-intl';
|
import { useIntl } from 'react-intl';
|
||||||
import OtpInput from 'react-otp-input';
|
import OtpInput from 'react-otp-input';
|
||||||
|
@ -61,15 +62,13 @@ const SmsVerification = () => {
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
setStatus(Statuses.REQUESTED);
|
setStatus(Statuses.REQUESTED);
|
||||||
}).catch(() => {
|
}).catch((error: AxiosError) => {
|
||||||
dispatch(
|
const message = (error.response?.data as any)?.message || intl.formatMessage({
|
||||||
snackbar.error(
|
|
||||||
intl.formatMessage({
|
|
||||||
id: 'sms_verification.fail',
|
id: 'sms_verification.fail',
|
||||||
defaultMessage: 'Failed to send SMS message to your phone number.',
|
defaultMessage: 'Failed to send SMS message to your phone number.',
|
||||||
}),
|
});
|
||||||
),
|
|
||||||
);
|
dispatch(snackbar.error(message));
|
||||||
setStatus(Statuses.FAIL);
|
setStatus(Statuses.FAIL);
|
||||||
});
|
});
|
||||||
}, [phone, isValid]);
|
}, [phone, isValid]);
|
||||||
|
|
Loading…
Reference in a new issue