浏览代码

resume step

amenpunk 2 年之前
父节点
当前提交
55adc058e6

+ 5 - 0
src/App.css

@@ -259,3 +259,8 @@
259 259
     padding-top : 25px !important;
260 260
 }
261 261
 
262
+.name_header{
263
+    max-width:20px;
264
+    background-color:whitesmoke;
265
+    font-weight:bold;
266
+}

+ 14 - 15
src/Auth/AuthProvider.js

@@ -3,47 +3,46 @@ import Cookies from 'js-cookie'
3 3
 
4 4
 export const AuthContext = React.createContext(null);
5 5
 
6
-export function AuthProvider ({ children }){
6
+export function AuthProvider({ children }) {
7 7
 
8
-    let [user, setUser] = React.useState( Cookies.get('token') );
9
-    let [profile, setProfile] = React.useState({});
8
+    let [user, setUser] = React.useState(Cookies.get('token'));
10 9
 
11 10
     const context = {
12 11
         user,
13 12
         login: (token) => {
14
-            try{
15
-                Cookies.set('token', token, { expires : 7 })
13
+            try {
14
+                Cookies.set('token', token, { expires: 7 })
16 15
                 setUser(Cookies.get('token'))
17
-            }catch(e){
16
+            } catch (e) {
18 17
                 console.log('Login Error >> ', e)
19 18
                 Cookies.set('token', undefined)
20 19
             }
21 20
         },
22
-        logout : () => {
21
+        logout: () => {
23 22
             Cookies.set('token', undefined)
24 23
             setUser(undefined)
25 24
         },
26
-        getToken : () => Cookies.get('token'),
27
-        isLogged : () => {
28
-            try{
25
+        getToken: () => Cookies.get('token'),
26
+        isLogged: () => {
27
+            try {
29 28
                 let CookiesUser = Cookies.get('token')
30
-                if(!CookiesUser || CookiesUser === 'undefined'){
29
+                if (!CookiesUser || CookiesUser === 'undefined') {
31 30
                     return false
32 31
                 }
33 32
                 // TODO   
34 33
                 // add an method implmentation for 
35 34
                 // check if cockie jwt is valid
36
-                let logged = CookiesUser.length > 5 
35
+                let logged = CookiesUser.length > 5
37 36
                 console.log("is login? >>", logged)
38 37
                 return logged
39 38
 
40
-            }catch(e){
39
+            } catch (e) {
41 40
                 console.log("Error checking user ", e)
42 41
                 return false
43 42
             }
44 43
         },
45
-        setProfile :(obj) => setProfile(obj),
46
-        getProfile: () => profile
44
+        setProfile: (obj) => Cookies.set('profile', JSON.stringify(obj) ),
45
+        getProfile: () => JSON.parse( Cookies.get('profile') )
47 46
     }
48 47
 
49 48
     return (

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

@@ -21,15 +21,15 @@ export function HelpModal(props) {
21 21
 
22 22
     const [password, setPassword] = React.useState({
23 23
         puesto: [],
24
-        pwd: "",
24
+        pwd: "xxxxxxxxxxx",
25 25
         deadpwd: now.current,
26 26
         dateToActived: now.current,
27
-        nombres:"",
28
-        apellidos:"",
29
-        mail:"",
27
+        nombres:"xxxxxxxxxx",
28
+        apellidos:"xxxxxxxxx",
29
+        mail:"xxx@gmail.com",
30 30
         sendmail:true,
31
-        nombrepuesto:"",
32
-        nombreEmpresa:"",
31
+        nombrepuesto:null,
32
+        nombreEmpresa:null,
33 33
     });
34 34
 
35 35
     const isStepSkipped = (step) => {
@@ -144,7 +144,7 @@ export function HelpModal(props) {
144 144
                     ) : (
145 145
                         <React.Fragment>
146 146
 
147
-                            <Box style={{ padding: 25, marginTop: 25 }}>
147
+                            <Box style={{ padding: 18, marginTop: 10 }}>
148 148
                                 {steps[activeStep].operation}
149 149
                             </Box>
150 150
 

+ 6 - 2
src/Components/Password/Steps/candidato.jsx

@@ -7,9 +7,13 @@ import {
7 7
     Stack, TextField, FormGroup,
8 8
 } from '@mui/material';
9 9
 
10
+import useAuth from '../../../Auth/useAuth';
11
+
10 12
 
11 13
 export function Candidato(props) {
12 14
 
15
+    const auth = useAuth();
16
+
13 17
     const CandidatoSchema = Yup.object().shape({
14 18
         nombres:
15 19
             Yup.string()
@@ -43,8 +47,8 @@ export function Candidato(props) {
43 47
             apellidos: password.apellidos,
44 48
             sendmail: password.sendmail,
45 49
             mail : password.mail,
46
-            nombrepuesto: password.nombrepuesto,
47
-            nombreEmpresa: password.nombreEmpresa,
50
+            nombrepuesto: password.nombrepuesto ? password.nombrepuesto: password.puesto[0].nombrepuesto,
51
+            nombreEmpresa: password.nombreEmpresa ? password.nombreEmpresa : auth.getProfile().nombre,
48 52
         },
49 53
         onSubmit: (fields) => {
50 54
             setPassword({ ...password, ...fields })

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

@@ -50,7 +50,6 @@ export function Puesto(props) {
50 50
             puesto: password.puesto
51 51
         },
52 52
         onSubmit: (fields) => {
53
-            console.log(fields)
54 53
             setPassword({
55 54
                 ...password,
56 55
                 puesto : fields.puesto
@@ -67,6 +66,7 @@ export function Puesto(props) {
67 66
             <Form autoComplete="off" noValidate onSubmit={handleSubmit}>
68 67
                 <Stack spacing={2}>
69 68
                     <Autocomplete
69
+                        disableCloseOnSelect={false}
70 70
                         {...getFieldProps('puesto')}
71 71
                         onChange={(_a,current_list,_c,_individual,_f) => {
72 72
                             setValues({
@@ -77,7 +77,6 @@ export function Puesto(props) {
77 77
                         multiple
78 78
                         id="checkboxes-tags-demo"
79 79
                         options={puestos}
80
-                        disableCloseOnSelect
81 80
                         getOptionLabel={(option) => { 
82 81
                             return option.nombrepuesto 
83 82
                         }}

+ 56 - 94
src/Components/Password/Steps/resume.jsx

@@ -1,104 +1,66 @@
1 1
 import * as React from 'react';
2
-import Table from '@mui/material/Table';
3
-import TableBody from '@mui/material/TableBody';
4
-import TableCell from '@mui/material/TableCell';
5
-import TableContainer from '@mui/material/TableContainer';
6
-import TableHead from '@mui/material/TableHead';
7
-import TableRow from '@mui/material/TableRow';
8
-import Paper from '@mui/material/Paper';
9
-import {
10
-    Typography, Divider, Box, Button
11
-} from '@mui/material';
2
+import { Table } from 'react-bootstrap';
12 3
 
13
-const TAX_RATE = 0.07;
14
-
15
-function ccyFormat(num) {
16
-    return `${num.toFixed(2)}`;
17
-}
18
-
19
-function priceRow(qty, unit) {
20
-    return qty * unit;
21
-}
22
-
23
-function createRow(desc, qty, unit) {
24
-    const price = priceRow(qty, unit);
25
-    return { desc, qty, unit, price };
26
-}
27
-
28
-function subtotal(items) {
29
-    return items.map(({ price }) => price).reduce((sum, i) => sum + i, 0);
30
-}
31
-
32
-const rows = [
33
-    createRow('Paperclips (Box)', 100, 1.15),
34
-    createRow('Paper (Case)', 10, 45.99),
35
-    createRow('Waste Basket', 2, 17.99),
36
-];
37
-
38
-const invoiceSubtotal = subtotal(rows);
39
-const invoiceTaxes = TAX_RATE * invoiceSubtotal;
40
-const invoiceTotal = invoiceTaxes + invoiceSubtotal;
4
+import { Box, Button } from '@mui/material';
41 5
 
42 6
 export function Resume(props) {
43
-    let {handleBack, password } = props
44
-    console.log("FINAL::", password)
45 7
 
46
-    return (
47
-        <React.Fragment>
48
-            <Typography  variant="h6">
49
-                Resumen:
50
-            </Typography>
51
-            <Divider sx={{paddingTop : 1}}/>
52
-            <TableContainer component={Paper}>
53
-                <Table sx={{ minWidth: 700 }} aria-label="spanning table">
54
-                    <TableBody>
55
-                        {rows.map((row) => (
56
-                            <TableRow key={row.desc}>
57
-                                <TableCell>{row.desc}</TableCell>
58
-                                <TableCell align="right">{row.qty}</TableCell>
59
-                                <TableCell align="right">{row.unit}</TableCell>
60
-                                <TableCell align="right">{ccyFormat(row.price)}</TableCell>
61
-                            </TableRow>
62
-                        ))}
8
+    let {handleBack, password: key } = props
9
+    const fmt = React.useRef({ weekday: 'long', year: 'numeric', month: 'short', day: 'numeric' })
63 10
 
64
-                        <TableRow>
65
-                            <TableCell rowSpan={3} />
66
-                            <TableCell colSpan={2}>Subtotal</TableCell>
67
-                            <TableCell align="right">{ccyFormat(invoiceSubtotal)}</TableCell>
68
-                        </TableRow>
69
-                        <TableRow>
70
-                            <TableCell>Tax</TableCell>
71
-                            <TableCell align="right">{`${(TAX_RATE * 100).toFixed(0)} %`}</TableCell>
72
-                            <TableCell align="right">{ccyFormat(invoiceTaxes)}</TableCell>
73
-                        </TableRow>
74
-                        <TableRow>
75
-                            <TableCell colSpan={2}>Total</TableCell>
76
-                            <TableCell align="right">{ccyFormat(invoiceTotal)}</TableCell>
77
-                        </TableRow>
78
-                    </TableBody>
79
-                </Table>
80
-            </TableContainer>
11
+    return(
12
+        <React.Fragment>
13
+            <Table>
14
+                <thead>
15
+                    <tr>
16
+                        <th>{key.pwd}</th>
17
+                        <th></th>
18
+                    </tr>
19
+                </thead>
20
+                <tbody>
21
+                    <tr>
22
+                        <td>{"Candidato"}</td>
23
+                        <td colSpan={2}>{key.nombres + " " + key.apellidos} - {key.mail}</td>
24
+                    </tr>
25
+                    <tr>
26
+                        <td>{"Puesto"}</td>
27
+                        <td colSpan={2}>{key.puesto[0].nombrepuesto}</td>
28
+                    </tr>
29
+                    <tr>
30
+                        <td>{"Empresa"}</td>
31
+                        <td colSpan={2}>{key.nombreEmpresa}</td>
32
+                    </tr>
33
+                    <tr>
34
+                        <td>{"Fecha Activación"}</td>
35
+                        <td colSpan={2}>{new Date( key.dateToActived ).toLocaleDateString('es-GT',fmt.current )}</td>
36
+                    </tr>
37
+                    <tr>
38
+                        <td>{"Fecha de Vencimiento"}</td>
39
+                        <td colSpan={2}>{new Date( key.deadpwd ).toLocaleDateString('es-GT',fmt.current )}</td>
40
+                    </tr>
41
+                </tbody>
42
+            </Table>
81 43
 
82
-                    <Box sx={{ mb: 2 }}>
83
-                        <div style={{ paddingTop: 15 }}>
84
-                            <Button
85
-                                type="submit"
86
-                                className="registerBtn"
87
-                                variant="contained"
88
-                                sx={{ mt: 1, mr: 1 }}
89
-                            >
90
-                                {'Guardar'}
91
-                            </Button>
92
-                            <Button
93
-                                disabled={false}
94
-                                onClick={handleBack}
95
-                                sx={{ mt: 1, mr: 1 }}
96
-                            >
97
-                                Regresar
98
-                            </Button>
99
-                        </div>
100
-                    </Box>
101 44
 
45
+            <Box sx={{ mb: 2 }}>
46
+                <div style={{ paddingTop: 15 }}>
47
+                    <Button
48
+                        type="submit"
49
+                        className="registerBtn"
50
+                        variant="contained"
51
+                        sx={{ mt: 1, mr: 1 }}
52
+                    >
53
+                        {'Guardar'}
54
+                    </Button>
55
+                    <Button
56
+                        disabled={false}
57
+                        onClick={handleBack}
58
+                        sx={{ mt: 1, mr: 1 }}
59
+                    >
60
+                        Regresar
61
+                    </Button>
62
+                </div>
63
+            </Box>
102 64
         </React.Fragment>
103
-    );
65
+    )
104 66
 }