Browse Source

resume step

amenpunk 2 years ago
parent
commit
55adc058e6

+ 5 - 0
src/App.css

259
     padding-top : 25px !important;
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
 
3
 
4
 export const AuthContext = React.createContext(null);
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
     const context = {
10
     const context = {
12
         user,
11
         user,
13
         login: (token) => {
12
         login: (token) => {
14
-            try{
15
-                Cookies.set('token', token, { expires : 7 })
13
+            try {
14
+                Cookies.set('token', token, { expires: 7 })
16
                 setUser(Cookies.get('token'))
15
                 setUser(Cookies.get('token'))
17
-            }catch(e){
16
+            } catch (e) {
18
                 console.log('Login Error >> ', e)
17
                 console.log('Login Error >> ', e)
19
                 Cookies.set('token', undefined)
18
                 Cookies.set('token', undefined)
20
             }
19
             }
21
         },
20
         },
22
-        logout : () => {
21
+        logout: () => {
23
             Cookies.set('token', undefined)
22
             Cookies.set('token', undefined)
24
             setUser(undefined)
23
             setUser(undefined)
25
         },
24
         },
26
-        getToken : () => Cookies.get('token'),
27
-        isLogged : () => {
28
-            try{
25
+        getToken: () => Cookies.get('token'),
26
+        isLogged: () => {
27
+            try {
29
                 let CookiesUser = Cookies.get('token')
28
                 let CookiesUser = Cookies.get('token')
30
-                if(!CookiesUser || CookiesUser === 'undefined'){
29
+                if (!CookiesUser || CookiesUser === 'undefined') {
31
                     return false
30
                     return false
32
                 }
31
                 }
33
                 // TODO   
32
                 // TODO   
34
                 // add an method implmentation for 
33
                 // add an method implmentation for 
35
                 // check if cockie jwt is valid
34
                 // check if cockie jwt is valid
36
-                let logged = CookiesUser.length > 5 
35
+                let logged = CookiesUser.length > 5
37
                 console.log("is login? >>", logged)
36
                 console.log("is login? >>", logged)
38
                 return logged
37
                 return logged
39
 
38
 
40
-            }catch(e){
39
+            } catch (e) {
41
                 console.log("Error checking user ", e)
40
                 console.log("Error checking user ", e)
42
                 return false
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
     return (
48
     return (

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

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

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

7
     Stack, TextField, FormGroup,
7
     Stack, TextField, FormGroup,
8
 } from '@mui/material';
8
 } from '@mui/material';
9
 
9
 
10
+import useAuth from '../../../Auth/useAuth';
11
+
10
 
12
 
11
 export function Candidato(props) {
13
 export function Candidato(props) {
12
 
14
 
15
+    const auth = useAuth();
16
+
13
     const CandidatoSchema = Yup.object().shape({
17
     const CandidatoSchema = Yup.object().shape({
14
         nombres:
18
         nombres:
15
             Yup.string()
19
             Yup.string()
43
             apellidos: password.apellidos,
47
             apellidos: password.apellidos,
44
             sendmail: password.sendmail,
48
             sendmail: password.sendmail,
45
             mail : password.mail,
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
         onSubmit: (fields) => {
53
         onSubmit: (fields) => {
50
             setPassword({ ...password, ...fields })
54
             setPassword({ ...password, ...fields })

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

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

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

1
 import * as React from 'react';
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
 export function Resume(props) {
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
         </React.Fragment>
64
         </React.Fragment>
103
-    );
65
+    )
104
 }
66
 }