|
@@ -2,153 +2,151 @@ import React from 'react'
|
2
|
2
|
import * as Yup from 'yup';
|
3
|
3
|
import { useFormik, Form, FormikProvider } from 'formik';
|
4
|
4
|
|
5
|
|
-import {
|
6
|
|
- Box, Button,
|
7
|
|
- Stack, TextField,
|
|
5
|
+import {
|
|
6
|
+ Box, Button,
|
|
7
|
+ Stack, TextField,
|
8
|
8
|
} from '@mui/material';
|
9
|
9
|
|
10
|
|
-import DateFnsUtils from '@date-io/date-fns';
|
11
|
|
-import { DesktopDatePicker, LocalizationProvider } from '@mui/lab';
|
12
|
|
-
|
|
10
|
+import { AdapterDateFns as DateFnsUtils } from '@mui/x-date-pickers/AdapterDateFns';
|
|
11
|
+import { DesktopDatePicker } from '@mui/x-date-pickers/DesktopDatePicker';
|
|
12
|
+import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
|
13
|
13
|
|
14
|
14
|
export function Password(props) {
|
15
|
|
-
|
16
|
|
- // console.log(props.password)
|
17
|
15
|
|
18
|
|
- const [uid,setUID] = React.useState(null);
|
|
16
|
+ const [uid, setUID] = React.useState(null);
|
19
|
17
|
|
20
|
|
- const PasswordSchema = Yup.object().shape({
|
21
|
|
- pwd:
|
22
|
|
- Yup
|
|
18
|
+ const PasswordSchema = Yup.object().shape({
|
|
19
|
+ pwd:
|
|
20
|
+ Yup
|
23
|
21
|
.string()
|
24
|
22
|
.required('Ingresa un identificador válido')
|
25
|
|
- .min(5,"Ingresa un identificador válido")
|
26
|
|
- .max(50,"identificador demasiado largo"),
|
27
|
|
- deadpwd: Yup.date("Ingresa una fecha válida"),
|
28
|
|
- dateToActived: Yup.date("Ingresa una fecha válida"),
|
29
|
|
- });
|
30
|
|
-
|
31
|
|
- let { handleNext, handleBack, password, setPassword } = props
|
32
|
|
-
|
33
|
|
- const formik = useFormik({
|
34
|
|
- initialValues: {
|
35
|
|
- pwd: password.pwd ,
|
36
|
|
- deadpwd: password.deadpwd,
|
37
|
|
- dateToActived: password.dateToActived,
|
38
|
|
- },
|
39
|
|
- onSubmit: (fields) => {
|
40
|
|
- fields['deadpwd'] = new Date(fields.deadpwd).toISOString();
|
41
|
|
- fields['dateToActived'] = new Date(fields.dateToActived).toISOString();
|
42
|
|
- setPassword({
|
43
|
|
- ...password,
|
44
|
|
- ...fields
|
45
|
|
- })
|
46
|
|
- handleNext()
|
47
|
|
- },
|
48
|
|
- validationSchema: PasswordSchema,
|
49
|
|
- });
|
50
|
|
-
|
51
|
|
- const {errors, touched, handleSubmit, getFieldProps, values,setValues } = formik;
|
52
|
|
-
|
53
|
|
- return (
|
54
|
|
- <FormikProvider style={{ padding : 25, paddingTop : 5 }} value={formik}>
|
55
|
|
- <Form autoComplete="off" noValidate onSubmit={handleSubmit}>
|
56
|
|
- <Stack spacing={3}>
|
57
|
|
-
|
58
|
|
- <TextField
|
59
|
|
- fullWidth
|
60
|
|
- type="text"
|
61
|
|
- label="Nombre o identificador"
|
62
|
|
- {...getFieldProps('pwd')}
|
63
|
|
- onChange={(event)=>{
|
64
|
|
- let value = event.target.value
|
65
|
|
- setUID(btoa(value));
|
66
|
|
- setValues({
|
67
|
|
- ...values,
|
68
|
|
- pwd:value
|
69
|
|
- })
|
70
|
|
- }}
|
71
|
|
- error={Boolean(touched.pwd && errors.pwd)}
|
72
|
|
- helperText={touched.pwd && errors.pwd}
|
73
|
|
- />
|
74
|
|
-
|
75
|
|
- <TextField
|
76
|
|
- value={uid? uid: btoa(values.pwd)}
|
77
|
|
- disabled
|
78
|
|
- fullWidth
|
79
|
|
- type="text"
|
80
|
|
- label="Identificador Codificado"
|
81
|
|
- variant="filled"
|
82
|
|
- />
|
83
|
|
-
|
84
|
|
- <Stack direction={{ xs: 'column', sm: 'row' }} spacing={2}>
|
85
|
|
-
|
86
|
|
- <LocalizationProvider
|
87
|
|
- dateAdapter={DateFnsUtils}>
|
88
|
|
- <DesktopDatePicker
|
89
|
|
- label="Fecha de Activación"
|
90
|
|
- fullWidth
|
91
|
|
- inputFormat="dd/MM/yyyy"
|
92
|
|
- {...getFieldProps('dateToActived')}
|
93
|
|
- value={values.dateToActived}
|
94
|
|
- onChange={(val) => setValues({ ...values, dateToActived: new Date(val) })
|
95
|
|
- }
|
96
|
|
- renderInput={(params) =>
|
97
|
|
- <TextField
|
98
|
|
- error={Boolean(touched.dateToActived && errors.dateToActived)}
|
99
|
|
- helperText={touched.dateToActived && errors.dateToActived}
|
100
|
|
- disabled={true}
|
101
|
|
- label="Fecha de Activación"
|
102
|
|
- fullWidth
|
103
|
|
- {...params}
|
104
|
|
- />}
|
105
|
|
- />
|
106
|
|
- </LocalizationProvider>
|
107
|
|
-
|
108
|
|
- <LocalizationProvider
|
109
|
|
- dateAdapter={DateFnsUtils}>
|
110
|
|
- <DesktopDatePicker
|
111
|
|
- label="Fecha de Caducidad"
|
112
|
|
- fullWidth
|
113
|
|
- inputFormat="dd/MM/yyyy"
|
114
|
|
- {...getFieldProps('deadpwd')}
|
115
|
|
- value={values.deadpwd}
|
116
|
|
- onChange={(val) => setValues({ ...values, deadpwd: new Date(val) }) }
|
117
|
|
- renderInput={(params) =>
|
118
|
|
- <TextField
|
119
|
|
- error={Boolean(touched.deadpwd && errors.deadpwd)}
|
120
|
|
- helperText={touched.deadpwd && errors.deadpwd}
|
121
|
|
- disabled={true}
|
122
|
|
- label="Fecha de Caducidad"
|
123
|
|
- fullWidth
|
124
|
|
- {...params}
|
125
|
|
- />}
|
126
|
|
- />
|
127
|
|
- </LocalizationProvider>
|
128
|
|
- </Stack>
|
129
|
|
-
|
130
|
|
- <Box sx={{ mb: 2 }}>
|
131
|
|
- <div style={{ paddingTop : 15}}>
|
132
|
|
- <Button
|
133
|
|
- type="submit"
|
134
|
|
- className="registerBtn"
|
135
|
|
- variant="contained"
|
136
|
|
- sx={{ mt: 1, mr: 1 }}
|
137
|
|
- >
|
138
|
|
- {'Siguiente'}
|
139
|
|
- </Button>
|
140
|
|
- <Button
|
141
|
|
- disabled={false}
|
142
|
|
- onClick={handleBack}
|
143
|
|
- sx={{ mt: 1, mr: 1 }}
|
144
|
|
- >
|
145
|
|
- Regresar
|
146
|
|
- </Button>
|
147
|
|
- </div>
|
148
|
|
- </Box>
|
149
|
|
-
|
150
|
|
- </Stack>
|
151
|
|
- </Form>
|
152
|
|
- </FormikProvider>
|
153
|
|
- );
|
|
23
|
+ .min(5, "Ingresa un identificador válido")
|
|
24
|
+ .max(50, "identificador demasiado largo"),
|
|
25
|
+ deadpwd: Yup.date("Ingresa una fecha válida"),
|
|
26
|
+ dateToActived: Yup.date("Ingresa una fecha válida"),
|
|
27
|
+ });
|
|
28
|
+
|
|
29
|
+ let { handleNext, handleBack, password, setPassword } = props
|
|
30
|
+
|
|
31
|
+ const formik = useFormik({
|
|
32
|
+ initialValues: {
|
|
33
|
+ pwd: password.pwd,
|
|
34
|
+ deadpwd: password.deadpwd,
|
|
35
|
+ dateToActived: password.dateToActived,
|
|
36
|
+ },
|
|
37
|
+ onSubmit: (fields) => {
|
|
38
|
+ fields['deadpwd'] = new Date(fields.deadpwd).toISOString();
|
|
39
|
+ fields['dateToActived'] = new Date(fields.dateToActived).toISOString();
|
|
40
|
+ setPassword({
|
|
41
|
+ ...password,
|
|
42
|
+ ...fields
|
|
43
|
+ })
|
|
44
|
+ handleNext()
|
|
45
|
+ },
|
|
46
|
+ validationSchema: PasswordSchema,
|
|
47
|
+ });
|
|
48
|
+
|
|
49
|
+ const { errors, touched, handleSubmit, getFieldProps, values, setValues } = formik;
|
|
50
|
+
|
|
51
|
+ return (
|
|
52
|
+ <FormikProvider style={{ padding: 25, paddingTop: 5 }} value={formik}>
|
|
53
|
+ <Form autoComplete="off" noValidate onSubmit={handleSubmit}>
|
|
54
|
+ <Stack spacing={3}>
|
|
55
|
+
|
|
56
|
+ <TextField
|
|
57
|
+ value={uid ? uid : btoa(values.pwd)}
|
|
58
|
+ disabled
|
|
59
|
+ fullWidth
|
|
60
|
+ type="text"
|
|
61
|
+ label="Identificador Codificado"
|
|
62
|
+ variant="standard"
|
|
63
|
+ />
|
|
64
|
+
|
|
65
|
+ <TextField
|
|
66
|
+ fullWidth
|
|
67
|
+ type="text"
|
|
68
|
+ label="Nombre o identificador"
|
|
69
|
+ {...getFieldProps('pwd')}
|
|
70
|
+ onChange={(event) => {
|
|
71
|
+ let value = event.target.value
|
|
72
|
+ setUID(btoa(value));
|
|
73
|
+ setValues({
|
|
74
|
+ ...values,
|
|
75
|
+ pwd: value
|
|
76
|
+ })
|
|
77
|
+ }}
|
|
78
|
+ error={Boolean(touched.pwd && errors.pwd)}
|
|
79
|
+ helperText={touched.pwd && errors.pwd}
|
|
80
|
+ />
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+ <Stack direction={{ xs: 'column', sm: 'row' }} spacing={2}>
|
|
84
|
+
|
|
85
|
+ <LocalizationProvider dateAdapter={DateFnsUtils}>
|
|
86
|
+
|
|
87
|
+ <DesktopDatePicker
|
|
88
|
+ label="Fecha de Activación"
|
|
89
|
+ fullWidth
|
|
90
|
+ inputFormat="dd/MM/yyyy"
|
|
91
|
+ {...getFieldProps('dateToActived')}
|
|
92
|
+ value={values.dateToActived}
|
|
93
|
+ onChange={(val) => setValues({ ...values, dateToActived: new Date(val) })}
|
|
94
|
+ renderInput={(params) =>
|
|
95
|
+ <TextField
|
|
96
|
+ error={Boolean(touched.dateToActived && errors.dateToActived)}
|
|
97
|
+ helperText={touched.dateToActived && errors.dateToActived}
|
|
98
|
+ disabled={true}
|
|
99
|
+ label="Fecha de Activación"
|
|
100
|
+ fullWidth
|
|
101
|
+ {...params}
|
|
102
|
+ />}
|
|
103
|
+ />
|
|
104
|
+
|
|
105
|
+ <DesktopDatePicker
|
|
106
|
+ label="Fecha de Caducidad"
|
|
107
|
+ fullWidth
|
|
108
|
+ inputFormat="dd/MM/yyyy"
|
|
109
|
+ {...getFieldProps('deadpwd')}
|
|
110
|
+ value={values.deadpwd}
|
|
111
|
+ onChange={(val) => setValues({ ...values, deadpwd: new Date(val) })}
|
|
112
|
+ renderInput={(params) =>
|
|
113
|
+ <TextField
|
|
114
|
+ error={Boolean(touched.deadpwd && errors.deadpwd)}
|
|
115
|
+ helperText={touched.deadpwd && errors.deadpwd}
|
|
116
|
+ disabled={true}
|
|
117
|
+ label="Fecha de Caducidad"
|
|
118
|
+ fullWidth
|
|
119
|
+ {...params}
|
|
120
|
+ />}
|
|
121
|
+ />
|
|
122
|
+
|
|
123
|
+ </LocalizationProvider>
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+ </Stack>
|
|
127
|
+
|
|
128
|
+ <Box sx={{ mb: 2 }}>
|
|
129
|
+ <div style={{ paddingTop: 15 }}>
|
|
130
|
+ <Button
|
|
131
|
+ type="submit"
|
|
132
|
+ className="registerBtn"
|
|
133
|
+ variant="contained"
|
|
134
|
+ sx={{ mt: 1, mr: 1 }}
|
|
135
|
+ >
|
|
136
|
+ {'Siguiente'}
|
|
137
|
+ </Button>
|
|
138
|
+ <Button
|
|
139
|
+ disabled={false}
|
|
140
|
+ onClick={handleBack}
|
|
141
|
+ sx={{ mt: 1, mr: 1 }}
|
|
142
|
+ >
|
|
143
|
+ Regresar
|
|
144
|
+ </Button>
|
|
145
|
+ </div>
|
|
146
|
+ </Box>
|
|
147
|
+
|
|
148
|
+ </Stack>
|
|
149
|
+ </Form>
|
|
150
|
+ </FormikProvider>
|
|
151
|
+ );
|
154
|
152
|
}
|