mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 13:20:31 +00:00
feat: add notify via SMS Form.
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
import React from 'react';
|
||||
import { NotifyEstimateViaSMSFormProvider } from './NotifyEstimateViaSMSFormProvider';
|
||||
import NotifyEstimateViaSMSForm from './NotifyEstimateViaSMSForm';
|
||||
|
||||
export default function NotifyEstimateViaSMSDialogContent({
|
||||
// #ownProps
|
||||
dialogName,
|
||||
estimate,
|
||||
}) {
|
||||
return (
|
||||
<NotifyEstimateViaSMSFormProvider
|
||||
estimateId={estimate}
|
||||
dialogName={dialogName}
|
||||
>
|
||||
<NotifyEstimateViaSMSForm />
|
||||
</NotifyEstimateViaSMSFormProvider>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
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 { useEstimateViaSMSContext } from './NotifyEstimateViaSMSFormProvider';
|
||||
|
||||
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||
import { compose } from 'utils';
|
||||
|
||||
function NotifyEstimateViaSMSForm({
|
||||
// #withDialogActions
|
||||
closeDialog,
|
||||
}) {
|
||||
const { dialogName, estimateId } = 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'),
|
||||
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)(NotifyEstimateViaSMSForm);
|
||||
@@ -0,0 +1,30 @@
|
||||
import React from 'react';
|
||||
import { DialogContent } from 'components';
|
||||
// import { } from 'hooks/query';
|
||||
|
||||
const NotifyEstimateViaSMSContext = React.createContext();
|
||||
|
||||
function NotifyEstimateViaSMSFormProvider({
|
||||
estimateId,
|
||||
dialogName,
|
||||
...props
|
||||
}) {
|
||||
// State provider.
|
||||
const provider = {
|
||||
estimateId,
|
||||
dialogName,
|
||||
};
|
||||
|
||||
return (
|
||||
<DialogContent
|
||||
// isLoading={}
|
||||
>
|
||||
<NotifyEstimateViaSMSContext.Provider value={provider} {...props} />
|
||||
</DialogContent>
|
||||
);
|
||||
}
|
||||
|
||||
const useEstimateViaSMSContext = () =>
|
||||
React.useContext(NotifyEstimateViaSMSContext);
|
||||
|
||||
export { NotifyEstimateViaSMSFormProvider, useEstimateViaSMSContext };
|
||||
36
src/containers/Dialogs/NotifyEstimateViaSMSDialog/index.js
Normal file
36
src/containers/Dialogs/NotifyEstimateViaSMSDialog/index.js
Normal file
@@ -0,0 +1,36 @@
|
||||
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 NotifyEstimateViaSMSDialogContent = React.lazy(() =>
|
||||
import('./NotifyEstimateViaSMSDialogContent'),
|
||||
);
|
||||
|
||||
function NotifyEstimateViaSMSDialog({
|
||||
dialogName,
|
||||
payload: { estimateId },
|
||||
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>
|
||||
<NotifyEstimateViaSMSDialogContent
|
||||
dialogName={dialogName}
|
||||
estimate={estimateId}
|
||||
/>
|
||||
</DialogSuspense>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
||||
export default compose(withDialogRedux())(NotifyEstimateViaSMSDialog);
|
||||
Reference in New Issue
Block a user