Browse Source

step one validation and submit

amenpunk 3 years ago
parent
commit
0cc7e4dc41

+ 24 - 33
src/Components/Modal/PasswordModal.jsx

@@ -8,24 +8,6 @@ import {
8 8
 
9 9
 import { StepOne } from '../Password/Steps/one'
10 10
 
11
-const steps = [
12
-    {
13
-        label : 'Información del candidato',
14
-        operation: <StepOne/>
15
-    },
16
-    {
17
-        label : 'Seleccionar plaza',
18
-        operation: <h1>plaza</h1>
19
-    },
20
-    {
21
-        label : 'Seleccionar pruebas',
22
-        operation: <h1>preubas</h1>
23
-    },
24
-    {
25
-        label : 'Confirmar',
26
-        operation: <h1>adios</h1>
27
-    },
28
-];
29 11
 
30 12
 export function HelpModal (props) {
31 13
 
@@ -58,6 +40,30 @@ export function HelpModal (props) {
58 40
     };
59 41
 
60 42
 
43
+    const steps = [
44
+        {
45
+            label : 'Información del candidato',
46
+            operation: 
47
+                <StepOne 
48
+                    handleNext={handleNext} 
49
+                    handleBack={handleBack} 
50
+                />
51
+        },
52
+        {
53
+            label : 'Seleccionar plaza',
54
+            operation: <h1>plaza</h1>
55
+        },
56
+        {
57
+            label : 'Seleccionar pruebas',
58
+            operation: <h1>preubas</h1>
59
+        },
60
+        {
61
+            label : 'Confirmar',
62
+            operation: <h1>adios</h1>
63
+        },
64
+    ];
65
+
66
+
61 67
     return (
62 68
         <Modal size="lg" 
63 69
             aria-labelledby="contained-modal-title-vcenter" 
@@ -102,21 +108,6 @@ export function HelpModal (props) {
102 108
                                     {steps[activeStep].operation}
103 109
                                 </Box>
104 110
 
105
-                                <Box sx={{ display: 'flex', flexDirection: 'row', pt: 2 }}>
106
-                                    <Button
107
-                                        color="inherit"
108
-                                        disabled={activeStep === 0}
109
-                                        onClick={handleBack}
110
-                                        sx={{ mr: 1 }}
111
-                                    >
112
-                                        Anterior
113
-                                    </Button>
114
-                                    <Box sx={{ flex: '1 1 auto' }} />
115
-                                    <Button onClick={handleNext}>
116
-                                        {activeStep === steps.length - 1 ? 'Guardar' : 'Siguiente'}
117
-                                    </Button>
118
-                                </Box>
119
-
120 111
                             </React.Fragment>
121 112
                         )}
122 113
                 </Box>

+ 12 - 0
src/Components/Password/Rows.js

@@ -54,3 +54,15 @@ export const encabezados = [
54 54
         label: 'Operacion',
55 55
     },
56 56
 ]
57
+export const niveles_educativos = [
58
+    "Primaria",
59
+    "Basico",
60
+    "Diversificado",
61
+    "Tecnico",
62
+    "Pregrado / Licenciatura",
63
+    "Postgrado / Maestria",
64
+    "Doctorado",
65
+    "Diplomado",
66
+    "Certificacion",
67
+    "Cursos"
68
+]

+ 64 - 84
src/Components/Password/Steps/one.js

@@ -2,31 +2,28 @@ 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 { Icon } from '@iconify/react';
6 5
 
7 6
 import {  
8 7
     Box, Button,
9
-    Stack, TextField, IconButton, InputAdornment, 
8
+    Stack, TextField, 
9
+    InputLabel,MenuItem,FormControl,Select
10 10
 } from '@mui/material';
11 11
 
12
-import eyeFill from '@iconify/icons-eva/eye-fill';
13
-import eyeOffFill from '@iconify/icons-eva/eye-off-fill';
14
-// import { V1, V2 } from '../../Utils/HTTP'
12
+import { niveles_educativos } from '../Rows'
15 13
 
16 14
 export function StepOne(props) {
17 15
 
18
-    const steplen = 2;
19
-    const index = 0;
16
+    const [educativo, setEducativo] = useState('');
20 17
 
21
-    const [showPassword, setShowPassword] = useState(false);
22
-    const [showPasswordTwo, setShowPasswordTwo] = useState(false);
18
+    const changeNivelEducativo = (event) => {
19
+        setEducativo(event.target.value);
20
+    };
23 21
 
24
-    const RegisterSchema = Yup.object().shape({
25
-        firstName: Yup.string().min(2, 'Demasiado corto!').max(50, 'Demasiado largo!').required('Tu nombre es requerido'),
22
+    const CandidatoSchema = Yup.object().shape({
23
+        firstName: Yup.string().min(2, 'Demasiado corto!').max(50, 'Demasiado largo!').required('El nombre es requerido'),
26 24
         lastName: Yup.string().min(2, 'Demasiado corto!').max(50, 'Demasiado Largo!').required('El apellido es requerido'),
27
-        email: Yup.string().email('El correo no es valido').required('Email es requerido'),
28
-        password: Yup.string().min(5, 'La contraseña debe contener mínimo 5 caracteres').required('la contraseña es requerida'),
29
-        password_confirm: Yup.string().required('Las contraseñas no coincidien').oneOf([Yup.ref('password'), null], 'Las contraseñas no coincidien')
25
+        puesto: Yup.string().required('El puesto es requerido'),
26
+        niveles_educativo: Yup.number().required('Selecciona un nivel educativo')
30 27
     });
31 28
 
32 29
     let {  handleNext, handleBack } = props
@@ -35,14 +32,14 @@ export function StepOne(props) {
35 32
         initialValues: {
36 33
             firstName: '',
37 34
             lastName: '',
38
-            email: '',
39
-            password: '',
40
-            password_confirm: ''
35
+            puesto: '',
36
+            niveles_educativo: 0,
41 37
         },
42 38
         onSubmit: (fields) => {
39
+            console.log('SUBMIT > ',fields)
43 40
             handleNext()
44 41
         },
45
-        validationSchema: RegisterSchema,
42
+        validationSchema: CandidatoSchema,
46 43
     });
47 44
 
48 45
     const {errors, touched, handleSubmit, getFieldProps } = formik;
@@ -58,7 +55,7 @@ export function StepOne(props) {
58 55
                             {...getFieldProps('firstName')}
59 56
                             error={Boolean(touched.firstName && errors.firstName)}
60 57
                             helperText={touched.firstName && errors.firstName}
61
-                        />
58
+                            />
62 59
 
63 60
                         <TextField
64 61
                             label="Apellidos"
@@ -66,76 +63,59 @@ export function StepOne(props) {
66 63
                             {...getFieldProps('lastName')}
67 64
                             error={Boolean(touched.lastName && errors.lastName)}
68 65
                             helperText={touched.lastName && errors.lastName}
69
-                        />
66
+                            />
70 67
                     </Stack>
71 68
 
72 69
                     <TextField
73 70
                         fullWidth
74
-                        autoComplete="username"
75
-                        type="email"
76
-                        label="Correo Electrónico"
77
-                        {...getFieldProps('email')}
78
-                        error={Boolean(touched.email && errors.email)}
79
-                        helperText={touched.email && errors.email}
80
-                    />
81
-
82
-                    <TextField
83
-                        fullWidth
84
-                        autoComplete="current-password"
85
-                        type={showPassword ? 'text' : 'password'}
86
-                        label="Contraseña"
87
-                        {...getFieldProps('password')}
88
-                        InputProps={{
89
-                            endAdornment: (
90
-                                <InputAdornment position="end">
91
-                                    <IconButton edge="end" onClick={() => setShowPassword((prev) => !prev)}>
92
-                                        <Icon icon={showPassword ? eyeFill : eyeOffFill} />
93
-                                    </IconButton>
94
-                                </InputAdornment>
95
-                            )
96
-                        }}
97
-                        error={Boolean(touched.password && errors.password)}
98
-                        helperText={touched.password && errors.password}
99
-                    />
71
+                        type="text"
72
+                        label="Experiencia laboral o puesto"
73
+                        {...getFieldProps('puesto')}
74
+                        error={Boolean(touched.puesto && errors.puesto)}
75
+                        helperText={touched.puesto && errors.puesto}
76
+                        />
100 77
 
101
-                    <TextField
102
-                        fullWidth
103
-                        type={showPasswordTwo ? 'text' : 'password'}
104
-                        label="Confirma contraseña"
105
-                        {...getFieldProps('password_confirm')}
106
-                        InputProps={{
107
-                            endAdornment: (
108
-                                <InputAdornment position="end">
109
-                                    <IconButton edge="end" onClick={() => setShowPasswordTwo((prev) => !prev)}>
110
-                                        <Icon icon={showPasswordTwo ? eyeFill : eyeOffFill} />
111
-                                    </IconButton>
112
-                                </InputAdornment>
113
-                            )
114
-                        }}
115
-                        error={Boolean(touched.password_confirm && errors.password_confirm)}
116
-                        helperText={touched.password_confirm && errors.password_confirm}
117
-                    />
118
-
119
-
120
-                  <Box sx={{ mb: 2 }}>
121
-                    <div style={{ paddingTop  : 15}}>
122
-                      <Button
123
-                        type="submit"
124
-                        className="registerBtn" 
125
-                        variant="contained"
126
-                        sx={{ mt: 1, mr: 1 }}
127
-                      >
128
-                        {index === steplen - 1 ? 'Registrarme' : 'Siguiente'}
129
-                      </Button>
130
-                      <Button
131
-                        disabled={true}
132
-                        onClick={handleBack}
133
-                        sx={{ mt: 1, mr: 1 }}
134
-                      >
135
-                        Regresar
136
-                      </Button>
137
-                    </div>
138
-                  </Box>
78
+                    <FormControl fullWidth>
79
+                        <InputLabel id="demo-simple-select-label">Nivel Educativo</InputLabel>
80
+                        <Select
81
+                            labelId="demo-simple-select-label"
82
+                            id="demo-simple-select"
83
+                            value={educativo}
84
+                            label="Nivel Educativo"
85
+                            onChange={changeNivelEducativo}
86
+                            {...getFieldProps('niveles_educativo')}
87
+                            error={Boolean(touched.niveles_educativo && errors.niveles_educativo)}
88
+                        >
89
+                            {
90
+                                niveles_educativos.map( ( nivel, index ) => {
91
+                                return (
92
+                                    <MenuItem key={nivel} value={index}>{nivel}</MenuItem>
93
+                                )
94
+                            })
95
+                        }
96
+                        </Select>
97
+                    </FormControl>
98
+
99
+
100
+                    <Box sx={{ mb: 2 }}>
101
+                        <div style={{ paddingTop  : 15}}>
102
+                            <Button
103
+                                type="submit"
104
+                                className="registerBtn" 
105
+                                variant="contained"
106
+                                sx={{ mt: 1, mr: 1 }}
107
+                            >
108
+                                {'Siguiente'}
109
+                            </Button>
110
+                            <Button
111
+                                disabled={true}
112
+                                onClick={handleBack}
113
+                                sx={{ mt: 1, mr: 1 }}
114
+                            >
115
+                                Regresar
116
+                            </Button>
117
+                        </div>
118
+                    </Box>
139 119
 
140 120
                 </Stack>
141 121
             </Form>