|
@@ -2,8 +2,8 @@ import * as React from 'react';
|
2
|
2
|
|
3
|
3
|
import { Table } from 'react-bootstrap';
|
4
|
4
|
import {
|
5
|
|
- Box, Button, LinearProgress,
|
6
|
|
- Backdrop, CircularProgress
|
|
5
|
+ Box, Button, LinearProgress,
|
|
6
|
+ Backdrop, CircularProgress
|
7
|
7
|
} from '@mui/material';
|
8
|
8
|
|
9
|
9
|
import toast, { Toaster } from 'react-hot-toast';
|
|
@@ -15,25 +15,26 @@ import { useSelector } from 'react-redux';
|
15
|
15
|
import { createTheme, ThemeProvider } from '@mui/material/styles';
|
16
|
16
|
|
17
|
17
|
let theme = createTheme({
|
18
|
|
- status: {
|
19
|
|
- success: '#fd4b4b'
|
|
18
|
+ status: {
|
|
19
|
+ success: '#fd4b4b'
|
|
20
|
+ },
|
|
21
|
+ palette: {
|
|
22
|
+ primary: {
|
|
23
|
+ main: '#fd4b4b',
|
20
|
24
|
},
|
21
|
|
- palette: {
|
22
|
|
- primary: {
|
23
|
|
- main: '#fd4b4b',
|
24
|
|
- },
|
25
|
|
- secondary: {
|
26
|
|
- main: '#fd4b4b',
|
27
|
|
- },
|
|
25
|
+ secondary: {
|
|
26
|
+ main: '#fd4b4b',
|
28
|
27
|
},
|
|
28
|
+ },
|
29
|
29
|
});
|
30
|
30
|
|
31
|
31
|
export function Resume(props) {
|
32
|
32
|
|
33
|
|
- let { handleBack, password: key, handleClose,handleReset } = props
|
|
33
|
+ let { handleBack, password: key, handleClose, handleReset } = props
|
|
34
|
+
|
|
35
|
+ console.log(key)
|
34
|
36
|
|
35
|
37
|
const fmt = React.useRef({ weekday: 'long', year: 'numeric', month: 'short', day: 'numeric' })
|
36
|
|
- const [pwdID, setPwdID] = React.useState(null);
|
37
|
38
|
const [loading, setLoading] = React.useState(false);
|
38
|
39
|
|
39
|
40
|
const auth = useSelector((state) => state.token)
|
|
@@ -52,62 +53,71 @@ export function Resume(props) {
|
52
|
53
|
|
53
|
54
|
const pwdMutation = useMutation('password', savePassword);
|
54
|
55
|
const candiMutation = useMutation('candidato', saveCandidato);
|
|
56
|
+ console.log(candiMutation)
|
55
|
57
|
|
56
|
58
|
const saveStepper = () => {
|
57
|
59
|
|
58
|
60
|
setLoading(true);
|
59
|
61
|
|
60
|
|
- let {
|
61
|
|
- deadpwd, dateToActived, puesto,
|
62
|
|
- pwd,nombreEmpresa,nombrepuesto, candidatos
|
63
|
|
- } = key;
|
|
62
|
+ let { deadpwd, dateToActived } = key;
|
64
|
63
|
|
65
|
64
|
let pwdBody = {
|
66
|
65
|
id: -1,
|
67
|
|
- pwd: btoa(pwd),
|
|
66
|
+ pwd: btoa(key.pwd),
|
68
|
67
|
link: "www.psicoadmin.com",
|
69
|
68
|
deadpwd: new Date(deadpwd).toISOString(),
|
70
|
69
|
state: 1,
|
71
|
70
|
dateToActived: new Date(dateToActived).toISOString(),
|
72
|
|
- plaza_id: puesto[0].id
|
|
71
|
+ plaza_id: key.puesto[0].id
|
73
|
72
|
}
|
74
|
73
|
|
|
74
|
+ console.log("PWD BODY: ", pwdBody)
|
|
75
|
+
|
75
|
76
|
pwdMutation.mutate(pwdBody, {
|
76
|
|
- onSuccess: (data) => {
|
77
|
|
-
|
78
|
|
- let { id: password_id } = data.data;
|
79
|
|
- setPwdID(password_id);
|
80
|
|
-
|
81
|
|
- let candidatoBody = {
|
82
|
|
- id: -1,
|
83
|
|
- //nombres,
|
84
|
|
- //apellidos,
|
85
|
|
- //sendmail: sendmail ? 1 : 0,
|
86
|
|
- //mail,
|
87
|
|
- idContrasenia: password_id,
|
88
|
|
- nombrepuesto,
|
89
|
|
- nombreEmpresa
|
90
|
|
- }
|
91
|
|
-
|
92
|
|
- candiMutation.mutate(candidatoBody, {
|
93
|
|
- onSuccess: (data) => {
|
|
77
|
+ onSuccess: (result) => {
|
|
78
|
+
|
|
79
|
+ let { id: idContrasenia } = result.data;
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+ let candidatos_body = key.candidatos.map((candi) => ({
|
|
83
|
+ "id": -1,
|
|
84
|
+ "nombres": candi.nombres,
|
|
85
|
+ "apellidos": candi.apellidos,
|
|
86
|
+ "mail": candi.mail,
|
|
87
|
+ "sendmail": 0,
|
|
88
|
+ "idContrasenia": idContrasenia,
|
|
89
|
+ "nombrepuesto": 'Senior Software',
|
|
90
|
+ "nombreEmpresa": 'Google'
|
|
91
|
+ }))
|
|
92
|
+
|
|
93
|
+ console.log(candidatos_body)
|
|
94
|
+
|
|
95
|
+ // setLoading(false);
|
|
96
|
+ // return;
|
94
|
97
|
|
|
98
|
+ queryClient.invalidateQueries('passwords')
|
|
99
|
+ setLoading(false);
|
|
100
|
+ handleClose();
|
|
101
|
+ handleReset();
|
|
102
|
+ /*
|
|
103
|
+
|
|
104
|
+ candiMutation.mutate(candidatos_body, {
|
|
105
|
+ onSuccess: (data) => {
|
95
|
106
|
queryClient.invalidateQueries('passwords')
|
96
|
107
|
toast.success("Contraseña agregada exitosamente!!")
|
97
|
108
|
setTimeout(() => {
|
98
|
|
- console.log("OK LETS GO >> ", data,pwdID)
|
|
109
|
+ console.log("OK LETS GO >> ", data)
|
99
|
110
|
setLoading(false);
|
100
|
111
|
handleClose();
|
101
|
112
|
handleReset();
|
102
|
113
|
}, 1000)
|
103
|
|
-
|
104
|
114
|
},
|
105
|
115
|
onError: () => {
|
106
|
116
|
toast.error("Ups!! error al crear el candidato")
|
107
|
117
|
setLoading(false);
|
108
|
118
|
}
|
109
|
119
|
})
|
110
|
|
-
|
|
120
|
+*/
|
111
|
121
|
|
112
|
122
|
},
|
113
|
123
|
onError: () => {
|
|
@@ -118,13 +128,13 @@ export function Resume(props) {
|
118
|
128
|
})
|
119
|
129
|
}
|
120
|
130
|
|
121
|
|
- const getLi = (user) => {
|
122
|
|
- return (
|
123
|
|
- <li style={{ listStyleType: 'none'}}>
|
|
131
|
+ const getLi = (user, i) => {
|
|
132
|
+ return (
|
|
133
|
+ <li key={i} style={{ listStyleType: 'none' }}>
|
124
|
134
|
{user.nombres + " " + user.apellidos} - {user.mail}
|
125
|
|
- </li>
|
|
135
|
+ </li>
|
126
|
136
|
)
|
127
|
|
- }
|
|
137
|
+ }
|
128
|
138
|
|
129
|
139
|
return (
|
130
|
140
|
<React.Fragment>
|
|
@@ -138,17 +148,17 @@ export function Resume(props) {
|
138
|
148
|
<thead>
|
139
|
149
|
<tr className="table_password">
|
140
|
150
|
<th>{"Contraseña: "}</th>
|
141
|
|
- <th>{ key.pwd } - {btoa(key.pwd)}</th>
|
|
151
|
+ <th>{key.pwd} - {btoa(key.pwd)}</th>
|
142
|
152
|
</tr>
|
143
|
153
|
</thead>
|
144
|
154
|
<tbody>
|
145
|
155
|
<tr>
|
146
|
156
|
<td className="title_td">{"Candidatos:"}</td>
|
147
|
157
|
<td colSpan={2}>
|
148
|
|
- <ul style={{ margin:0, padding:0}}>
|
149
|
|
- {key.candidatos.map(u => getLi(u))}
|
|
158
|
+ <ul style={{ margin: 0, padding: 0 }}>
|
|
159
|
+ {key.candidatos ? key.candidatos.map((u, i) => getLi(u, i)) : null}
|
150
|
160
|
</ul>
|
151
|
|
- </td>
|
|
161
|
+ </td>
|
152
|
162
|
</tr>
|
153
|
163
|
<tr>
|
154
|
164
|
<td className="title_td">{"Puesto:"}</td>
|