-
-
Notifications
You must be signed in to change notification settings - Fork 319
Expand file tree
/
Copy pathFormView.web.jsx
More file actions
26 lines (23 loc) · 748 Bytes
/
FormView.web.jsx
File metadata and controls
26 lines (23 loc) · 748 Bytes
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
import React from 'react';
import PropTypes from 'prop-types';
import { onSubmit } from '../../../../utils/crud';
import generateFormik from '../../generateFormik';
const FormView = ({ schema, updateEntry, createEntry, title, data }) => {
const Formik = generateFormik(schema);
return (
<Formik
values={data ? data.node : null}
onSubmit={async values => {
await onSubmit({ schema, values, updateEntry, createEntry, title, data: data ? data.node : null });
}}
/>
);
};
FormView.propTypes = {
updateEntry: PropTypes.func.isRequired,
schema: PropTypes.object.isRequired,
createEntry: PropTypes.func.isRequired,
title: PropTypes.string.isRequired,
data: PropTypes.object
};
export default FormView;