浏览代码

comple step one by usign remember value

amenpunk 3 年之前
父节点
当前提交
bd2d162e47
共有 3 个文件被更改,包括 32 次插入15 次删除
  1. 2 3
      src/Components/Home/Candidatos.js
  2. 8 0
      src/Components/Modal/PasswordModal.jsx
  3. 22 12
      src/Components/Password/Steps/one.js

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

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

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

17
 
17
 
18
     const [activeStep, setActiveStep] = React.useState(0);
18
     const [activeStep, setActiveStep] = React.useState(0);
19
     const [skipped, setSkipped] = React.useState(new Set());
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
     const isStepSkipped = (step) => {
27
     const isStepSkipped = (step) => {
22
         return skipped.has(step);
28
         return skipped.has(step);
49
                 <StepOne 
55
                 <StepOne 
50
                     handleNext={handleNext} 
56
                     handleNext={handleNext} 
51
                     handleBack={handleBack} 
57
                     handleBack={handleBack} 
58
+                    password={password} 
59
+                    setPassword={setPassword} 
52
                 />
60
                 />
53
         },
61
         },
54
         {
62
         {

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

20
     };
20
     };
21
 
21
 
22
     const CandidatoSchema = Yup.object().shape({
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
     const formik = useFormik({
42
     const formik = useFormik({
32
         initialValues: {
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
         onSubmit: (fields) => {
49
         onSubmit: (fields) => {
39
-            console.log('SUBMIT > ',fields)
50
+            setPassword({...password, ...fields})
40
             handleNext()
51
             handleNext()
41
         },
52
         },
42
         validationSchema: CandidatoSchema,
53
         validationSchema: CandidatoSchema,
84
                             label="Nivel Educativo"
95
                             label="Nivel Educativo"
85
                             onChange={changeNivelEducativo}
96
                             onChange={changeNivelEducativo}
86
                             {...getFieldProps('niveles_educativo')}
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
                                 niveles_educativos.map( ( nivel, index ) => {
100
                                 niveles_educativos.map( ( nivel, index ) => {
91
                                 return (
101
                                 return (