feat: add notify by sms .

This commit is contained in:
elforjani13
2021-11-07 20:11:15 +02:00
parent 7706d2992c
commit 4d89f1e0e0
17 changed files with 141 additions and 75 deletions

View File

@@ -1,6 +1,9 @@
import React from 'react';
import { DialogContent } from 'components';
// import { useCreateNotifyInvoiceBySMS, useInvocieSMSDetails } from 'hooks/query';
import {
useCreateNotifyPaymentReceiveBySMS,
usePaymentReceiveSMSDetail,
} from 'hooks/query';
const NotifyPaymentReceiveViaSMSContext = React.createContext();
@@ -9,16 +12,27 @@ function NotifyPaymentReceiveViaFormProvider({
dialogName,
...props
}) {
// Create notfiy receipt via sms mutations.
const { mutateAsync: createNotifyPaymentReceivetBySMSMutate } =
useCreateNotifyPaymentReceiveBySMS();
const {
data: paymentReceiveMSDetail,
isLoading: isPaymentReceiveSMSDetailLoading,
} = usePaymentReceiveSMSDetail(paymentReceiveId, {
enabled: !!paymentReceiveId,
});
// State provider.
const provider = {
paymentReceiveId,
dialogName,
paymentReceiveMSDetail,
createNotifyPaymentReceivetBySMSMutate,
};
return (
<DialogContent
// isLoading={}
>
<DialogContent isLoading={isPaymentReceiveSMSDetailLoading}>
<NotifyPaymentReceiveViaSMSContext.Provider value={provider} {...props} />
</DialogContent>
);

View File

@@ -17,33 +17,38 @@ function NotifyPaymentReceiveViaSMSForm({
// #withDialogActions
closeDialog,
}) {
const { dialogName, paymentReceiveId } =
useNotifyPaymentReceiveViaSMSContext();
const {
dialogName,
paymentReceiveId,
paymentReceiveMSDetail,
createNotifyPaymentReceivetBySMSMutate,
} = useNotifyPaymentReceiveViaSMSContext();
// 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_payment_receive_via_sms.dialog.success_message',
),
intent: Intent.SUCCESS,
});
closeDialog(dialogName);
};
// Handle request response errors.
const onError = ({
response: {
data: { errors },
},
}) => {
const onError = ({}) => {
setSubmitting(false);
};
createNotifyPaymentReceivetBySMSMutate([paymentReceiveId, values])
.then(onSuccess)
.catch(onError);
};
return (
<NotifyViaSMSForm
NotificationDetail={{}}
NotificationDetail={paymentReceiveMSDetail}
NotificationName={dialogName}
onSubmit={handleFormSubmit}
/>

View File

@@ -25,7 +25,7 @@ function NotifyPaymentReciveViaSMSDialog({
<DialogSuspense>
<NotifyPaymentReceiveViaSMSDialogContent
dialogName={dialogName}
paymnetReceive={paymentReceiveId}
paymentReceive={paymentReceiveId}
/>
</DialogSuspense>
</Dialog>