diff --git a/src/containers/Alerts/EasySMSIntegration/EasySMSDisconnectAlert.js b/src/containers/Alerts/EasySMSIntegration/EasySMSDisconnectAlert.js index 899392528..f891cb99d 100644 --- a/src/containers/Alerts/EasySMSIntegration/EasySMSDisconnectAlert.js +++ b/src/containers/Alerts/EasySMSIntegration/EasySMSDisconnectAlert.js @@ -4,6 +4,8 @@ import { FormattedMessage as T, FormattedHTMLMessage } from 'components'; import { Intent, Alert } from '@blueprintjs/core'; import { AppToaster } from 'components'; +import { useSettingEasySMSDisconnect } from 'hooks/query'; + import withAlertStoreConnect from 'containers/Alert/withAlertStoreConnect'; import withAlertActions from 'containers/Alert/withAlertActions'; @@ -22,13 +24,28 @@ function EasySMSDisconnectAlert({ // #withAlertActions closeAlert, }) { + const { mutateAsync: disconnectEasySMS, isLoading } = + useSettingEasySMSDisconnect(); + // Handle cancel Disconnect alert. const handleCancelDisconnect = () => { closeAlert(name); }; // Handle confirm Disconnect alert. - const handleConfirmDisconnect = () => {}; + const handleConfirmDisconnect = () => { + disconnectEasySMS() + .then(() => { + AppToaster.show({ + message: intl.get('easysms.disconnect.alert.success_message'), + intent: Intent.SUCCESS, + }); + }) + .catch(() => {}) + .finally(() => { + closeAlert(name); + }); + }; return (

Ea aliqua elit reprehenderit pariatur consequat voluptate quis.

diff --git a/src/containers/Dialogs/EasySMSIntegrationDialog/EasySMSIntegrationForm.js b/src/containers/Dialogs/EasySMSIntegrationDialog/EasySMSIntegrationForm.js index 4fcd66873..0342b26fb 100644 --- a/src/containers/Dialogs/EasySMSIntegrationDialog/EasySMSIntegrationForm.js +++ b/src/containers/Dialogs/EasySMSIntegrationDialog/EasySMSIntegrationForm.js @@ -8,6 +8,7 @@ import '../../../style/pages/EasySMSIntegration/EasySMSIntegration.scss'; import { AppToaster } from 'components'; import EasySMSIntegrationFormContent from './EasySMSIntegrationFormContent'; import { CreateEasySMSIntegrationSchema } from './EasySMSIntegrationForm.schema'; +import { useEasySMSIntegration } from './EasySMSIntegrationProvider'; import withDialogActions from 'containers/Dialog/withDialogActions'; import { compose } from 'utils'; @@ -23,13 +24,34 @@ function EasySMSIntegrationForm({ // #withDialogActions closeDialog, }) { + const { dialogName, easySMSIntegrateMutate } = useEasySMSIntegration(); + // Initial form values. const initialValues = { ...defaultInitialValues, }; // Handles the form submit. - const handleFormSubmit = (values, { setSubmitting, setErrors }) => {}; + const handleFormSubmit = (values, { setSubmitting, setErrors }) => { + // Handle request response success. + const onSuccess = (response) => { + AppToaster.show({ + message: intl.get('easysms.integrate.dialog.success_message'), + intent: Intent.SUCCESS, + }); + closeDialog(dialogName); + }; + // Handle request response errors. + const onError = ({ + response: { + data: { errors }, + }, + }) => { + setSubmitting(false); + }; + + easySMSIntegrateMutate(values).then(onSuccess).catch(onError); + }; return ( {({ form, field, meta: { error, touched } }) => ( } + label={} labelInfo={} intent={inputIntent({ error, touched })} helperText={} diff --git a/src/containers/Dialogs/EasySMSIntegrationDialog/EasySMSIntegrationProvider.js b/src/containers/Dialogs/EasySMSIntegrationDialog/EasySMSIntegrationProvider.js index 573980381..628f3b0bb 100644 --- a/src/containers/Dialogs/EasySMSIntegrationDialog/EasySMSIntegrationProvider.js +++ b/src/containers/Dialogs/EasySMSIntegrationDialog/EasySMSIntegrationProvider.js @@ -7,9 +7,13 @@ const EasySMSIntegrationDialogContext = React.createContext(); * Easy SMS integration dialog provider. */ function EasySMSIntegrationProvider({ dialogName, ...props }) { + // easysms integrate mutations. + const { mutateAsync: easySMSIntegrateMutate } = useSettingEasySMSIntegrate(); + // State provider. const provider = { dialogName, + easySMSIntegrateMutate, }; return ( diff --git a/src/lang/en/index.json b/src/lang/en/index.json index a34745b54..891d3aa21 100644 --- a/src/lang/en/index.json +++ b/src/lang/en/index.json @@ -1467,31 +1467,31 @@ "sms_notification.payment_details.type": "Payment receive thank you.", "sms_notification.receipt_details.type": "Sale receipt details", "personal": "Personal", - "list.create":"Create {value}", - "roles.label":"Roles", - "roles.column.name":"Name", - "roles.column.description":"Description", - "roles.edit_roles":"Edit Roles", - "roles.delete_roles":"Delete Roles", - "roles.label.role_name":"Role Name", - "roles.label.role_name_":"Role name", - "roles.error.role_is_predefined":"Role is predefined, you cannot delete predefined roles.", - "roles.error.you_cannot_change_your_own_role":"You cannot change your own role.", - "sidebar.transactions_locaking":"Transactions Locaking", - "transactions_locking.dialog.label":"Transactions locking", - "roles.permission_schema.success_message":"The role has been created successfully.", - "roles.permission_schema.upload_message":"The given role has been updated successfully.", - "roles.permission_schema.delete.alert_message":"The given role has been deleted successfully.", - "roles.permission_schema.once_delete_this_role_you_will_able_to_restore_it":"Once you delete this role, you won't be able to restore it later. Are you sure you want to delete this role?", - "users.column.role_name":"Role Name", - "roles.error.you_cannot_edit_predefined_roles":"You cannot edit predefined roles.", - "roles.error.you_cannot_delete_predefined_roles":"You cannot delete predefined roles.", - "roles.error.the_submit_role_has_invalid_permissions":"The submit role has invalid permissions.", - "roles.error.you_cannot_delete_role_that_associated_to_users":"You cannot delete role that associated to users", - "easysms.label.token":"Token", - "easysms.label.disconnect":"Disconnect", - "esaysms.label.connect":"Connect", - "easysms.label.edit_integration_settings":"Edit integration settings" - - + "list.create": "Create {value}", + "roles.label": "Roles", + "roles.column.name": "Name", + "roles.column.description": "Description", + "roles.edit_roles": "Edit Roles", + "roles.delete_roles": "Delete Roles", + "roles.label.role_name": "Role Name", + "roles.label.role_name_": "Role name", + "roles.error.role_is_predefined": "Role is predefined, you cannot delete predefined roles.", + "roles.error.you_cannot_change_your_own_role": "You cannot change your own role.", + "sidebar.transactions_locaking": "Transactions Locaking", + "transactions_locking.dialog.label": "Transactions locking", + "roles.permission_schema.success_message": "The role has been created successfully.", + "roles.permission_schema.upload_message": "The given role has been updated successfully.", + "roles.permission_schema.delete.alert_message": "The given role has been deleted successfully.", + "roles.permission_schema.once_delete_this_role_you_will_able_to_restore_it": "Once you delete this role, you won't be able to restore it later. Are you sure you want to delete this role?", + "users.column.role_name": "Role Name", + "roles.error.you_cannot_edit_predefined_roles": "You cannot edit predefined roles.", + "roles.error.you_cannot_delete_predefined_roles": "You cannot delete predefined roles.", + "roles.error.the_submit_role_has_invalid_permissions": "The submit role has invalid permissions.", + "roles.error.you_cannot_delete_role_that_associated_to_users": "You cannot delete role that associated to users", + "esaysms.label.connect": "Connect", + "easysms.label.disconnect": "Disconnect", + "easysms.label.edit_integration_settings": "Edit integration settings", + "easysms.disconnect.alert.success_message": "The sms gateway integration has been disconnected successfully.", + "easysms.integrate.dialog.label.token": "Token", + "easysms.integrate.dialog.success_message": "The system has been integrated with Easysms sms gateway successfully." } \ No newline at end of file