Browse Source

comple step one by usign remember value

amenpunk 3 years ago
parent
commit
bd2d162e47

+ 2 - 3
src/Components/Home/Candidatos.js

@@ -15,7 +15,8 @@ const USER_LENGTH = 120
15 15
 
16 16
 
17 17
 function Divide(arregloOriginal){
18
-    const LONGITUD_PEDAZOS = 6;
18
+
19
+    const LONGITUD_PEDAZOS = 8;
19 20
     let arregloDeArreglos = [];
20 21
     for (let i = 0; i < arregloOriginal.length; i += LONGITUD_PEDAZOS) {
21 22
         let pedazo = arregloOriginal.slice(i, i + LONGITUD_PEDAZOS);
@@ -30,9 +31,7 @@ export default function Candidatos () {
30 31
     const [users, setUser] = useState([]);
31 32
 
32 33
     const changePage = ( _ , value) => {
33
-
34 34
         let page_numer = value;
35
-
36 35
         Divide(users)
37 36
         setPage(page_numer);
38 37
     };

+ 8 - 0
src/Components/Modal/PasswordModal.jsx

@@ -17,6 +17,12 @@ export function HelpModal (props) {
17 17
 
18 18
     const [activeStep, setActiveStep] = React.useState(0);
19 19
     const [skipped, setSkipped] = React.useState(new Set());
20
+    const [password, setPassword] = React.useState({
21
+        firstName: '',
22
+        lastName: '',
23
+        puesto: '',
24
+        niveles_educativo: 0,
25
+    });
20 26
 
21 27
     const isStepSkipped = (step) => {
22 28
         return skipped.has(step);
@@ -49,6 +55,8 @@ export function HelpModal (props) {
49 55
                 <StepOne 
50 56
                     handleNext={handleNext} 
51 57
                     handleBack={handleBack} 
58
+                    password={password} 
59
+                    setPassword={setPassword} 
52 60
                 />
53 61
         },
54 62
         {

+ 22 - 12
src/Components/Password/Steps/one.js

@@ -20,23 +20,34 @@ export function StepOne(props) {
20 20
     };
21 21
 
22 22
     const CandidatoSchema = Yup.object().shape({
23
-        firstName: Yup.string().min(2, 'Demasiado corto!').max(50, 'Demasiado largo!'),
24
-        lastName: Yup.string().min(2, 'Demasiado corto!').max(50, 'Demasiado Largo!'),
25
-        puesto: Yup.string(),
26
-        niveles_educativo: Yup.number(),
23
+        firstName: 
24
+        Yup.string()
25
+        .min(2, 'Demasiado corto!')
26
+        .max(50, 'Demasiado largo!')
27
+        .required("Ingresa un nombre válido"),
28
+        lastName: 
29
+        Yup.string()
30
+        .required("Ingresa un apellido valido")
31
+        .min(2, 'Demasiado corto!').max(50, 'Demasiado Largo!'),
32
+        puesto: 
33
+        Yup.string()
34
+        .required("Ingrea un puesto valido"),
35
+        niveles_educativo: 
36
+        Yup.number('Ingresa un valor valido')
37
+        .required('Ingresa un nivel educativo válido'),
27 38
     });
28 39
 
29
-    let {  handleNext, handleBack } = props
40
+    let {  handleNext, handleBack, password, setPassword } = props
30 41
 
31 42
     const formik = useFormik({
32 43
         initialValues: {
33
-            firstName: '',
34
-            lastName: '',
35
-            puesto: '',
36
-            niveles_educativo: 0,
44
+            firstName: password.firstName ,
45
+            lastName: password.lastName,
46
+            puesto: password.puesto,
47
+            niveles_educativo: password.niveles_educativo,
37 48
         },
38 49
         onSubmit: (fields) => {
39
-            console.log('SUBMIT > ',fields)
50
+            setPassword({...password, ...fields})
40 51
             handleNext()
41 52
         },
42 53
         validationSchema: CandidatoSchema,
@@ -84,8 +95,7 @@ export function StepOne(props) {
84 95
                             label="Nivel Educativo"
85 96
                             onChange={changeNivelEducativo}
86 97
                             {...getFieldProps('niveles_educativo')}
87
-                            error={Boolean(touched.niveles_educativo && errors.niveles_educativo)}
88
-                        >
98
+                            error={Boolean(touched.niveles_educativo && errors.niveles_educativo)} >
89 99
                             {
90 100
                                 niveles_educativos.map( ( nivel, index ) => {
91 101
                                 return (