|
@@ -2,78 +2,50 @@ import React from 'react'
|
2
|
2
|
import * as Yup from 'yup';
|
3
|
3
|
import { useState } from 'react';
|
4
|
4
|
import { useFormik, Form, FormikProvider } from 'formik';
|
5
|
|
-// import { useNavigate } from 'react-router-dom';
|
6
|
5
|
import { Icon } from '@iconify/react';
|
7
|
6
|
|
8
|
|
-import {
|
|
7
|
+import {
|
|
8
|
+ Box, Button,
|
9
|
9
|
Stack, TextField, IconButton, InputAdornment,
|
10
|
|
- Backdrop, CircularProgress,
|
11
|
10
|
} from '@mui/material';
|
12
|
11
|
|
13
|
12
|
import eyeFill from '@iconify/icons-eva/eye-fill';
|
14
|
13
|
import eyeOffFill from '@iconify/icons-eva/eye-off-fill';
|
15
|
|
-import { Toaster } from 'react-hot-toast';
|
16
|
14
|
// import { V1, V2 } from '../../Utils/HTTP'
|
17
|
15
|
|
18
|
|
-export function RegisterForm() {
|
|
16
|
+export function RegisterForm(props) {
|
|
17
|
+
|
|
18
|
+ const steplen = 2;
|
19
|
19
|
|
20
|
|
- // const navigate = useNavigate();
|
21
|
20
|
const [showPassword, setShowPassword] = useState(false);
|
22
|
|
- const [open, setOpen] = React.useState(false);
|
23
|
|
- const handleClose = () => {
|
24
|
|
- setOpen(false);
|
25
|
|
- };
|
26
|
|
-
|
27
|
|
- // let navigate = useNavigate()
|
|
21
|
+ const [showPasswordTwo, setShowPasswordTwo] = useState(false);
|
28
|
22
|
|
29
|
23
|
const RegisterSchema = Yup.object().shape({
|
30
|
|
- firstName: Yup.string()
|
31
|
|
- .min(2, 'Demasiado corto!')
|
32
|
|
- .max(50, 'Demasiado largo!')
|
33
|
|
- .required('Tu nombre es requerido'),
|
|
24
|
+ firstName: Yup.string().min(2, 'Demasiado corto!').max(50, 'Demasiado largo!').required('Tu nombre es requerido'),
|
34
|
25
|
lastName: Yup.string().min(2, 'Demasiado corto!').max(50, 'Demasiado Largo!').required('El apellido es requerido'),
|
35
|
26
|
email: Yup.string().email('El correo no es valido').required('Email es requerido'),
|
36
|
27
|
password: Yup.string().min(5, 'La contraseña debe contener mínimo 5 caracteres').required('la contraseña es requerida'),
|
37
|
28
|
password_confirm: Yup.string().required('Las contraseñas no coincidien').oneOf([Yup.ref('password'), null], 'Las contraseñas no coincidien')
|
38
|
29
|
});
|
39
|
30
|
|
40
|
|
- const formik = useFormik({
|
|
31
|
+ let {client, setClient } = props
|
41
|
32
|
|
|
33
|
+ const formik = useFormik({
|
42
|
34
|
initialValues: {
|
43
|
|
- firstName: '',
|
44
|
|
- lastName: '',
|
45
|
|
- email: '',
|
46
|
|
- password: '',
|
47
|
|
- password_confirm: ''
|
|
35
|
+ firstName: client.firstName,
|
|
36
|
+ lastName: client.lastName,
|
|
37
|
+ email: client.email,
|
|
38
|
+ password: client.password,
|
|
39
|
+ password_confirm: client.password_confirm
|
|
40
|
+ },
|
|
41
|
+ onSubmit: (fields) => {
|
|
42
|
+ setClient({ ...fields })
|
|
43
|
+ props.handleNext()
|
48
|
44
|
},
|
49
|
45
|
validationSchema: RegisterSchema,
|
50
|
|
- onSubmit: async (values) => {
|
51
|
|
- // setOpen(true);
|
52
|
|
- let body = {
|
53
|
|
- nombre : values.firstName,
|
54
|
|
- apelidos : values.lastName,
|
55
|
|
- email : values.email,
|
56
|
|
- username : values.email,
|
57
|
|
- pwd : values.password,
|
58
|
|
- "nit": "5345435",
|
59
|
|
- "cui": "555555",
|
60
|
|
- "direccio": "4 calle zona 1",
|
61
|
|
- "fechacumple": "2021-01-01",
|
62
|
|
- "telefono" : "45435345",
|
63
|
|
- }
|
64
|
|
-
|
65
|
|
- let url = 'http://204.48.25.93:8081/registro'
|
66
|
|
- console.log(body, url)
|
67
|
|
- // let url = 'http://psicoadmin.ditca.org:8081/registro'
|
68
|
|
- // V1(url, body);
|
69
|
|
- // V2(url, body);
|
70
|
|
- setOpen(false)
|
71
|
|
- //
|
72
|
|
- }
|
73
|
|
-
|
74
|
46
|
});
|
75
|
47
|
|
76
|
|
- const { errors, touched, handleSubmit, getFieldProps } = formik;
|
|
48
|
+ const {errors, touched, handleSubmit, getFieldProps } = formik;
|
77
|
49
|
|
78
|
50
|
return (
|
79
|
51
|
<FormikProvider style={{ padding : 15 }} value={formik}>
|
|
@@ -128,14 +100,14 @@ export function RegisterForm() {
|
128
|
100
|
|
129
|
101
|
<TextField
|
130
|
102
|
fullWidth
|
131
|
|
- type={showPassword ? 'text' : 'password'}
|
|
103
|
+ type={showPasswordTwo ? 'text' : 'password'}
|
132
|
104
|
label="Confirma contraseña"
|
133
|
105
|
{...getFieldProps('password_confirm')}
|
134
|
106
|
InputProps={{
|
135
|
107
|
endAdornment: (
|
136
|
108
|
<InputAdornment position="end">
|
137
|
|
- <IconButton edge="end" onClick={() => setShowPassword((prev) => !prev)}>
|
138
|
|
- <Icon icon={showPassword ? eyeFill : eyeOffFill} />
|
|
109
|
+ <IconButton edge="end" onClick={() => setShowPasswordTwo((prev) => !prev)}>
|
|
110
|
+ <Icon icon={showPasswordTwo ? eyeFill : eyeOffFill} />
|
139
|
111
|
</IconButton>
|
140
|
112
|
</InputAdornment>
|
141
|
113
|
)
|
|
@@ -145,30 +117,28 @@ export function RegisterForm() {
|
145
|
117
|
/>
|
146
|
118
|
|
147
|
119
|
|
148
|
|
- {/*
|
149
|
|
- <Button
|
150
|
|
- type="submit"
|
151
|
|
- size="large"
|
152
|
|
- style={{ backgroundColor : '#d32f2f'}}
|
153
|
|
- variant="contained" >
|
154
|
|
- Registrarme
|
155
|
|
- </Button>
|
156
|
|
- */
|
157
|
|
- }
|
|
120
|
+ <Box sx={{ mb: 2 }}>
|
|
121
|
+ <div style={{ paddingTop : 15}}>
|
|
122
|
+ <Button
|
|
123
|
+ type="submit"
|
|
124
|
+ className="registerBtn"
|
|
125
|
+ variant="contained"
|
|
126
|
+ // onClick={handleNext}
|
|
127
|
+ sx={{ mt: 1, mr: 1 }}
|
|
128
|
+ >
|
|
129
|
+ {props.index === steplen - 1 ? 'Registrarme' : 'Siguiente'}
|
|
130
|
+ </Button>
|
|
131
|
+ <Button
|
|
132
|
+ onClick={props.handleBack}
|
|
133
|
+ sx={{ mt: 1, mr: 1 }}
|
|
134
|
+ >
|
|
135
|
+ Regresar
|
|
136
|
+ </Button>
|
|
137
|
+ </div>
|
|
138
|
+ </Box>
|
158
|
139
|
|
159
|
140
|
</Stack>
|
160
|
141
|
</Form>
|
161
|
|
- <Toaster
|
162
|
|
- position="top-left"
|
163
|
|
- reverseOrder={false}
|
164
|
|
- />
|
165
|
|
- <Backdrop
|
166
|
|
- sx={{ color: '#fd4b4b', zIndex: (theme) => theme.zIndex.drawer + 1 }}
|
167
|
|
- open={open}
|
168
|
|
- onClick={handleClose}
|
169
|
|
- >
|
170
|
|
- <CircularProgress color="inherit" />
|
171
|
|
- </Backdrop>
|
172
|
142
|
</FormikProvider>
|
173
|
143
|
);
|
174
|
144
|
}
|