diff --git a/src/containers/Dialogs/SMSMessageDialog/SMSMessageForm.js b/src/containers/Dialogs/SMSMessageDialog/SMSMessageForm.js index 3a98f36a6..19924f2c8 100644 --- a/src/containers/Dialogs/SMSMessageDialog/SMSMessageForm.js +++ b/src/containers/Dialogs/SMSMessageDialog/SMSMessageForm.js @@ -9,6 +9,7 @@ import { AppToaster } from 'components'; import SMSMessageFormContent from './SMSMessageFormContent'; import { CreateSMSMessageFormSchema } from './SMSMessageForm.schema'; import { useSMSMessageDialogContext } from './SMSMessageDialogProvider'; +import { transformErrors } from './utils'; import withDialogActions from 'containers/Dialog/withDialogActions'; @@ -60,6 +61,9 @@ function SMSMessageForm({ data: { errors }, }, }) => { + if (errors) { + transformErrors(errors, { setErrors }); + } setSubmitting(false); }; diff --git a/src/containers/Dialogs/SMSMessageDialog/utils.js b/src/containers/Dialogs/SMSMessageDialog/utils.js new file mode 100644 index 000000000..b4f46f1f7 --- /dev/null +++ b/src/containers/Dialogs/SMSMessageDialog/utils.js @@ -0,0 +1,15 @@ +import { Intent } from '@blueprintjs/core'; +import { AppToaster } from 'components'; +import intl from 'react-intl-universal'; + +export const transformErrors = (errors, { setErrors }) => { + if ( + errors.find((error) => error.type === 'UNSUPPORTED_SMS_MESSAGE_VARIABLES') + ) { + setErrors({ + message_text: intl.get( + 'sms_message.dialog.unsupported_variables_error_message', + ), + }); + } +}; diff --git a/src/lang/en/index.json b/src/lang/en/index.json index 1c791975b..6fec2ea85 100644 --- a/src/lang/en/index.json +++ b/src/lang/en/index.json @@ -1445,6 +1445,7 @@ "sms_message.label_Notification":"Notification", "sms_message.label_auto":"Auto", "sms_message":"SMS message", - "sms_message.dialog.success_message":"Sms notification settings has been updated successfully." + "sms_message.dialog.success_message":"Sms notification settings has been updated successfully.", + "sms_message.dialog.unsupported_variables_error_message":"Unsupported variables" }