UNPKG

test-crud

Version:

es una prueba acerca de como publicar un package name

79 lines (76 loc) 1.93 kB
import { Formik } from 'formik' import Paper from '@mui/material/Paper' import Loading from '../feedback/loading' import ErrorMessage from '../feedback/errorMessage' const AppForm = ({ initialValues, onSubmit, validationSchema, loading = false, error = null, modal = false, className = '', style = {}, formikRef = null, children, }) => { return ( <Formik initialValues={initialValues} onSubmit={onSubmit} validationSchema={validationSchema} enableReinitialize={true} innerRef={formikRef && formikRef} > {({ values, errors, touched, resetForm, handleChange, setFieldValue, setTouched, isSubmitting, }) => { return modal ? ( <> <Loading visible={loading} /> <ErrorMessage error={error} /> <div style={style} className={className ? className : 'modal'}> {typeof children === 'function' ? children({ values, errors, touched, resetForm, handleChange, setFieldValue, }) : children} </div> </> ) : ( <> <Loading visible={loading} /> <ErrorMessage error={error} /> <Paper elevation={3}> <div style={style} className="form"> {typeof children === 'function' ? children({ values, errors, touched, resetForm, handleChange, setFieldValue, }) : children} </div> </Paper> </> ) }} </Formik> ) } export default AppForm