-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExportTemplateDialog.jsx
More file actions
43 lines (39 loc) · 1.55 KB
/
ExportTemplateDialog.jsx
File metadata and controls
43 lines (39 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import Dialog from '@material-ui/core/Dialog';
import DialogTitle from '@material-ui/core/DialogTitle';
import { compose } from 'redux';
import * as formActions from '../../formactions/exporttemplate';
import withUI from '../../hoc/withUI';
import DialogContent from '../ui/DialogContent';
import WizardForm from '../ui/WizardForm';
import ExportTemplateForm from './ExportTemplateForm';
function ExportTemplateDialog({ templateName, open, onClose, onSuccess, openSnackBar, onFail }) {
const onSubmitSuccess = (response, dispatch, props) => {
const { locationName } = response;
const messageContent = `Export Location ${locationName} Created`;
openSnackBar({ messageContent });
onClose();
if (onSuccess) onSuccess(response, dispatch, props);
};
const onSubmitFail = (error, dispatch, props) => {
const messageContent = 'Error Creating Export Template';
openSnackBar({ messageContent, messageColor: 'secondary' });
if (onFail) onSuccess(error, dispatch, props);
};
return (
<Dialog open={open} onClose={onClose} fullWidth maxWidth={false}>
<DialogTitle>New Export Template</DialogTitle>
<DialogContent>
<WizardForm
FormComponent={ExportTemplateForm}
documentName="exportLocationDocument"
onSubmit={formActions.onUpdateExportTemplate}
onSubmitSuccess={onSubmitSuccess}
onSubmitFail={onSubmitFail}
onCancel={onClose}
templateName={templateName}
/>
</DialogContent>
</Dialog>
);
}
export default compose(withUI)(ExportTemplateDialog);