|
@@ -0,0 +1,107 @@
|
|
1
|
+import { useFormik, Form, FormikProvider } from 'formik'; // import { useNavigate } from 'react-router-dom';
|
|
2
|
+import * as Yup from 'yup';
|
|
3
|
+
|
|
4
|
+import {
|
|
5
|
+ Stack, TextField,
|
|
6
|
+} from '@mui/material';
|
|
7
|
+
|
|
8
|
+export function PersonalInfo() {
|
|
9
|
+
|
|
10
|
+ // let navigate = useNavigate()
|
|
11
|
+
|
|
12
|
+ const RegisterSchema = Yup.object().shape({
|
|
13
|
+ nit: Yup.string().min(2, 'Demasiado corto!').max(50, 'Demasiado largo!').required('El nit es requerido'),
|
|
14
|
+ cui: Yup.string().min(2, 'Demasiado corto!').max(50, 'Demasiado Largo!').required('Tu CUI/DPI es requerido'),
|
|
15
|
+ direccion: Yup.string().min(2, 'Demasiado corto!').max(50, 'Demasiado Largo!').required('La direccion es requerida'),
|
|
16
|
+ nacimiento: Yup.date().required('Tu fecha nacimiento es requerida'),
|
|
17
|
+ telefono: Yup.number().required('Tu numero de telefono es requerido').oneOf([Yup.ref('password'), null], 'Las contraseñas no coincidien')
|
|
18
|
+ });
|
|
19
|
+
|
|
20
|
+ const formik = useFormik({
|
|
21
|
+
|
|
22
|
+ initialValues: {
|
|
23
|
+ nit: '',
|
|
24
|
+ cui: '',
|
|
25
|
+ direccion: '',
|
|
26
|
+ nacimiento: new Date(),
|
|
27
|
+ telefono: ''
|
|
28
|
+ },
|
|
29
|
+ validationSchema: RegisterSchema,
|
|
30
|
+ onSubmit: async (values) => {
|
|
31
|
+ // setOpen(true);
|
|
32
|
+ let body = {
|
|
33
|
+ "nit": "5345435",
|
|
34
|
+ "cui": "555555",
|
|
35
|
+ "direccion": "4 calle zona 1",
|
|
36
|
+ "fechacumple": "2021-01-01",
|
|
37
|
+ "telefono" : "45435345",
|
|
38
|
+ }
|
|
39
|
+ console.log(values,body)
|
|
40
|
+
|
|
41
|
+ // let url = 'http://204.48.25.93:8081/registro'
|
|
42
|
+ // let url = 'http://psicoadmin.ditca.org:8081/registro'
|
|
43
|
+ }
|
|
44
|
+
|
|
45
|
+ });
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+ const { errors, touched, handleSubmit, getFieldProps } = formik;
|
|
49
|
+
|
|
50
|
+ return(
|
|
51
|
+ <FormikProvider style={{ padding : 15}} value={formik}>
|
|
52
|
+ <Form autoComplete="off" noValidate onSubmit={handleSubmit}>
|
|
53
|
+ <Stack spacing={3}>
|
|
54
|
+ <Stack direction={{ xs: 'column', sm: 'row' }} spacing={2}>
|
|
55
|
+ <TextField
|
|
56
|
+ label="Numero de Nit"
|
|
57
|
+ fullWidth
|
|
58
|
+ {...getFieldProps('nit')}
|
|
59
|
+ error={Boolean(touched.nit && errors.nit)}
|
|
60
|
+ helperText={touched.nit && errors.nit}
|
|
61
|
+ />
|
|
62
|
+
|
|
63
|
+ <TextField
|
|
64
|
+ label="CUI/DPI"
|
|
65
|
+ fullWidth
|
|
66
|
+ {...getFieldProps('cui')}
|
|
67
|
+ error={Boolean(touched.cui && errors.cui)}
|
|
68
|
+ helperText={touched.cui && errors.cui}
|
|
69
|
+ />
|
|
70
|
+ </Stack>
|
|
71
|
+
|
|
72
|
+ <TextField
|
|
73
|
+ fullWidth
|
|
74
|
+ type="text"
|
|
75
|
+ label="Dirección"
|
|
76
|
+ {...getFieldProps('direccion')}
|
|
77
|
+ error={Boolean(touched.direccion && errors.direccion)}
|
|
78
|
+ helperText={touched.direccion && errors.direccion}
|
|
79
|
+ />
|
|
80
|
+
|
|
81
|
+ <Stack direction={{ xs: 'column', sm: 'row' }} spacing={2}>
|
|
82
|
+ <TextField
|
|
83
|
+ type="date"
|
|
84
|
+ label="Fecha de nacimiento"
|
|
85
|
+ fullWidth
|
|
86
|
+ defaultValue={'2021-01-10'}
|
|
87
|
+ InputLabelProps={{ shrink: true, required: true }}
|
|
88
|
+ {...getFieldProps('nacimiento')}
|
|
89
|
+ error={Boolean(touched.nacimiento && errors.nacimiento)}
|
|
90
|
+ helperText={touched.nacimiento && errors.nacimiento}
|
|
91
|
+ />
|
|
92
|
+
|
|
93
|
+ <TextField
|
|
94
|
+ label="Telefono"
|
|
95
|
+ fullWidth
|
|
96
|
+ {...getFieldProps('telefono')}
|
|
97
|
+ error={Boolean(touched.telefono && errors.telefono)}
|
|
98
|
+ helperText={touched.telefono && errors.telefono}
|
|
99
|
+ />
|
|
100
|
+ </Stack>
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+ </Stack>
|
|
104
|
+ </Form>
|
|
105
|
+ </FormikProvider>
|
|
106
|
+ )
|
|
107
|
+}
|