amenpunk 3 years ago
parent
commit
e4f9326892

+ 27 - 7
src/Components/Modal/PasswordModal.jsx

@@ -6,7 +6,26 @@ import {
6 6
     StepLabel, Button , Typography
7 7
 } from '@mui/material'
8 8
 
9
-const steps = ['Información del candidato', 'Seleccionar plaza', 'Seleccionar pruebas', 'Confirmar'];
9
+import { StepOne } from '../Password/Steps/one'
10
+
11
+const steps = [
12
+    {
13
+        label : 'Información del candidato',
14
+        operation: <StepOne/>
15
+    },
16
+    {
17
+        label : 'Seleccionar plaza',
18
+        operation: <h1>plaza</h1>
19
+    },
20
+    {
21
+        label : 'Seleccionar pruebas',
22
+        operation: <h1>preubas</h1>
23
+    },
24
+    {
25
+        label : 'Confirmar',
26
+        operation: <h1>adios</h1>
27
+    },
28
+];
10 29
 
11 30
 export function HelpModal (props) {
12 31
 
@@ -53,15 +72,15 @@ export function HelpModal (props) {
53 72
 
54 73
                 <Box sx={{ width: '100%' }}>
55 74
                     <Stepper activeStep={activeStep}>
56
-                        {steps.map((label, index) => {
75
+                        {steps.map((step, index) => {
57 76
                             const stepProps = {};
58 77
                             const labelProps = {};
59 78
                             if (isStepSkipped(index)) {
60 79
                                 stepProps.completed = false;
61 80
                             }
62 81
                             return (
63
-                                <Step key={label} {...stepProps}>
64
-                                    <StepLabel {...labelProps}>{label}</StepLabel>
82
+                                <Step key={step.label} {...stepProps}>
83
+                                    <StepLabel {...labelProps}>{step.label}</StepLabel>
65 84
                                 </Step>
66 85
                             );
67 86
                         })}
@@ -79,9 +98,9 @@ export function HelpModal (props) {
79 98
                     ) : (
80 99
                             <React.Fragment>
81 100
 
82
-                                <Typography sx={{ mt: 2, mb: 1 }}>
83
-                                    Paso numero: {activeStep + 1}
84
-                                </Typography>
101
+                                <Box style={{ padding : 25, marginTop : 25}}>
102
+                                    {steps[activeStep].operation}
103
+                                </Box>
85 104
 
86 105
                                 <Box sx={{ display: 'flex', flexDirection: 'row', pt: 2 }}>
87 106
                                     <Button
@@ -97,6 +116,7 @@ export function HelpModal (props) {
97 116
                                         {activeStep === steps.length - 1 ? 'Guardar' : 'Siguiente'}
98 117
                                     </Button>
99 118
                                 </Box>
119
+
100 120
                             </React.Fragment>
101 121
                         )}
102 122
                 </Box>

+ 144 - 0
src/Components/Password/Steps/one.js

@@ -0,0 +1,144 @@
1
+import React from 'react'
2
+import * as Yup from 'yup';
3
+import { useState } from 'react';
4
+import { useFormik, Form, FormikProvider } from 'formik';
5
+import { Icon } from '@iconify/react';
6
+
7
+import {  
8
+    Box, Button,
9
+    Stack, TextField, IconButton, InputAdornment, 
10
+} from '@mui/material';
11
+
12
+import eyeFill from '@iconify/icons-eva/eye-fill';
13
+import eyeOffFill from '@iconify/icons-eva/eye-off-fill';
14
+// import { V1, V2 } from '../../Utils/HTTP'
15
+
16
+export function StepOne(props) {
17
+
18
+    const steplen = 2;
19
+    const index = 0;
20
+
21
+    const [showPassword, setShowPassword] = useState(false);
22
+    const [showPasswordTwo, setShowPasswordTwo] = useState(false);
23
+
24
+    const RegisterSchema = Yup.object().shape({
25
+        firstName: Yup.string().min(2, 'Demasiado corto!').max(50, 'Demasiado largo!').required('Tu nombre es requerido'),
26
+        lastName: Yup.string().min(2, 'Demasiado corto!').max(50, 'Demasiado Largo!').required('El apellido es requerido'),
27
+        email: Yup.string().email('El correo no es valido').required('Email es requerido'),
28
+        password: Yup.string().min(5, 'La contraseña debe contener mínimo 5 caracteres').required('la contraseña es requerida'),
29
+        password_confirm: Yup.string().required('Las contraseñas no coincidien').oneOf([Yup.ref('password'), null], 'Las contraseñas no coincidien')
30
+    });
31
+
32
+    let {  handleNext, handleBack } = props
33
+
34
+    const formik = useFormik({
35
+        initialValues: {
36
+            firstName: '',
37
+            lastName: '',
38
+            email: '',
39
+            password: '',
40
+            password_confirm: ''
41
+        },
42
+        onSubmit: (fields) => {
43
+            handleNext()
44
+        },
45
+        validationSchema: RegisterSchema,
46
+    });
47
+
48
+    const {errors, touched, handleSubmit, getFieldProps } = formik;
49
+
50
+    return (
51
+        <FormikProvider style={{ padding : 25 }} value={formik}>
52
+            <Form autoComplete="off" noValidate onSubmit={handleSubmit}>
53
+                <Stack spacing={3}>
54
+                    <Stack direction={{ xs: 'column', sm: 'row' }} spacing={2}>
55
+                        <TextField
56
+                            label="Nombre"
57
+                            fullWidth
58
+                            {...getFieldProps('firstName')}
59
+                            error={Boolean(touched.firstName && errors.firstName)}
60
+                            helperText={touched.firstName && errors.firstName}
61
+                        />
62
+
63
+                        <TextField
64
+                            label="Apellidos"
65
+                            fullWidth
66
+                            {...getFieldProps('lastName')}
67
+                            error={Boolean(touched.lastName && errors.lastName)}
68
+                            helperText={touched.lastName && errors.lastName}
69
+                        />
70
+                    </Stack>
71
+
72
+                    <TextField
73
+                        fullWidth
74
+                        autoComplete="username"
75
+                        type="email"
76
+                        label="Correo Electrónico"
77
+                        {...getFieldProps('email')}
78
+                        error={Boolean(touched.email && errors.email)}
79
+                        helperText={touched.email && errors.email}
80
+                    />
81
+
82
+                    <TextField
83
+                        fullWidth
84
+                        autoComplete="current-password"
85
+                        type={showPassword ? 'text' : 'password'}
86
+                        label="Contraseña"
87
+                        {...getFieldProps('password')}
88
+                        InputProps={{
89
+                            endAdornment: (
90
+                                <InputAdornment position="end">
91
+                                    <IconButton edge="end" onClick={() => setShowPassword((prev) => !prev)}>
92
+                                        <Icon icon={showPassword ? eyeFill : eyeOffFill} />
93
+                                    </IconButton>
94
+                                </InputAdornment>
95
+                            )
96
+                        }}
97
+                        error={Boolean(touched.password && errors.password)}
98
+                        helperText={touched.password && errors.password}
99
+                    />
100
+
101
+                    <TextField
102
+                        fullWidth
103
+                        type={showPasswordTwo ? 'text' : 'password'}
104
+                        label="Confirma contraseña"
105
+                        {...getFieldProps('password_confirm')}
106
+                        InputProps={{
107
+                            endAdornment: (
108
+                                <InputAdornment position="end">
109
+                                    <IconButton edge="end" onClick={() => setShowPasswordTwo((prev) => !prev)}>
110
+                                        <Icon icon={showPasswordTwo ? eyeFill : eyeOffFill} />
111
+                                    </IconButton>
112
+                                </InputAdornment>
113
+                            )
114
+                        }}
115
+                        error={Boolean(touched.password_confirm && errors.password_confirm)}
116
+                        helperText={touched.password_confirm && errors.password_confirm}
117
+                    />
118
+
119
+
120
+                  <Box sx={{ mb: 2 }}>
121
+                    <div style={{ paddingTop  : 15}}>
122
+                      <Button
123
+                        type="submit"
124
+                        className="registerBtn" 
125
+                        variant="contained"
126
+                        sx={{ mt: 1, mr: 1 }}
127
+                      >
128
+                        {index === steplen - 1 ? 'Registrarme' : 'Siguiente'}
129
+                      </Button>
130
+                      <Button
131
+                        disabled={true}
132
+                        onClick={handleBack}
133
+                        sx={{ mt: 1, mr: 1 }}
134
+                      >
135
+                        Regresar
136
+                      </Button>
137
+                    </div>
138
+                  </Box>
139
+
140
+                </Stack>
141
+            </Form>
142
+        </FormikProvider>
143
+    );
144
+}

+ 0 - 378
src/Components/Register/temp.js

@@ -1,378 +0,0 @@
1
-import * as React from 'react';
2
-import PropTypes from 'prop-types';
3
-import { alpha } from '@mui/material/styles';
4
-import Box from '@mui/material/Box';
5
-import Table from '@mui/material/Table';
6
-import TableBody from '@mui/material/TableBody';
7
-import TableCell from '@mui/material/TableCell';
8
-import TableContainer from '@mui/material/TableContainer';
9
-import TableHead from '@mui/material/TableHead';
10
-import TablePagination from '@mui/material/TablePagination';
11
-import TableRow from '@mui/material/TableRow';
12
-import TableSortLabel from '@mui/material/TableSortLabel';
13
-import Toolbar from '@mui/material/Toolbar';
14
-import Typography from '@mui/material/Typography';
15
-import Paper from '@mui/material/Paper';
16
-import Checkbox from '@mui/material/Checkbox';
17
-import IconButton from '@mui/material/IconButton';
18
-import Tooltip from '@mui/material/Tooltip';
19
-import FormControlLabel from '@mui/material/FormControlLabel';
20
-import Switch from '@mui/material/Switch';
21
-import DeleteIcon from '@mui/icons-material/Delete';
22
-import FilterListIcon from '@mui/icons-material/FilterList';
23
-import { visuallyHidden } from '@mui/utils';
24
-
25
-function createData(name, calories, fat, carbs, protein) {
26
-  return {
27
-    name,
28
-    calories,
29
-    fat,
30
-    carbs,
31
-    protein,
32
-  };
33
-}
34
-
35
-const rows = [
36
-  createData('Cupcake', 305, 3.7, 67, 4.3),
37
-  createData('Donut', 452, 25.0, 51, 4.9),
38
-  createData('Eclair', 262, 16.0, 24, 6.0),
39
-  createData('Frozen yoghurt', 159, 6.0, 24, 4.0),
40
-  createData('Gingerbread', 356, 16.0, 49, 3.9),
41
-  createData('Honeycomb', 408, 3.2, 87, 6.5),
42
-  createData('Ice cream sandwich', 237, 9.0, 37, 4.3),
43
-  createData('Jelly Bean', 375, 0.0, 94, 0.0),
44
-  createData('KitKat', 518, 26.0, 65, 7.0),
45
-  createData('Lollipop', 392, 0.2, 98, 0.0),
46
-  createData('Marshmallow', 318, 0, 81, 2.0),
47
-  createData('Nougat', 360, 19.0, 9, 37.0),
48
-  createData('Oreo', 437, 18.0, 63, 4.0),
49
-];
50
-
51
-function descendingComparator(a, b, orderBy) {
52
-  if (b[orderBy] < a[orderBy]) {
53
-    return -1;
54
-  }
55
-  if (b[orderBy] > a[orderBy]) {
56
-    return 1;
57
-  }
58
-  return 0;
59
-}
60
-
61
-function getComparator(order, orderBy) {
62
-  return order === 'desc'
63
-    ? (a, b) => descendingComparator(a, b, orderBy)
64
-    : (a, b) => -descendingComparator(a, b, orderBy);
65
-}
66
-
67
-// This method is created for cross-browser compatibility, if you don't
68
-// need to support IE11, you can use Array.prototype.sort() directly
69
-function stableSort(array, comparator) {
70
-  const stabilizedThis = array.map((el, index) => [el, index]);
71
-  stabilizedThis.sort((a, b) => {
72
-    const order = comparator(a[0], b[0]);
73
-    if (order !== 0) {
74
-      return order;
75
-    }
76
-    return a[1] - b[1];
77
-  });
78
-  return stabilizedThis.map((el) => el[0]);
79
-}
80
-
81
-const headCells = [
82
-  {
83
-    id: 'name',
84
-    numeric: false,
85
-    disablePadding: true,
86
-    label: 'Dessert (100g serving)',
87
-  },
88
-  {
89
-    id: 'calories',
90
-    numeric: true,
91
-    disablePadding: false,
92
-    label: 'Calories',
93
-  },
94
-  {
95
-    id: 'fat',
96
-    numeric: true,
97
-    disablePadding: false,
98
-    label: 'Fat (g)',
99
-  },
100
-  {
101
-    id: 'carbs',
102
-    numeric: true,
103
-    disablePadding: false,
104
-    label: 'Carbs (g)',
105
-  },
106
-  {
107
-    id: 'protein',
108
-    numeric: true,
109
-    disablePadding: false,
110
-    label: 'Protein (g)',
111
-  },
112
-];
113
-
114
-function EnhancedTableHead(props) {
115
-
116
-  const { onSelectAllClick, order, orderBy, numSelected, rowCount, onRequestSort } =
117
-    props;
118
-  const createSortHandler = (property) => (event) => {
119
-    onRequestSort(event, property);
120
-  };
121
-
122
-  return (
123
-    <TableHead>
124
-      <TableRow>
125
-        <TableCell padding="checkbox">
126
-          <Checkbox
127
-            color="primary"
128
-            indeterminate={numSelected > 0 && numSelected < rowCount}
129
-            checked={rowCount > 0 && numSelected === rowCount}
130
-            onChange={onSelectAllClick}
131
-            inputProps={{
132
-              'aria-label': 'select all desserts',
133
-            }}
134
-          />
135
-        </TableCell>
136
-        {headCells.map((headCell) => (
137
-          <TableCell
138
-            key={headCell.id}
139
-            align={headCell.numeric ? 'right' : 'left'}
140
-            padding={headCell.disablePadding ? 'none' : 'normal'}
141
-            sortDirection={orderBy === headCell.id ? order : false}
142
-          >
143
-            <TableSortLabel
144
-              active={orderBy === headCell.id}
145
-              direction={orderBy === headCell.id ? order : 'asc'}
146
-              onClick={createSortHandler(headCell.id)}
147
-            >
148
-              {headCell.label}
149
-              {orderBy === headCell.id ? (
150
-                <Box component="span" sx={visuallyHidden}>
151
-                  {order === 'desc' ? 'sorted descending' : 'sorted ascending'}
152
-                </Box>
153
-              ) : null}
154
-            </TableSortLabel>
155
-          </TableCell>
156
-        ))}
157
-      </TableRow>
158
-    </TableHead>
159
-  );
160
-}
161
-
162
-EnhancedTableHead.propTypes = {
163
-  numSelected: PropTypes.number.isRequired,
164
-  onRequestSort: PropTypes.func.isRequired,
165
-  onSelectAllClick: PropTypes.func.isRequired,
166
-  order: PropTypes.oneOf(['asc', 'desc']).isRequired,
167
-  orderBy: PropTypes.string.isRequired,
168
-  rowCount: PropTypes.number.isRequired,
169
-};
170
-
171
-const EnhancedTableToolbar = (props) => {
172
-
173
-  const { numSelected } = props;
174
-
175
-  return (
176
-    <Toolbar
177
-      sx={{
178
-        pl: { sm: 2 },
179
-        pr: { xs: 1, sm: 1 },
180
-        ...(numSelected > 0 && {
181
-          bgcolor: (theme) =>
182
-            alpha(theme.palette.primary.main, theme.palette.action.activatedOpacity),
183
-        }),
184
-      }}
185
-    >
186
-      {numSelected > 0 ? (
187
-        <Typography
188
-          sx={{ flex: '1 1 100%' }}
189
-          color="inherit"
190
-          variant="subtitle1"
191
-          component="div"
192
-        >
193
-          {numSelected} selected
194
-        </Typography>
195
-      ) : (
196
-        <Typography
197
-          sx={{ flex: '1 1 100%' }}
198
-          variant="h6"
199
-          id="tableTitle"
200
-          component="div"
201
-        >
202
-          Nutrition
203
-        </Typography>
204
-      )}
205
-
206
-      {numSelected > 0 ? (
207
-        <Tooltip title="Delete">
208
-          <IconButton>
209
-            <DeleteIcon />
210
-          </IconButton>
211
-        </Tooltip>
212
-      ) : (
213
-        <Tooltip title="Filter list">
214
-          <IconButton>
215
-            <FilterListIcon />
216
-          </IconButton>
217
-        </Tooltip>
218
-      )}
219
-    </Toolbar>
220
-  );
221
-};
222
-
223
-EnhancedTableToolbar.propTypes = {
224
-  numSelected: PropTypes.number.isRequired,
225
-};
226
-
227
-export default function EnhancedTable() {
228
-
229
-  const [order, setOrder] = React.useState('asc');
230
-  const [orderBy, setOrderBy] = React.useState('calories');
231
-  const [selected, setSelected] = React.useState([]);
232
-  const [page, setPage] = React.useState(0);
233
-  const [dense, setDense] = React.useState(false);
234
-  const [rowsPerPage, setRowsPerPage] = React.useState(5);
235
-
236
-  const handleRequestSort = (event, property) => {
237
-    const isAsc = orderBy === property && order === 'asc';
238
-    setOrder(isAsc ? 'desc' : 'asc');
239
-    setOrderBy(property);
240
-  };
241
-
242
-  const handleSelectAllClick = (event) => {
243
-    if (event.target.checked) {
244
-      const newSelecteds = rows.map((n) => n.name);
245
-      setSelected(newSelecteds);
246
-      return;
247
-    }
248
-    setSelected([]);
249
-  };
250
-
251
-  const handleClick = (event, name) => {
252
-    const selectedIndex = selected.indexOf(name);
253
-    let newSelected = [];
254
-
255
-    if (selectedIndex === -1) {
256
-      newSelected = newSelected.concat(selected, name);
257
-    } else if (selectedIndex === 0) {
258
-      newSelected = newSelected.concat(selected.slice(1));
259
-    } else if (selectedIndex === selected.length - 1) {
260
-      newSelected = newSelected.concat(selected.slice(0, -1));
261
-    } else if (selectedIndex > 0) {
262
-      newSelected = newSelected.concat(
263
-        selected.slice(0, selectedIndex),
264
-        selected.slice(selectedIndex + 1),
265
-      );
266
-    }
267
-
268
-    setSelected(newSelected);
269
-  };
270
-
271
-  const handleChangePage = (event, newPage) => {
272
-    setPage(newPage);
273
-  };
274
-
275
-  const handleChangeRowsPerPage = (event) => {
276
-    setRowsPerPage(parseInt(event.target.value, 10));
277
-    setPage(0);
278
-  };
279
-
280
-  const handleChangeDense = (event) => {
281
-    setDense(event.target.checked);
282
-  };
283
-
284
-  const isSelected = (name) => selected.indexOf(name) !== -1;
285
-
286
-  // Avoid a layout jump when reaching the last page with empty rows.
287
-  const emptyRows = page > 0 ? Math.max(0, (1 + page) * rowsPerPage - rows.length) : 0;
288
-
289
-  return (
290
-    <Box sx={{ width: '100%' }}>
291
-      <Paper sx={{ width: '100%', mb: 2 }}>
292
-        <EnhancedTableToolbar numSelected={selected.length} />
293
-        <TableContainer>
294
-          <Table
295
-            sx={{ minWidth: 750 }}
296
-            aria-labelledby="tableTitle"
297
-            size={dense ? 'small' : 'medium'}
298
-          >
299
-            <EnhancedTableHead
300
-              numSelected={selected.length}
301
-              order={order}
302
-              orderBy={orderBy}
303
-              onSelectAllClick={handleSelectAllClick}
304
-              onRequestSort={handleRequestSort}
305
-              rowCount={rows.length}
306
-            />
307
-            <TableBody>
308
-              {/* if you don't need to support IE11, you can replace the `stableSort` call with:
309
-                 rows.slice().sort(getComparator(order, orderBy)) */}
310
-              {stableSort(rows, getComparator(order, orderBy))
311
-                .slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage)
312
-                .map((row, index) => {
313
-                  const isItemSelected = isSelected(row.name);
314
-                  const labelId = `enhanced-table-checkbox-${index}`;
315
-
316
-                  return (
317
-                    <TableRow
318
-                      hover
319
-                      onClick={(event) => handleClick(event, row.name)}
320
-                      role="checkbox"
321
-                      aria-checked={isItemSelected}
322
-                      tabIndex={-1}
323
-                      key={row.name}
324
-                      selected={isItemSelected}
325
-                    >
326
-                      <TableCell padding="checkbox">
327
-                        <Checkbox
328
-                          color="primary"
329
-                          checked={isItemSelected}
330
-                          inputProps={{
331
-                            'aria-labelledby': labelId,
332
-                          }}
333
-                        />
334
-                      </TableCell>
335
-                      <TableCell
336
-                        component="th"
337
-                        id={labelId}
338
-                        scope="row"
339
-                        padding="none"
340
-                      >
341
-                        {row.name}
342
-                      </TableCell>
343
-                      <TableCell align="right">{row.calories}</TableCell>
344
-                      <TableCell align="right">{row.fat}</TableCell>
345
-                      <TableCell align="right">{row.carbs}</TableCell>
346
-                      <TableCell align="right">{row.protein}</TableCell>
347
-                    </TableRow>
348
-                  );
349
-                })}
350
-              {emptyRows > 0 && (
351
-                <TableRow
352
-                  style={{
353
-                    height: (dense ? 33 : 53) * emptyRows,
354
-                  }}
355
-                >
356
-                  <TableCell colSpan={6} />
357
-                </TableRow>
358
-              )}
359
-            </TableBody>
360
-          </Table>
361
-        </TableContainer>
362
-        <TablePagination
363
-          rowsPerPageOptions={[5, 10, 25]}
364
-          component="div"
365
-          count={rows.length}
366
-          rowsPerPage={rowsPerPage}
367
-          page={page}
368
-          onPageChange={handleChangePage}
369
-          onRowsPerPageChange={handleChangeRowsPerPage}
370
-        />
371
-      </Paper>
372
-      <FormControlLabel
373
-        control={<Switch checked={dense} onChange={handleChangeDense} />}
374
-        label="Dense padding"
375
-      />
376
-    </Box>
377
-  );
378
-}