mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 04:40:32 +00:00
feat: SMS notification module.
This commit is contained in:
@@ -11,6 +11,11 @@ import { transformErrors } from '../../../containers/NotifyViaSMS/utils';
|
||||
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||
import { compose } from 'utils';
|
||||
|
||||
const notificationType = {
|
||||
key: 'sale-estimate-details',
|
||||
label: 'Sale estimate details',
|
||||
};
|
||||
|
||||
function NotifyEstimateViaSMSForm({
|
||||
// #withDialogActions
|
||||
closeDialog,
|
||||
@@ -51,10 +56,19 @@ function NotifyEstimateViaSMSForm({
|
||||
.catch(onError);
|
||||
};
|
||||
|
||||
const initialValues = {
|
||||
...estimateSMSDetail,
|
||||
};
|
||||
// Handle the form cancel.
|
||||
const handleFormCancel = () => {
|
||||
closeDialog(dialogName);
|
||||
};
|
||||
|
||||
return (
|
||||
<NotifyViaSMSForm
|
||||
NotificationDetail={estimateSMSDetail}
|
||||
NotificationName={dialogName}
|
||||
initialValues={initialValues}
|
||||
notificationTypes={notificationType}
|
||||
onCancel={handleFormCancel}
|
||||
onSubmit={handleFormSubmit}
|
||||
/>
|
||||
);
|
||||
|
||||
@@ -80,10 +80,19 @@ function NotifyInvoiceViaSMSForm({
|
||||
setNotificationType(values.notification_key);
|
||||
}
|
||||
};
|
||||
// Momerize the notification types.
|
||||
const notificationTypes = React.useMemo(
|
||||
() => [
|
||||
{ key: 'details', label: 'Invoice details' },
|
||||
{ key: 'reminder', label: 'Invoice reminder' },
|
||||
],
|
||||
[],
|
||||
);
|
||||
|
||||
return (
|
||||
<NotifyViaSMSForm
|
||||
initialValues={initialValues}
|
||||
notificationTypes={notificationTypes}
|
||||
onSubmit={handleFormSubmit}
|
||||
onCancel={handleFormCancel}
|
||||
onValuesChange={handleValuesChange}
|
||||
|
||||
@@ -11,6 +11,11 @@ import { transformErrors } from '../../../containers/NotifyViaSMS/utils';
|
||||
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||
import { compose } from 'utils';
|
||||
|
||||
const notificationType = {
|
||||
key: 'payment-receive-details',
|
||||
label: 'Payment receive thank you.',
|
||||
};
|
||||
|
||||
/**
|
||||
* Notify Payment Recive Via SMS Form.
|
||||
*/
|
||||
@@ -53,12 +58,23 @@ function NotifyPaymentReceiveViaSMSForm({
|
||||
.then(onSuccess)
|
||||
.catch(onError);
|
||||
};
|
||||
// Handle the form cancel.
|
||||
const handleFormCancel = () => {
|
||||
closeDialog(dialogName);
|
||||
};
|
||||
|
||||
// Form initial values.
|
||||
const initialValues = React.useMemo(
|
||||
() => ({ ...paymentReceiveMSDetail }),
|
||||
[paymentReceiveMSDetail],
|
||||
);
|
||||
|
||||
return (
|
||||
<NotifyViaSMSForm
|
||||
NotificationDetail={paymentReceiveMSDetail}
|
||||
NotificationName={dialogName}
|
||||
initialValues={initialValues}
|
||||
notificationTypes={notificationType}
|
||||
onSubmit={handleFormSubmit}
|
||||
onCancel={handleFormCancel}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -11,6 +11,11 @@ import { transformErrors } from '../../../containers/NotifyViaSMS/utils';
|
||||
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||
import { compose } from 'utils';
|
||||
|
||||
const notificationType = {
|
||||
key: 'sale-receipt-details',
|
||||
label: 'Sale receipt details',
|
||||
};
|
||||
|
||||
/**
|
||||
* Notify Receipt Via SMS Form.
|
||||
*/
|
||||
@@ -51,12 +56,24 @@ function NotifyReceiptViaSMSForm({
|
||||
.then(onSuccess)
|
||||
.catch(onError);
|
||||
};
|
||||
// Handle the form cancel.
|
||||
const handleFormCancel = () => {
|
||||
closeDialog(dialogName);
|
||||
};
|
||||
// Initial values.
|
||||
const initialValues = React.useMemo(
|
||||
() => ({
|
||||
...receiptSMSDetail,
|
||||
}),
|
||||
[receiptSMSDetail],
|
||||
);
|
||||
|
||||
return (
|
||||
<NotifyViaSMSForm
|
||||
NotificationDetail={receiptSMSDetail}
|
||||
NotificationName={dialogName}
|
||||
initialValues={initialValues}
|
||||
notificationTypes={notificationType}
|
||||
onSubmit={handleFormSubmit}
|
||||
onCancel={handleFormCancel}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -4,11 +4,15 @@ import { useCreateNotifyReceiptBySMS, useReceiptSMSDetail } from 'hooks/query';
|
||||
|
||||
const NotifyReceiptViaSMSContext = React.createContext();
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function NotifyReceiptViaSMSFormProvider({ receiptId, dialogName, ...props }) {
|
||||
// Create notfiy receipt via sms mutations.
|
||||
// Create notfiy receipt via SMS mutations.
|
||||
const { mutateAsync: createNotifyReceiptBySMSMutate } =
|
||||
useCreateNotifyReceiptBySMS();
|
||||
|
||||
// Retrieve the receipt SMS notification details.
|
||||
const { data: receiptSMSDetail, isLoading: isReceiptSMSDetailLoading } =
|
||||
useReceiptSMSDetail(receiptId, {
|
||||
enabled: !!receiptId,
|
||||
|
||||
Reference in New Issue
Block a user