feat: add easysms integrate api.

This commit is contained in:
elforjani13
2021-12-01 19:24:02 +02:00
parent a99fc78fe1
commit 43c3f5e3de
5 changed files with 74 additions and 30 deletions

View File

@@ -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 (
<Alert
@@ -38,6 +55,7 @@ function EasySMSDisconnectAlert({
isOpen={isOpen}
onCancel={handleCancelDisconnect}
onConfirm={handleConfirmDisconnect}
loading={isLoading}
>
<p>Ea aliqua elit reprehenderit pariatur consequat voluptate quis.</p>
</Alert>

View File

@@ -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 (
<Formik

View File

@@ -31,7 +31,7 @@ function EasySMSIntegrationFormContent({
<FastField name={'token'}>
{({ form, field, meta: { error, touched } }) => (
<FormGroup
label={<T id={'easysms.label.token'} />}
label={<T id={'easysms.integrate.dialog.label.token'} />}
labelInfo={<FieldRequiredHint />}
intent={inputIntent({ error, touched })}
helperText={<ErrorMessage name="token" />}

View File

@@ -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 (

View File

@@ -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."
}