mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-21 07:10:33 +00:00
feat: add easysms integrate api.
This commit is contained in:
@@ -4,6 +4,8 @@ import { FormattedMessage as T, FormattedHTMLMessage } from 'components';
|
|||||||
import { Intent, Alert } from '@blueprintjs/core';
|
import { Intent, Alert } from '@blueprintjs/core';
|
||||||
import { AppToaster } from 'components';
|
import { AppToaster } from 'components';
|
||||||
|
|
||||||
|
import { useSettingEasySMSDisconnect } from 'hooks/query';
|
||||||
|
|
||||||
import withAlertStoreConnect from 'containers/Alert/withAlertStoreConnect';
|
import withAlertStoreConnect from 'containers/Alert/withAlertStoreConnect';
|
||||||
import withAlertActions from 'containers/Alert/withAlertActions';
|
import withAlertActions from 'containers/Alert/withAlertActions';
|
||||||
|
|
||||||
@@ -22,13 +24,28 @@ function EasySMSDisconnectAlert({
|
|||||||
// #withAlertActions
|
// #withAlertActions
|
||||||
closeAlert,
|
closeAlert,
|
||||||
}) {
|
}) {
|
||||||
|
const { mutateAsync: disconnectEasySMS, isLoading } =
|
||||||
|
useSettingEasySMSDisconnect();
|
||||||
|
|
||||||
// Handle cancel Disconnect alert.
|
// Handle cancel Disconnect alert.
|
||||||
const handleCancelDisconnect = () => {
|
const handleCancelDisconnect = () => {
|
||||||
closeAlert(name);
|
closeAlert(name);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handle confirm Disconnect alert.
|
// 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 (
|
return (
|
||||||
<Alert
|
<Alert
|
||||||
@@ -38,6 +55,7 @@ function EasySMSDisconnectAlert({
|
|||||||
isOpen={isOpen}
|
isOpen={isOpen}
|
||||||
onCancel={handleCancelDisconnect}
|
onCancel={handleCancelDisconnect}
|
||||||
onConfirm={handleConfirmDisconnect}
|
onConfirm={handleConfirmDisconnect}
|
||||||
|
loading={isLoading}
|
||||||
>
|
>
|
||||||
<p>Ea aliqua elit reprehenderit pariatur consequat voluptate quis.</p>
|
<p>Ea aliqua elit reprehenderit pariatur consequat voluptate quis.</p>
|
||||||
</Alert>
|
</Alert>
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import '../../../style/pages/EasySMSIntegration/EasySMSIntegration.scss';
|
|||||||
import { AppToaster } from 'components';
|
import { AppToaster } from 'components';
|
||||||
import EasySMSIntegrationFormContent from './EasySMSIntegrationFormContent';
|
import EasySMSIntegrationFormContent from './EasySMSIntegrationFormContent';
|
||||||
import { CreateEasySMSIntegrationSchema } from './EasySMSIntegrationForm.schema';
|
import { CreateEasySMSIntegrationSchema } from './EasySMSIntegrationForm.schema';
|
||||||
|
import { useEasySMSIntegration } from './EasySMSIntegrationProvider';
|
||||||
|
|
||||||
import withDialogActions from 'containers/Dialog/withDialogActions';
|
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||||
import { compose } from 'utils';
|
import { compose } from 'utils';
|
||||||
@@ -23,13 +24,34 @@ function EasySMSIntegrationForm({
|
|||||||
// #withDialogActions
|
// #withDialogActions
|
||||||
closeDialog,
|
closeDialog,
|
||||||
}) {
|
}) {
|
||||||
|
const { dialogName, easySMSIntegrateMutate } = useEasySMSIntegration();
|
||||||
|
|
||||||
// Initial form values.
|
// Initial form values.
|
||||||
const initialValues = {
|
const initialValues = {
|
||||||
...defaultInitialValues,
|
...defaultInitialValues,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handles the form submit.
|
// 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 (
|
return (
|
||||||
<Formik
|
<Formik
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ function EasySMSIntegrationFormContent({
|
|||||||
<FastField name={'token'}>
|
<FastField name={'token'}>
|
||||||
{({ form, field, meta: { error, touched } }) => (
|
{({ form, field, meta: { error, touched } }) => (
|
||||||
<FormGroup
|
<FormGroup
|
||||||
label={<T id={'easysms.label.token'} />}
|
label={<T id={'easysms.integrate.dialog.label.token'} />}
|
||||||
labelInfo={<FieldRequiredHint />}
|
labelInfo={<FieldRequiredHint />}
|
||||||
intent={inputIntent({ error, touched })}
|
intent={inputIntent({ error, touched })}
|
||||||
helperText={<ErrorMessage name="token" />}
|
helperText={<ErrorMessage name="token" />}
|
||||||
|
|||||||
@@ -7,9 +7,13 @@ const EasySMSIntegrationDialogContext = React.createContext();
|
|||||||
* Easy SMS integration dialog provider.
|
* Easy SMS integration dialog provider.
|
||||||
*/
|
*/
|
||||||
function EasySMSIntegrationProvider({ dialogName, ...props }) {
|
function EasySMSIntegrationProvider({ dialogName, ...props }) {
|
||||||
|
// easysms integrate mutations.
|
||||||
|
const { mutateAsync: easySMSIntegrateMutate } = useSettingEasySMSIntegrate();
|
||||||
|
|
||||||
// State provider.
|
// State provider.
|
||||||
const provider = {
|
const provider = {
|
||||||
dialogName,
|
dialogName,
|
||||||
|
easySMSIntegrateMutate,
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1488,10 +1488,10 @@
|
|||||||
"roles.error.you_cannot_delete_predefined_roles": "You cannot delete 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.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",
|
"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",
|
"esaysms.label.connect": "Connect",
|
||||||
"easysms.label.edit_integration_settings":"Edit integration settings"
|
"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."
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user