瀏覽代碼

first two steps in modal

amenpunk 2 年之前
父節點
當前提交
5399249aec

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

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

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

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

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

@@ -41,20 +41,19 @@ export function Puesto(props) {
41 41
     }
42 42
 
43 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 46
     let {  handleNext, handleBack, password, setPassword } = props
47 47
 
48 48
     const formik = useFormik({
49 49
         initialValues: {
50
-            puesto: 
51
-            password.index_pruebas
50
+            puesto: password.puesto
52 51
         },
53 52
         onSubmit: (fields) => {
54
-            console.log('PRUEBAS :: -> ',fields)
53
+            console.log(fields)
55 54
             setPassword({
56 55
                 ...password,
57
-                index_pruebas : fields.puesto
56
+                puesto : fields.puesto
58 57
             })
59 58
             handleNext()
60 59
         },
@@ -74,13 +73,13 @@ export function Puesto(props) {
74 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 77
                         multiple
79 78
                         id="checkboxes-tags-demo"
80 79
                         options={puestos}
81 80
                         disableCloseOnSelect
82 81
                         getOptionLabel={(option) => { 
83
-                            return option.label 
82
+                            return option.nombrepuesto 
84 83
                         }}
85 84
                         renderOption={(props, option, { selected }) => (
86 85
                             <li {...props}>
@@ -90,7 +89,7 @@ export function Puesto(props) {
90 89
                                     style={{ marginRight: 8 }}
91 90
                                     checked={selected}
92 91
                                     />
93
-                                {option.label}
92
+                                {option.nombrepuesto}
94 93
                             </li>
95 94
                         )}
96 95
                         renderInput={(params) => (