ソースを参照

first two steeps in pwd

amenpunk 2 年 前
コミット
f3fe15038d

+ 48 - 43
src/Components/Modal/PasswordModal.jsx

@@ -1,17 +1,16 @@
1 1
 import { Modal } from 'react-bootstrap'
2 2
 import * as React from 'react';
3 3
 
4
-import { 
4
+import {
5 5
     Box, Stepper, Step,
6
-    StepLabel, Button , Typography
6
+    StepLabel, Button, Typography
7 7
 } from '@mui/material'
8 8
 
9
-import { StepOne } from '../Password/Steps/one'
10
-import { StepTwo } from '../Password/Steps/two'
11
-import { StepTree } from '../Password/Steps/tree'
9
+import { Puesto } from '../Password/Steps/puesto'
10
+import { Password } from '../Password/Steps/password'
12 11
 import { StepFour } from '../Password/Steps/four'
13 12
 
14
-export function HelpModal (props) {
13
+export function HelpModal(props) {
15 14
 
16 15
     let { visible, handleClose } = props
17 16
 
@@ -52,54 +51,54 @@ export function HelpModal (props) {
52 51
 
53 52
     const steps = [
54 53
         {
55
-            label : 'Información del candidato',
56
-            operation: 
57
-                <StepOne 
58
-                    handleNext={handleNext} 
59
-                    handleBack={handleBack} 
60
-                    password={password} 
61
-                    setPassword={setPassword} 
54
+            label: 'Selecciona un Puesto',
55
+            operation:
56
+                <Puesto
57
+                    handleNext={handleNext}
58
+                    handleBack={handleBack}
59
+                    password={password}
60
+                    setPassword={setPassword}
62 61
                 />
63 62
         },
64 63
         {
65
-            label : 'Seleccionar plaza',
64
+            label: 'Contraseña',
66 65
             operation:
67
-                <StepTwo 
68
-                    handleNext={handleNext} 
69
-                    handleBack={handleBack} 
70
-                    password={password} 
71
-                    setPassword={setPassword} 
66
+                <Password
67
+                    handleNext={handleNext}
68
+                    handleBack={handleBack}
69
+                    password={password}
70
+                    setPassword={setPassword}
72 71
                 />
73 72
         },
74 73
         {
75
-            label : 'Seleccionar pruebas',
74
+            label: 'Seleccionar pruebas',
76 75
             operation:
77
-                <StepTree
78
-                    handleNext={handleNext} 
79
-                    handleBack={handleBack} 
80
-                    password={password} 
81
-                    setPassword={setPassword} 
76
+                <Puesto
77
+                    handleNext={handleNext}
78
+                    handleBack={handleBack}
79
+                    password={password}
80
+                    setPassword={setPassword}
82 81
                 />
83 82
         },
84 83
         {
85
-            label : 'Confirmar',
86
-            operation: 
84
+            label: 'Confirmar',
85
+            operation:
87 86
                 <StepFour
88
-                    handleNext={handleNext} 
89
-                    handleBack={handleBack} 
90
-                    password={password} 
91
-                    setPassword={setPassword} 
87
+                    handleNext={handleNext}
88
+                    handleBack={handleBack}
89
+                    password={password}
90
+                    setPassword={setPassword}
92 91
                 />
93 92
         },
94 93
     ];
95 94
 
96 95
 
97 96
     return (
98
-        <Modal size="lg" 
99
-            aria-labelledby="contained-modal-title-vcenter" 
100
-            centered show={visible} 
97
+        <Modal size="lg"
98
+            aria-labelledby="contained-modal-title-vcenter"
99
+            centered show={visible}
101 100
             onHide={handleClose}
102
-        > 
101
+        >
103 102
             <Modal.Header>
104 103
                 <button type="button" className="close" onClick={handleClose}>&times;</button>
105 104
                 <h4 className="modal-title">Crear Contraseña</h4>
@@ -107,7 +106,11 @@ export function HelpModal (props) {
107 106
             <Modal.Body className="modal-body">
108 107
 
109 108
                 <Box sx={{ width: '100%' }}>
110
-                    <Stepper activeStep={activeStep}>
109
+                    <Stepper 
110
+                        sx={{
111
+                            flexWrap :'wrap'
112
+                        }}
113
+                        activeStep={activeStep}>
111 114
                         {steps.map((step, index) => {
112 115
                             const stepProps = {};
113 116
                             const labelProps = {};
@@ -116,7 +119,9 @@ export function HelpModal (props) {
116 119
                             }
117 120
                             return (
118 121
                                 <Step key={step.label} {...stepProps}>
119
-                                    <StepLabel {...labelProps}>{step.label}</StepLabel>
122
+                                    <StepLabel 
123
+                                        sx={{ margin:1}}
124
+                                        {...labelProps}>{step.label}</StepLabel>
120 125
                                 </Step>
121 126
                             );
122 127
                         })}
@@ -132,14 +137,14 @@ export function HelpModal (props) {
132 137
                             </Box>
133 138
                         </React.Fragment>
134 139
                     ) : (
135
-                            <React.Fragment>
140
+                        <React.Fragment>
136 141
 
137
-                                <Box style={{ padding : 25, marginTop : 25}}>
138
-                                    {steps[activeStep].operation}
139
-                                </Box>
142
+                            <Box style={{ padding: 25, marginTop: 25 }}>
143
+                                {steps[activeStep].operation}
144
+                            </Box>
140 145
 
141
-                            </React.Fragment>
142
-                        )}
146
+                        </React.Fragment>
147
+                    )}
143 148
                 </Box>
144 149
 
145 150
             </Modal.Body>

+ 0 - 1
src/Components/Password/CustomToolbar.jsx

@@ -15,7 +15,6 @@ export default class CustomToolbar extends React.Component {
15 15
         }
16 16
     }
17 17
 
18
-
19 18
     setVisible = () => this.setState({ visible : false});
20 19
 
21 20
     handleClick = () => {

+ 2 - 1
src/Components/Password/Steps/one.js

@@ -11,7 +11,8 @@ import {
11 11
 
12 12
 import { niveles_educativos } from '../Rows'
13 13
 
14
-export function StepOne(props) {
14
+
15
+export function Candidato(props) {
15 16
 
16 17
     const [educativo, setEducativo] = useState('');
17 18
 

+ 132 - 0
src/Components/Password/Steps/password.jsx

@@ -0,0 +1,132 @@
1
+import React from 'react'
2
+import * as Yup from 'yup';
3
+import { useState } from 'react';
4
+import { useFormik, Form, FormikProvider } from 'formik';
5
+
6
+import {  
7
+    Box, Button,
8
+    Stack, TextField, 
9
+    InputLabel,MenuItem,FormControl,Select
10
+} from '@mui/material';
11
+
12
+import DateFnsUtils from '@date-io/date-fns';
13
+import { DesktopDatePicker, LocalizationProvider } from '@mui/lab';
14
+
15
+import { niveles_educativos } from '../Rows'
16
+
17
+export function Password(props) {
18
+
19
+    const [educativo, setEducativo] = useState('');
20
+
21
+    const changeNivelEducativo = (event) => {
22
+        setEducativo(event.target.value);
23
+    };
24
+
25
+    const PasswordSchema = Yup.object().shape({
26
+        pwd: 
27
+        Yup
28
+        .string()
29
+        .required('Ingresa un nivel educativo válido')
30
+        .min(5,"Ingresa un identificador válido")
31
+        .max(50,"identificador demasiado largo"),
32
+        fecha_start: Yup.date("Ingresa una fecha válida"),
33
+        fecha_end: Yup.date("Ingresa una fecha válida"),
34
+    });
35
+
36
+    let {  handleNext, handleBack, password, setPassword } = props
37
+
38
+    const formik = useFormik({
39
+        initialValues: {
40
+            pwd: "",
41
+            fecha_start: new Date(),
42
+            fecha_end: new Date(),
43
+        },
44
+        onSubmit: (fields) => {
45
+            console.log(fields)
46
+            handleNext()
47
+        },
48
+        validationSchema: PasswordSchema,
49
+    });
50
+
51
+    const {errors, touched, handleSubmit, getFieldProps } = 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
+                        error={Boolean(touched.pwd && errors.pwd)}
64
+                        helperText={touched.pwd && errors.pwd}
65
+                        />
66
+
67
+                    <Stack direction={{ xs: 'column', sm: 'row' }} spacing={2}>
68
+
69
+                        <LocalizationProvider
70
+                            dateAdapter={DateFnsUtils}>
71
+                            <DesktopDatePicker
72
+                                label="Fecha de Activación"
73
+                                fullWidth
74
+                                inputFormat="dd/MM/yyyy"
75
+                                {...getFieldProps('fecha_start')}
76
+                                value={new Date()}
77
+                                onChange={() => console.log('fecha creacion')}
78
+                                renderInput={(params) =>
79
+                                    <TextField
80
+                                        disabled={true}
81
+                                        label="Fecha de Activación"
82
+                                        fullWidth
83
+                                        {...params}
84
+                                        />}
85
+                                />
86
+                        </LocalizationProvider>
87
+
88
+                        <LocalizationProvider
89
+                            dateAdapter={DateFnsUtils}>
90
+                            <DesktopDatePicker
91
+                                label="Fecha de caducidad"
92
+                                fullWidth
93
+                                inputFormat="dd/MM/yyyy"
94
+                                {...getFieldProps('fecha_end')}
95
+                                value={new Date()}
96
+                                onChange={() => console.log('fecha creacion')}
97
+                                renderInput={(params) =>
98
+                                    <TextField
99
+                                        disabled={true}
100
+                                        label="Fecha de caducidad"
101
+                                        fullWidth
102
+                                        {...params}
103
+                                        />}
104
+                                />
105
+                        </LocalizationProvider>
106
+                    </Stack>
107
+
108
+                    <Box sx={{ mb: 2 }}>
109
+                        <div style={{ paddingTop  : 15}}>
110
+                            <Button
111
+                                type="submit"
112
+                                className="registerBtn" 
113
+                                variant="contained"
114
+                                sx={{ mt: 1, mr: 1 }}
115
+                            >
116
+                                {'Siguiente'}
117
+                            </Button>
118
+                            <Button
119
+                                disabled={false}
120
+                                onClick={handleBack}
121
+                                sx={{ mt: 1, mr: 1 }}
122
+                            >
123
+                                Regresar
124
+                            </Button>
125
+                        </div>
126
+                    </Box>
127
+
128
+                </Stack>
129
+            </Form>
130
+        </FormikProvider>
131
+    );
132
+}

+ 22 - 5
src/Components/Password/Steps/tree.js

@@ -13,18 +13,35 @@ import {
13 13
     CheckBoxOutlineBlank as CheckBoxOutlineBlankIcon
14 14
 } from '@mui/icons-material';
15 15
 
16
+import { useQuery } from 'react-query';
17
+import { Service } from '../../../Utils/HTTP.js'
18
+import useAuth from '../../../Auth/useAuth'
19
+
16 20
 const delete_icon = <CheckBoxOutlineBlankIcon fontSize="small" />;
17 21
 const checkedIcon = <CheckBoxIcon fontSize="small" />;
18 22
 
19 23
 
20
-export function StepTree(props) {
24
+
25
+export function Puesto(props) {
26
+
27
+    const auth = useAuth();
28
+    const token = auth.getToken();
21 29
 
22 30
     const PlazaScheme = Yup.object().shape({
23 31
         puesto: 
24 32
         Yup.array()
25 33
         .required('Escoge un puesto valido')
26
-        .min(1,"Debes escoger por lo menos una prueba")
34
+        .min(1,"Debes escoger por lo menos un puesto")
35
+        .max(1,"Debes escoger un solo puesto")
27 36
     });
37
+    
38
+    const getPuestos = async () => {
39
+        let rest = new Service('/plaza/getall')
40
+        return rest.getQuery(token);
41
+    }
42
+
43
+    let { data } = useQuery('puestos', getPuestos)
44
+    let puestos = data ? data.data.map( ({ nombrepuesto, id  }) => ({ label : nombrepuesto, id } )) : []
28 45
 
29 46
     let {  handleNext, handleBack, password, setPassword } = props
30 47
 
@@ -60,7 +77,7 @@ export function StepTree(props) {
60 77
                         isOptionEqualToValue={(option, value) => option.label === value.label}
61 78
                         multiple
62 79
                         id="checkboxes-tags-demo"
63
-                        options={top100Films}
80
+                        options={puestos}
64 81
                         disableCloseOnSelect
65 82
                         getOptionLabel={(option) => { 
66 83
                             return option.label 
@@ -82,8 +99,8 @@ export function StepTree(props) {
82 99
                                 error={Boolean(touched.puesto && errors.puesto)}
83 100
                                 helperText={touched.puesto && errors.puesto}
84 101
                                 {...params} 
85
-                                label="Escribe el nombre de la prueba" 
86
-                                placeholder="Prueba" 
102
+                                label="Escribe el nombre del puesto" 
103
+                                placeholder="Puesto" 
87 104
                             />
88 105
                         )}
89 106
                     />

+ 18 - 2
src/Components/Password/Steps/two.js

@@ -1,6 +1,5 @@
1 1
 import React from 'react'
2 2
 import * as Yup from 'yup';
3
-// import { useState, useEffect } from 'react';
4 3
 import { useFormik, Form, FormikProvider } from 'formik';
5 4
 
6 5
 import {
@@ -8,7 +7,15 @@ import {
8 7
     FormControl,MenuItem,InputLabel
9 8
 } from '@mui/material';
10 9
 
11
-export function StepTwo(props) {
10
+import { useQuery } from 'react-query';
11
+import { Service } from '../../../Utils/HTTP.js'
12
+import useAuth from '../../../Auth/useAuth'
13
+
14
+
15
+export function Puesto(props) {
16
+    
17
+    const auth = useAuth();
18
+    const token = auth.getToken();
12 19
 
13 20
     const PlazaScheme = Yup.object().shape({
14 21
         puesto_id: 
@@ -17,6 +24,15 @@ export function StepTwo(props) {
17 24
         .required('Escoge un puesto válido')
18 25
     });
19 26
 
27
+
28
+    const getPuestos = async () => {
29
+        let rest = new Service('/plaza/getall')
30
+        return rest.getQuery(token);
31
+    }
32
+
33
+    let { data } = useQuery('puetos', getPuestos)
34
+    console.log("puestos >>", data )
35
+
20 36
     let {  handleNext, handleBack, password, setPassword } = props
21 37
 
22 38
     const formik = useFormik({