mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 05:10:31 +00:00
feat: add notify via SMS Form.
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
import React from 'react';
|
||||
import { DialogContent } from 'components';
|
||||
// import { useCreateNotifyInvoiceBySMS, useInvocieSMSDetails } from 'hooks/query';
|
||||
|
||||
const NotifyPaymentReceiveViaSMSContext = React.createContext();
|
||||
|
||||
function NotifyPaymentReceiveViaFormProvider({
|
||||
paymentReceiveId,
|
||||
dialogName,
|
||||
...props
|
||||
}) {
|
||||
// State provider.
|
||||
const provider = {
|
||||
paymentReceiveId,
|
||||
dialogName,
|
||||
};
|
||||
|
||||
return (
|
||||
<DialogContent
|
||||
// isLoading={}
|
||||
>
|
||||
<NotifyPaymentReceiveViaSMSContext.Provider value={provider} {...props} />
|
||||
</DialogContent>
|
||||
);
|
||||
}
|
||||
|
||||
const useNotifyPaymentReceiveViaSMSContext = () =>
|
||||
React.useContext(NotifyPaymentReceiveViaSMSContext);
|
||||
|
||||
export {
|
||||
NotifyPaymentReceiveViaFormProvider,
|
||||
useNotifyPaymentReceiveViaSMSContext,
|
||||
};
|
||||
@@ -0,0 +1,19 @@
|
||||
import React from 'react';
|
||||
|
||||
import { NotifyPaymentReceiveViaFormProvider } from './NotifyPaymentReceiveViaFormProvider';
|
||||
import NotifyPaymentReceiveViaSMSForm from './NotifyPaymentReceiveViaSMSForm';
|
||||
|
||||
export default function NotifyPaymentReceiveViaSMSContent({
|
||||
// #ownProps
|
||||
dialogName,
|
||||
paymentReceive,
|
||||
}) {
|
||||
return (
|
||||
<NotifyPaymentReceiveViaFormProvider
|
||||
paymentReceiveId={paymentReceive}
|
||||
dialogName={dialogName}
|
||||
>
|
||||
<NotifyPaymentReceiveViaSMSForm />
|
||||
</NotifyPaymentReceiveViaFormProvider>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
import React from 'react';
|
||||
import intl from 'react-intl-universal';
|
||||
|
||||
import { Intent } from '@blueprintjs/core';
|
||||
import { AppToaster } from 'components';
|
||||
|
||||
import NotifyViaSMSForm from '../../NotifyViaSMS/NotifyViaSMSForm';
|
||||
import { useNotifyPaymentReceiveViaSMSContext } from './NotifyPaymentReceiveViaFormProvider';
|
||||
|
||||
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||
import { compose } from 'utils';
|
||||
|
||||
/**
|
||||
* Notify Payment Recive Via SMS Form.
|
||||
*/
|
||||
function NotifyPaymentReceiveViaSMSForm({
|
||||
// #withDialogActions
|
||||
closeDialog,
|
||||
}) {
|
||||
const { dialogName, paymentReceiveId } =
|
||||
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'),
|
||||
intent: Intent.SUCCESS,
|
||||
});
|
||||
closeDialog(dialogName);
|
||||
};
|
||||
|
||||
// Handle request response errors.
|
||||
const onError = ({
|
||||
response: {
|
||||
data: { errors },
|
||||
},
|
||||
}) => {
|
||||
setSubmitting(false);
|
||||
};
|
||||
};
|
||||
|
||||
return (
|
||||
<NotifyViaSMSForm
|
||||
NotificationDetail={{}}
|
||||
NotificationName={dialogName}
|
||||
onSubmit={handleFormSubmit}
|
||||
/>
|
||||
);
|
||||
}
|
||||
export default compose(withDialogActions)(NotifyPaymentReceiveViaSMSForm);
|
||||
@@ -0,0 +1,34 @@
|
||||
import React from 'react';
|
||||
import { FormattedMessage as T } from 'components';
|
||||
import { Dialog, DialogSuspense } from 'components';
|
||||
import withDialogRedux from 'components/DialogReduxConnect';
|
||||
import { compose } from 'utils';
|
||||
|
||||
const NotifyPaymentReceiveViaSMSDialogContent = React.lazy(() =>
|
||||
import('./NotifyPaymentReceiveViaSMSContent'),
|
||||
);
|
||||
|
||||
function NotifyPaymentReciveViaSMSDialog({
|
||||
dialogName,
|
||||
payload: { paymentReceiveId },
|
||||
isOpen,
|
||||
}) {
|
||||
return (
|
||||
<Dialog
|
||||
name={dialogName}
|
||||
title={<T id={'notify_via_sms.dialog.notify_via_sms'} />}
|
||||
isOpen={isOpen}
|
||||
canEscapeJeyClose={true}
|
||||
autoFocus={true}
|
||||
className={'dialog--notify-vis-sms'}
|
||||
>
|
||||
<DialogSuspense>
|
||||
<NotifyPaymentReceiveViaSMSDialogContent
|
||||
dialogName={dialogName}
|
||||
paymnetReceive={paymentReceiveId}
|
||||
/>
|
||||
</DialogSuspense>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
export default compose(withDialogRedux())(NotifyPaymentReciveViaSMSDialog);
|
||||
Reference in New Issue
Block a user