|
|
@@ -0,0 +1,107 @@
|
|
|
+import { useFormik, Form, FormikProvider } from 'formik'; // import { useNavigate } from 'react-router-dom';
|
|
|
+import * as Yup from 'yup';
|
|
|
+
|
|
|
+import {
|
|
|
+ Stack, TextField,
|
|
|
+} from '@mui/material';
|
|
|
+
|
|
|
+export function PersonalInfo() {
|
|
|
+
|
|
|
+ // let navigate = useNavigate()
|
|
|
+
|
|
|
+ const RegisterSchema = Yup.object().shape({
|
|
|
+ nit: Yup.string().min(2, 'Demasiado corto!').max(50, 'Demasiado largo!').required('El nit es requerido'),
|
|
|
+ cui: Yup.string().min(2, 'Demasiado corto!').max(50, 'Demasiado Largo!').required('Tu CUI/DPI es requerido'),
|
|
|
+ direccion: Yup.string().min(2, 'Demasiado corto!').max(50, 'Demasiado Largo!').required('La direccion es requerida'),
|
|
|
+ nacimiento: Yup.date().required('Tu fecha nacimiento es requerida'),
|
|
|
+ telefono: Yup.number().required('Tu numero de telefono es requerido').oneOf([Yup.ref('password'), null], 'Las contraseñas no coincidien')
|
|
|
+ });
|
|
|
+
|
|
|
+ const formik = useFormik({
|
|
|
+
|
|
|
+ initialValues: {
|
|
|
+ nit: '',
|
|
|
+ cui: '',
|
|
|
+ direccion: '',
|
|
|
+ nacimiento: new Date(),
|
|
|
+ telefono: ''
|
|
|
+ },
|
|
|
+ validationSchema: RegisterSchema,
|
|
|
+ onSubmit: async (values) => {
|
|
|
+ // setOpen(true);
|
|
|
+ let body = {
|
|
|
+ "nit": "5345435",
|
|
|
+ "cui": "555555",
|
|
|
+ "direccion": "4 calle zona 1",
|
|
|
+ "fechacumple": "2021-01-01",
|
|
|
+ "telefono" : "45435345",
|
|
|
+ }
|
|
|
+ console.log(values,body)
|
|
|
+
|
|
|
+ // let url = 'http://204.48.25.93:8081/registro'
|
|
|
+ // let url = 'http://psicoadmin.ditca.org:8081/registro'
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ const { errors, touched, handleSubmit, getFieldProps } = formik;
|
|
|
+
|
|
|
+ return(
|
|
|
+ <FormikProvider style={{ padding : 15}} value={formik}>
|
|
|
+ <Form autoComplete="off" noValidate onSubmit={handleSubmit}>
|
|
|
+ <Stack spacing={3}>
|
|
|
+ <Stack direction={{ xs: 'column', sm: 'row' }} spacing={2}>
|
|
|
+ <TextField
|
|
|
+ label="Numero de Nit"
|
|
|
+ fullWidth
|
|
|
+ {...getFieldProps('nit')}
|
|
|
+ error={Boolean(touched.nit && errors.nit)}
|
|
|
+ helperText={touched.nit && errors.nit}
|
|
|
+ />
|
|
|
+
|
|
|
+ <TextField
|
|
|
+ label="CUI/DPI"
|
|
|
+ fullWidth
|
|
|
+ {...getFieldProps('cui')}
|
|
|
+ error={Boolean(touched.cui && errors.cui)}
|
|
|
+ helperText={touched.cui && errors.cui}
|
|
|
+ />
|
|
|
+ </Stack>
|
|
|
+
|
|
|
+ <TextField
|
|
|
+ fullWidth
|
|
|
+ type="text"
|
|
|
+ label="Dirección"
|
|
|
+ {...getFieldProps('direccion')}
|
|
|
+ error={Boolean(touched.direccion && errors.direccion)}
|
|
|
+ helperText={touched.direccion && errors.direccion}
|
|
|
+ />
|
|
|
+
|
|
|
+ <Stack direction={{ xs: 'column', sm: 'row' }} spacing={2}>
|
|
|
+ <TextField
|
|
|
+ type="date"
|
|
|
+ label="Fecha de nacimiento"
|
|
|
+ fullWidth
|
|
|
+ defaultValue={'2021-01-10'}
|
|
|
+ InputLabelProps={{ shrink: true, required: true }}
|
|
|
+ {...getFieldProps('nacimiento')}
|
|
|
+ error={Boolean(touched.nacimiento && errors.nacimiento)}
|
|
|
+ helperText={touched.nacimiento && errors.nacimiento}
|
|
|
+ />
|
|
|
+
|
|
|
+ <TextField
|
|
|
+ label="Telefono"
|
|
|
+ fullWidth
|
|
|
+ {...getFieldProps('telefono')}
|
|
|
+ error={Boolean(touched.telefono && errors.telefono)}
|
|
|
+ helperText={touched.telefono && errors.telefono}
|
|
|
+ />
|
|
|
+ </Stack>
|
|
|
+
|
|
|
+
|
|
|
+ </Stack>
|
|
|
+ </Form>
|
|
|
+ </FormikProvider>
|
|
|
+ )
|
|
|
+}
|