Browse Source

first two steps in modal

amenpunk 2 years ago
parent
commit
5399249aec

+ 11 - 10
src/Components/Modal/PasswordModal.jsx

13
 export function HelpModal(props) {
13
 export function HelpModal(props) {
14
 
14
 
15
     let { visible, handleClose } = props
15
     let { visible, handleClose } = props
16
+    const now = React.useRef(new Date());
17
+
16
 
18
 
17
     const [activeStep, setActiveStep] = React.useState(0);
19
     const [activeStep, setActiveStep] = React.useState(0);
18
     const [skipped, setSkipped] = React.useState(new Set());
20
     const [skipped, setSkipped] = React.useState(new Set());
21
+
19
     const [password, setPassword] = React.useState({
22
     const [password, setPassword] = React.useState({
20
-        firstName: '',
23
+        puesto: [],
21
-        lastName: '',
24
+        pwd: "",
22
-        puesto: '',
25
+        deadpwd: now,
23
-        niveles_educativo: 0,
26
+        dateToActived: now,
24
-        puesto_id: 20,
25
-        index_pruebas: []
26
     });
27
     });
27
 
28
 
28
     const isStepSkipped = (step) => {
29
     const isStepSkipped = (step) => {
100
             <Modal.Body className="modal-body">
101
             <Modal.Body className="modal-body">
101
 
102
 
102
                 <Box sx={{ width: '100%' }}>
103
                 <Box sx={{ width: '100%' }}>
103
-                    <Stepper 
104
+                    <Stepper
104
                         sx={{
105
                         sx={{
105
-                            flexWrap :'wrap'
106
+                            flexWrap: 'wrap'
106
                         }}
107
                         }}
107
                         activeStep={activeStep}>
108
                         activeStep={activeStep}>
108
                         {steps.map((step, index) => {
109
                         {steps.map((step, index) => {
113
                             }
114
                             }
114
                             return (
115
                             return (
115
                                 <Step key={step.label} {...stepProps}>
116
                                 <Step key={step.label} {...stepProps}>
116
-                                    <StepLabel 
117
+                                    <StepLabel
117
-                                        sx={{ margin:1}}
118
+                                        sx={{ margin: 1 }}
118
                                         {...labelProps}>{step.label}</StepLabel>
119
                                         {...labelProps}>{step.label}</StepLabel>
119
                                 </Step>
120
                                 </Step>
120
                             );
121
                             );

+ 28 - 18
src/Components/Password/Steps/password.jsx

17
         pwd: 
17
         pwd: 
18
         Yup
18
         Yup
19
         .string()
19
         .string()
20
-        .required('Ingresa un nivel educativo válido')
20
+        .required('Ingresa un identificador válido')
21
         .min(5,"Ingresa un identificador válido")
21
         .min(5,"Ingresa un identificador válido")
22
         .max(50,"identificador demasiado largo"),
22
         .max(50,"identificador demasiado largo"),
23
-        fecha_start: Yup.date("Ingresa una fecha válida"),
23
+        deadpwd: Yup.date("Ingresa una fecha válida"),
24
-        fecha_end: Yup.date("Ingresa una fecha válida"),
24
+        dateToActived: Yup.date("Ingresa una fecha válida"),
25
     });
25
     });
26
 
26
 
27
     let {  handleNext, handleBack, password, setPassword } = props
27
     let {  handleNext, handleBack, password, setPassword } = props
28
-    console.log(password, setPassword)
29
 
28
 
30
     const formik = useFormik({
29
     const formik = useFormik({
31
         initialValues: {
30
         initialValues: {
32
-            pwd: "",
31
+            pwd: password.pwd ,
33
-            fecha_start: new Date(),
32
+            deadpwd: password.deadpwd,
34
-            fecha_end: new Date(),
33
+            dateToActived: password.dateToActived,
35
         },
34
         },
36
         onSubmit: (fields) => {
35
         onSubmit: (fields) => {
37
-            console.log(fields)
36
+            console.log('PASS::::',fields)
37
+            fields['deadpwd'] = new Date(fields.deadpwd).toISOString();
38
+            fields['dateToActived'] = new Date(fields.dateToActived).toISOString();
39
+            setPassword({
40
+                ...password,
41
+                ...fields
42
+            })
38
             handleNext()
43
             handleNext()
39
         },
44
         },
40
         validationSchema: PasswordSchema,
45
         validationSchema: PasswordSchema,
41
     });
46
     });
42
 
47
 
43
-    const {errors, touched, handleSubmit, getFieldProps } = formik;
48
+    const {errors, touched, handleSubmit, getFieldProps, values,setValues } = formik;
44
 
49
 
45
     return (
50
     return (
46
         <FormikProvider style={{ padding : 25, paddingTop : 5 }} value={formik}>
51
         <FormikProvider style={{ padding : 25, paddingTop : 5 }} value={formik}>
64
                                 label="Fecha de Activación"
69
                                 label="Fecha de Activación"
65
                                 fullWidth
70
                                 fullWidth
66
                                 inputFormat="dd/MM/yyyy"
71
                                 inputFormat="dd/MM/yyyy"
67
-                                {...getFieldProps('fecha_start')}
72
+                                {...getFieldProps('dateToActived')}
68
-                                value={new Date()}
73
+                                value={values.dateToActived}
69
-                                onChange={() => console.log('fecha creacion')}
74
+                                onChange={(val) => setValues({ ...values, dateToActived: new Date(val) })
75
+                                }
70
                                 renderInput={(params) =>
76
                                 renderInput={(params) =>
71
                                     <TextField
77
                                     <TextField
78
+                                        error={Boolean(touched.dateToActived && errors.dateToActived)}
79
+                                        helperText={touched.dateToActived && errors.dateToActived}
72
                                         disabled={true}
80
                                         disabled={true}
73
                                         label="Fecha de Activación"
81
                                         label="Fecha de Activación"
74
                                         fullWidth
82
                                         fullWidth
80
                         <LocalizationProvider
88
                         <LocalizationProvider
81
                             dateAdapter={DateFnsUtils}>
89
                             dateAdapter={DateFnsUtils}>
82
                             <DesktopDatePicker
90
                             <DesktopDatePicker
83
-                                label="Fecha de caducidad"
91
+                                label="Fecha de Caducidad"
84
                                 fullWidth
92
                                 fullWidth
85
                                 inputFormat="dd/MM/yyyy"
93
                                 inputFormat="dd/MM/yyyy"
86
-                                {...getFieldProps('fecha_end')}
94
+                                {...getFieldProps('deadpwd')}
87
-                                value={new Date()}
95
+                                value={values.deadpwd}
88
-                                onChange={() => console.log('fecha creacion')}
96
+                                onChange={(val) => setValues({ ...values, deadpwd: new Date(val) }) }
89
                                 renderInput={(params) =>
97
                                 renderInput={(params) =>
90
                                     <TextField
98
                                     <TextField
99
+                                        error={Boolean(touched.deadpwd && errors.deadpwd)}
100
+                                        helperText={touched.deadpwd && errors.deadpwd}
91
                                         disabled={true}
101
                                         disabled={true}
92
-                                        label="Fecha de caducidad"
102
+                                        label="Fecha de Caducidad"
93
                                         fullWidth
103
                                         fullWidth
94
                                         {...params}
104
                                         {...params}
95
-                                        />}
105
+                                    />}
96
                                 />
106
                                 />
97
                         </LocalizationProvider>
107
                         </LocalizationProvider>
98
                     </Stack>
108
                     </Stack>

+ 7 - 8
src/Components/Password/Steps/puesto.js

41
     }
41
     }
42
 
42
 
43
     let { data } = useQuery('puestos', getPuestos)
43
     let { data } = useQuery('puestos', getPuestos)
44
-    let puestos = data ? data.data.map( ({ nombrepuesto, id  }) => ({ label : nombrepuesto, id } )) : []
44
+    let puestos = data ? data.data.map( ({ nombrepuesto, id  }) => ({ nombrepuesto, id } )) : []
45
 
45
 
46
     let {  handleNext, handleBack, password, setPassword } = props
46
     let {  handleNext, handleBack, password, setPassword } = props
47
 
47
 
48
     const formik = useFormik({
48
     const formik = useFormik({
49
         initialValues: {
49
         initialValues: {
50
-            puesto: 
50
+            puesto: password.puesto
51
-            password.index_pruebas
52
         },
51
         },
53
         onSubmit: (fields) => {
52
         onSubmit: (fields) => {
54
-            console.log('PRUEBAS :: -> ',fields)
53
+            console.log(fields)
55
             setPassword({
54
             setPassword({
56
                 ...password,
55
                 ...password,
57
-                index_pruebas : fields.puesto
56
+                puesto : fields.puesto
58
             })
57
             })
59
             handleNext()
58
             handleNext()
60
         },
59
         },
74
                                 puesto:current_list
73
                                 puesto:current_list
75
                             })
74
                             })
76
                         }}
75
                         }}
77
-                        isOptionEqualToValue={(option, value) => option.label === value.label}
76
+                        isOptionEqualToValue={(option, value) => option.nombrepuesto === value.nombrepuesto}
78
                         multiple
77
                         multiple
79
                         id="checkboxes-tags-demo"
78
                         id="checkboxes-tags-demo"
80
                         options={puestos}
79
                         options={puestos}
81
                         disableCloseOnSelect
80
                         disableCloseOnSelect
82
                         getOptionLabel={(option) => { 
81
                         getOptionLabel={(option) => { 
83
-                            return option.label 
82
+                            return option.nombrepuesto 
84
                         }}
83
                         }}
85
                         renderOption={(props, option, { selected }) => (
84
                         renderOption={(props, option, { selected }) => (
86
                             <li {...props}>
85
                             <li {...props}>
90
                                     style={{ marginRight: 8 }}
89
                                     style={{ marginRight: 8 }}
91
                                     checked={selected}
90
                                     checked={selected}
92
                                     />
91
                                     />
93
-                                {option.label}
92
+                                {option.nombrepuesto}
94
                             </li>
93
                             </li>
95
                         )}
94
                         )}
96
                         renderInput={(params) => (
95
                         renderInput={(params) => (