mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 13:20:31 +00:00
feat: add notify by sms .
This commit is contained in:
@@ -14,32 +14,36 @@ function NotifyEstimateViaSMSForm({
|
||||
// #withDialogActions
|
||||
closeDialog,
|
||||
}) {
|
||||
const { dialogName, estimateId } = useEstimateViaSMSContext();
|
||||
const {
|
||||
estimateId,
|
||||
dialogName,
|
||||
estimateSMSDetail,
|
||||
createNotifyEstimateBySMSMutate,
|
||||
} = useEstimateViaSMSContext();
|
||||
|
||||
// Handles the form submit.
|
||||
const handleFormSubmit = (values, { setSubmitting, setErrors }) => {
|
||||
// Handle request response success.
|
||||
const onSuccess = (response) => {
|
||||
AppToaster.show({
|
||||
message: intl.get('notify_via_sms.dialog.success_message'),
|
||||
message: intl.get('notify_estimate_via_sms.dialog.success_message'),
|
||||
intent: Intent.SUCCESS,
|
||||
});
|
||||
closeDialog(dialogName);
|
||||
};
|
||||
|
||||
// Handle request response errors.
|
||||
const onError = ({
|
||||
response: {
|
||||
data: { errors },
|
||||
},
|
||||
}) => {
|
||||
const onError = () => {
|
||||
setSubmitting(false);
|
||||
};
|
||||
createNotifyEstimateBySMSMutate([estimateId, values])
|
||||
.then(onSuccess)
|
||||
.then(onError);
|
||||
};
|
||||
|
||||
return (
|
||||
<NotifyViaSMSForm
|
||||
NotificationDetail={{}}
|
||||
NotificationDetail={estimateSMSDetail}
|
||||
NotificationName={dialogName}
|
||||
onSubmit={handleFormSubmit}
|
||||
/>
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import React from 'react';
|
||||
import { DialogContent } from 'components';
|
||||
// import { } from 'hooks/query';
|
||||
import {
|
||||
useEstimateSMSDetail,
|
||||
useCreateNotifyEstimateBySMS,
|
||||
} from 'hooks/query';
|
||||
|
||||
const NotifyEstimateViaSMSContext = React.createContext();
|
||||
|
||||
@@ -9,16 +12,25 @@ function NotifyEstimateViaSMSFormProvider({
|
||||
dialogName,
|
||||
...props
|
||||
}) {
|
||||
const { data: estimateSMSDetail, isLoading: isEstimateSMSDetailLoading } =
|
||||
useEstimateSMSDetail(estimateId, {
|
||||
enabled: !!estimateId,
|
||||
});
|
||||
|
||||
// Create notfiy estimate by sms mutations.
|
||||
const { mutateAsync: createNotifyEstimateBySMSMutate } =
|
||||
useCreateNotifyEstimateBySMS();
|
||||
|
||||
// State provider.
|
||||
const provider = {
|
||||
estimateId,
|
||||
dialogName,
|
||||
estimateSMSDetail,
|
||||
createNotifyEstimateBySMSMutate,
|
||||
};
|
||||
|
||||
return (
|
||||
<DialogContent
|
||||
// isLoading={}
|
||||
>
|
||||
<DialogContent isLoading={isEstimateSMSDetailLoading}>
|
||||
<NotifyEstimateViaSMSContext.Provider value={provider} {...props} />
|
||||
</DialogContent>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user