mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 21:30:31 +00:00
feat: add notify by sms .
This commit is contained in:
@@ -17,32 +17,36 @@ function NotifyReceiptViaSMSForm({
|
||||
// #withDialogActions
|
||||
closeDialog,
|
||||
}) {
|
||||
const { dialogName, receiptId } = useNotifyReceiptViaSMSContext();
|
||||
const {
|
||||
dialogName,
|
||||
receiptId,
|
||||
receiptSMSDetail,
|
||||
createNotifyReceiptBySMSMutate,
|
||||
} = useNotifyReceiptViaSMSContext();
|
||||
|
||||
// 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_receipt_via_sms.dialog.success_message'),
|
||||
intent: Intent.SUCCESS,
|
||||
});
|
||||
closeDialog(dialogName);
|
||||
};
|
||||
|
||||
// Handle request response errors.
|
||||
const onError = ({
|
||||
response: {
|
||||
data: { errors },
|
||||
},
|
||||
}) => {
|
||||
const onError = ({}) => {
|
||||
setSubmitting(false);
|
||||
};
|
||||
createNotifyReceiptBySMSMutate([receiptId, values])
|
||||
.then(onSuccess)
|
||||
.catch(onError);
|
||||
};
|
||||
|
||||
return (
|
||||
<NotifyViaSMSForm
|
||||
NotificationDetail={{}}
|
||||
NotificationDetail={receiptSMSDetail}
|
||||
NotificationName={dialogName}
|
||||
onSubmit={handleFormSubmit}
|
||||
/>
|
||||
|
||||
@@ -1,22 +1,29 @@
|
||||
import React from 'react';
|
||||
import { DialogContent } from 'components';
|
||||
// import { useCreateNotifyInvoiceBySMS, useInvocieSMSDetails } from 'hooks/query';
|
||||
import { useCreateNotifyReceiptBySMS, useReceiptSMSDetail } from 'hooks/query';
|
||||
|
||||
const NotifyReceiptViaSMSContext = React.createContext();
|
||||
|
||||
function NotifyReceiptViaSMSFormProvider({ receiptId, dialogName, ...props }) {
|
||||
// Create notfiy receipt via sms mutations.
|
||||
const { mutateAsync: createNotifyReceiptBySMSMutate } =
|
||||
useCreateNotifyReceiptBySMS();
|
||||
|
||||
const { data: receiptSMSDetail, isLoading: isReceiptSMSDetailLoading } =
|
||||
useReceiptSMSDetail(receiptId, {
|
||||
enabled: !!receiptId,
|
||||
});
|
||||
|
||||
// State provider.
|
||||
const provider = {
|
||||
receiptId,
|
||||
dialogName,
|
||||
receiptSMSDetail,
|
||||
createNotifyReceiptBySMSMutate,
|
||||
};
|
||||
|
||||
return (
|
||||
<DialogContent
|
||||
// isLoading={}
|
||||
>
|
||||
<DialogContent isLoading={isReceiptSMSDetailLoading}>
|
||||
<NotifyReceiptViaSMSContext.Provider value={provider} {...props} />
|
||||
</DialogContent>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user