This repository was archived by the owner on Feb 27, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +6
-8
lines changed
components/molecules/Form Expand file tree Collapse file tree 1 file changed +6
-8
lines changed Original file line number Diff line number Diff line change @@ -13,25 +13,22 @@ import cn from 'classnames'
13
13
* @param {object } props.formDefaults Formik default data.
14
14
* @param {string|number } props.id Form id.
15
15
* @param {object } props.validationSchema Yup validation schema object.
16
+ * @param {function } props.onSubmit Function to execute when form is submitted
16
17
* @return {Element } The Form component.
17
18
*/
18
19
export default function Form ( {
19
20
children,
20
21
className,
21
22
formDefaults,
22
23
id,
23
- validationSchema
24
+ validationSchema,
25
+ onSubmit
24
26
} ) {
25
27
return (
26
28
< Formik
27
29
initialValues = { formDefaults }
28
30
validationSchema = { validationSchema }
29
- onSubmit = { ( values , { setSubmitting} ) => {
30
- setTimeout ( ( ) => {
31
- alert ( JSON . stringify ( values , null , 2 ) )
32
- setSubmitting ( false )
33
- } , 400 )
34
- } }
31
+ onSubmit = { onSubmit }
35
32
>
36
33
< FormikForm id = { id } className = { cn ( styles . form , className ) } >
37
34
{ children }
@@ -46,7 +43,8 @@ Form.propTypes = {
46
43
className : PropTypes . string ,
47
44
formDefaults : PropTypes . object ,
48
45
id : PropTypes . string ,
49
- validationSchema : PropTypes . object
46
+ validationSchema : PropTypes . object ,
47
+ onSubmit : PropTypes . function
50
48
}
51
49
52
50
Form . defaultProps = {
You can’t perform that action at this time.
0 commit comments