|
|
@@ -2,78 +2,50 @@ import React from 'react'
|
|
|
import * as Yup from 'yup';
|
|
|
import { useState } from 'react';
|
|
|
import { useFormik, Form, FormikProvider } from 'formik';
|
|
|
-// import { useNavigate } from 'react-router-dom';
|
|
|
import { Icon } from '@iconify/react';
|
|
|
|
|
|
-import {
|
|
|
+import {
|
|
|
+ Box, Button,
|
|
|
Stack, TextField, IconButton, InputAdornment,
|
|
|
- Backdrop, CircularProgress,
|
|
|
} from '@mui/material';
|
|
|
|
|
|
import eyeFill from '@iconify/icons-eva/eye-fill';
|
|
|
import eyeOffFill from '@iconify/icons-eva/eye-off-fill';
|
|
|
-import { Toaster } from 'react-hot-toast';
|
|
|
// import { V1, V2 } from '../../Utils/HTTP'
|
|
|
|
|
|
-export function RegisterForm() {
|
|
|
+export function RegisterForm(props) {
|
|
|
+
|
|
|
+ const steplen = 2;
|
|
|
|
|
|
- // const navigate = useNavigate();
|
|
|
const [showPassword, setShowPassword] = useState(false);
|
|
|
- const [open, setOpen] = React.useState(false);
|
|
|
- const handleClose = () => {
|
|
|
- setOpen(false);
|
|
|
- };
|
|
|
-
|
|
|
- // let navigate = useNavigate()
|
|
|
+ const [showPasswordTwo, setShowPasswordTwo] = useState(false);
|
|
|
|
|
|
const RegisterSchema = Yup.object().shape({
|
|
|
- firstName: Yup.string()
|
|
|
- .min(2, 'Demasiado corto!')
|
|
|
- .max(50, 'Demasiado largo!')
|
|
|
- .required('Tu nombre es requerido'),
|
|
|
+ firstName: Yup.string().min(2, 'Demasiado corto!').max(50, 'Demasiado largo!').required('Tu nombre es requerido'),
|
|
|
lastName: Yup.string().min(2, 'Demasiado corto!').max(50, 'Demasiado Largo!').required('El apellido es requerido'),
|
|
|
email: Yup.string().email('El correo no es valido').required('Email es requerido'),
|
|
|
password: Yup.string().min(5, 'La contraseña debe contener mínimo 5 caracteres').required('la contraseña es requerida'),
|
|
|
password_confirm: Yup.string().required('Las contraseñas no coincidien').oneOf([Yup.ref('password'), null], 'Las contraseñas no coincidien')
|
|
|
});
|
|
|
|
|
|
- const formik = useFormik({
|
|
|
+ let {client, setClient } = props
|
|
|
|
|
|
+ const formik = useFormik({
|
|
|
initialValues: {
|
|
|
- firstName: '',
|
|
|
- lastName: '',
|
|
|
- email: '',
|
|
|
- password: '',
|
|
|
- password_confirm: ''
|
|
|
+ firstName: client.firstName,
|
|
|
+ lastName: client.lastName,
|
|
|
+ email: client.email,
|
|
|
+ password: client.password,
|
|
|
+ password_confirm: client.password_confirm
|
|
|
+ },
|
|
|
+ onSubmit: (fields) => {
|
|
|
+ setClient({ ...fields })
|
|
|
+ props.handleNext()
|
|
|
},
|
|
|
validationSchema: RegisterSchema,
|
|
|
- onSubmit: async (values) => {
|
|
|
- // setOpen(true);
|
|
|
- let body = {
|
|
|
- nombre : values.firstName,
|
|
|
- apelidos : values.lastName,
|
|
|
- email : values.email,
|
|
|
- username : values.email,
|
|
|
- pwd : values.password,
|
|
|
- "nit": "5345435",
|
|
|
- "cui": "555555",
|
|
|
- "direccio": "4 calle zona 1",
|
|
|
- "fechacumple": "2021-01-01",
|
|
|
- "telefono" : "45435345",
|
|
|
- }
|
|
|
-
|
|
|
- let url = 'http://204.48.25.93:8081/registro'
|
|
|
- console.log(body, url)
|
|
|
- // let url = 'http://psicoadmin.ditca.org:8081/registro'
|
|
|
- // V1(url, body);
|
|
|
- // V2(url, body);
|
|
|
- setOpen(false)
|
|
|
- //
|
|
|
- }
|
|
|
-
|
|
|
});
|
|
|
|
|
|
- const { errors, touched, handleSubmit, getFieldProps } = formik;
|
|
|
+ const {errors, touched, handleSubmit, getFieldProps } = formik;
|
|
|
|
|
|
return (
|
|
|
<FormikProvider style={{ padding : 15 }} value={formik}>
|
|
|
@@ -128,14 +100,14 @@ export function RegisterForm() {
|
|
|
|
|
|
<TextField
|
|
|
fullWidth
|
|
|
- type={showPassword ? 'text' : 'password'}
|
|
|
+ type={showPasswordTwo ? 'text' : 'password'}
|
|
|
label="Confirma contraseña"
|
|
|
{...getFieldProps('password_confirm')}
|
|
|
InputProps={{
|
|
|
endAdornment: (
|
|
|
<InputAdornment position="end">
|
|
|
- <IconButton edge="end" onClick={() => setShowPassword((prev) => !prev)}>
|
|
|
- <Icon icon={showPassword ? eyeFill : eyeOffFill} />
|
|
|
+ <IconButton edge="end" onClick={() => setShowPasswordTwo((prev) => !prev)}>
|
|
|
+ <Icon icon={showPasswordTwo ? eyeFill : eyeOffFill} />
|
|
|
</IconButton>
|
|
|
</InputAdornment>
|
|
|
)
|
|
|
@@ -145,30 +117,28 @@ export function RegisterForm() {
|
|
|
/>
|
|
|
|
|
|
|
|
|
- {/*
|
|
|
- <Button
|
|
|
- type="submit"
|
|
|
- size="large"
|
|
|
- style={{ backgroundColor : '#d32f2f'}}
|
|
|
- variant="contained" >
|
|
|
- Registrarme
|
|
|
- </Button>
|
|
|
- */
|
|
|
- }
|
|
|
+ <Box sx={{ mb: 2 }}>
|
|
|
+ <div style={{ paddingTop : 15}}>
|
|
|
+ <Button
|
|
|
+ type="submit"
|
|
|
+ className="registerBtn"
|
|
|
+ variant="contained"
|
|
|
+ // onClick={handleNext}
|
|
|
+ sx={{ mt: 1, mr: 1 }}
|
|
|
+ >
|
|
|
+ {props.index === steplen - 1 ? 'Registrarme' : 'Siguiente'}
|
|
|
+ </Button>
|
|
|
+ <Button
|
|
|
+ onClick={props.handleBack}
|
|
|
+ sx={{ mt: 1, mr: 1 }}
|
|
|
+ >
|
|
|
+ Regresar
|
|
|
+ </Button>
|
|
|
+ </div>
|
|
|
+ </Box>
|
|
|
|
|
|
</Stack>
|
|
|
</Form>
|
|
|
- <Toaster
|
|
|
- position="top-left"
|
|
|
- reverseOrder={false}
|
|
|
- />
|
|
|
- <Backdrop
|
|
|
- sx={{ color: '#fd4b4b', zIndex: (theme) => theme.zIndex.drawer + 1 }}
|
|
|
- open={open}
|
|
|
- onClick={handleClose}
|
|
|
- >
|
|
|
- <CircularProgress color="inherit" />
|
|
|
- </Backdrop>
|
|
|
</FormikProvider>
|
|
|
);
|
|
|
}
|