mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 13:20:31 +00:00
fix: handle error.
This commit is contained in:
@@ -39,11 +39,14 @@ function NotifyEstimateViaSMSForm({
|
||||
data: { errors },
|
||||
},
|
||||
}) => {
|
||||
transformErrors(errors);
|
||||
if (errors) {
|
||||
transformErrors(errors, { setErrors });
|
||||
}
|
||||
setSubmitting(false);
|
||||
};
|
||||
createNotifyEstimateBySMSMutate([estimateId, values])
|
||||
.then(onSuccess)
|
||||
.then(onError);
|
||||
.catch(onError);
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@@ -42,7 +42,10 @@ function NotifyInvoiceViaSMSForm({
|
||||
data: { errors },
|
||||
},
|
||||
}) => {
|
||||
transformErrors(errors);
|
||||
if (errors) {
|
||||
transformErrors(errors, { setErrors });
|
||||
}
|
||||
setSubmitting(false);
|
||||
};
|
||||
createNotifyInvoiceBySMSMutate([invoiceId, values])
|
||||
.then(onSuccess)
|
||||
|
||||
@@ -44,7 +44,10 @@ function NotifyPaymentReceiveViaSMSForm({
|
||||
data: { errors },
|
||||
},
|
||||
}) => {
|
||||
transformErrors(errors);
|
||||
if (errors) {
|
||||
transformErrors(errors, { setErrors });
|
||||
}
|
||||
setSubmitting(false);
|
||||
};
|
||||
createNotifyPaymentReceivetBySMSMutate([paymentReceiveId, values])
|
||||
.then(onSuccess)
|
||||
|
||||
@@ -42,7 +42,10 @@ function NotifyReceiptViaSMSForm({
|
||||
data: { errors },
|
||||
},
|
||||
}) => {
|
||||
transformErrors(errors);
|
||||
if (errors) {
|
||||
transformErrors(errors, { setErrors });
|
||||
}
|
||||
setSubmitting(false);
|
||||
};
|
||||
createNotifyReceiptBySMSMutate([receiptId, values])
|
||||
.then(onSuccess)
|
||||
|
||||
@@ -2,11 +2,19 @@ import { Intent } from '@blueprintjs/core';
|
||||
import { AppToaster } from 'components';
|
||||
import intl from 'react-intl-universal';
|
||||
|
||||
export const transformErrors = (errors) => {
|
||||
export const transformErrors = (errors, { setErrors }) => {
|
||||
if (errors.some((e) => e.type === 'CUSTOMER_SMS_NOTIFY_PHONE_INVALID')) {
|
||||
AppToaster.show({
|
||||
message: intl.get('notify_via_sms.dialog.error_message'),
|
||||
intent: Intent.DANGER,
|
||||
});
|
||||
}
|
||||
|
||||
if (errors.find((error) => error.type === 'CUSTOMER_HAS_NO_PHONE_NUMBER')) {
|
||||
setErrors({
|
||||
customer_phone_number: intl.get(
|
||||
'notify_via_sms.dialog.customer_no_phone_error_message',
|
||||
),
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user