|
@@ -80,16 +80,20 @@ function Candidatos(props) {
|
80
|
80
|
|
81
|
81
|
return (
|
82
|
82
|
<FormikProvider style={{ padding: 25 }} value={formik}>
|
83
|
|
- <Typography style={{ padding: !home? 5: 0, marginBottom: !home? 15: 0 }}>
|
84
|
|
- { home ? "": "Ingresa la informacion del candidato" }
|
|
83
|
+ <Typography style={{ padding: !home ? 5 : 0, marginBottom: !home ? 15 : 0 }}>
|
|
84
|
+ {home ? "" : "Ingresa la informacion del candidato"}
|
85
|
85
|
</Typography>
|
86
|
86
|
<Divider />
|
87
|
87
|
<Form autoComplete="off" noValidate onSubmit={handleSubmit}>
|
88
|
88
|
<Stack spacing={3}>
|
89
|
89
|
|
90
|
|
- <Stack style={{ paddingTop:!home? 15 :0, background:'' }} direction={{ xs: 'column', sm: 'row' }} spacing={2}>
|
|
90
|
+ <Stack
|
|
91
|
+ style={{ paddingTop: !home ? 15 : 0, paddingBottom: !home ? 15 : 0 }}
|
|
92
|
+ direction={{ xs: 'column', sm: 'row' }}
|
|
93
|
+ spacing={2}>
|
|
94
|
+
|
91
|
95
|
<TextField
|
92
|
|
- style={{ display: home ?'none': 'block',background:'' }}
|
|
96
|
+ style={{ display: home ? 'none' : 'block', background: '' }}
|
93
|
97
|
label="Nombre"
|
94
|
98
|
{...getFieldProps('nombres')}
|
95
|
99
|
error={Boolean(touched.nombres && errors.nombres)}
|
|
@@ -97,7 +101,7 @@ function Candidatos(props) {
|
97
|
101
|
/>
|
98
|
102
|
|
99
|
103
|
<TextField
|
100
|
|
- style={{ display: home ?'none': 'block' }}
|
|
104
|
+ style={{ display: home ? 'none' : 'block' }}
|
101
|
105
|
label="Apellidos"
|
102
|
106
|
{...getFieldProps('apellidos')}
|
103
|
107
|
error={Boolean(touched.apellidos && errors.apellidos)}
|
|
@@ -105,9 +109,9 @@ function Candidatos(props) {
|
105
|
109
|
/>
|
106
|
110
|
</Stack>
|
107
|
111
|
|
108
|
|
- <Stack style={{ marginTop:0}} direction={{ xs: 'column', sm: 'row' }} spacing={2}>
|
|
112
|
+ <Stack direction={{ xs: 'column', sm: 'row' }} >
|
109
|
113
|
<TextField
|
110
|
|
- style={{ display: home ?'none': 'block' }}
|
|
114
|
+ style={{ display: home ? 'none' : 'block' }}
|
111
|
115
|
fullWidth
|
112
|
116
|
type="email"
|
113
|
117
|
label="Correo Electronico"
|
|
@@ -169,7 +173,7 @@ export function Loading() {
|
169
|
173
|
|
170
|
174
|
function ModalForm(props) {
|
171
|
175
|
|
172
|
|
- let { pwdinfo, closeModal,home } = props
|
|
176
|
+ let { pwdinfo, closeModal, home } = props
|
173
|
177
|
const auth = useSelector((state) => state.token)
|
174
|
178
|
let [candidatos, setCandidatos] = React.useState([]);
|
175
|
179
|
let [password, setPassword] = React.useState();
|
|
@@ -194,8 +198,6 @@ function ModalForm(props) {
|
194
|
198
|
|
195
|
199
|
React.useEffect(() => {
|
196
|
200
|
let { pwd, plz } = pwdinfo;
|
197
|
|
- console.log('PWDINOF',{pwd,plz})
|
198
|
|
-
|
199
|
201
|
let rest = new Service(`/contrasenia/${home ? pwd : btoa(pwd)}/${plz}`)
|
200
|
202
|
|
201
|
203
|
rest.getQuery(auth.token)
|
|
@@ -203,7 +205,7 @@ function ModalForm(props) {
|
203
|
205
|
|
204
|
206
|
let json_data = resp;
|
205
|
207
|
let mapCandi = resp.data.candidatospwds.map(pwd => {
|
206
|
|
- let { apellidos, nombre, mail,id } = pwd.candi
|
|
208
|
+ let { apellidos, nombre, mail, id } = pwd.candi
|
207
|
209
|
return { nombres: nombre, apellidos, mail, id }
|
208
|
210
|
})
|
209
|
211
|
|
|
@@ -222,7 +224,7 @@ function ModalForm(props) {
|
222
|
224
|
})
|
223
|
225
|
.catch(error => console.log(error))
|
224
|
226
|
|
225
|
|
- }, [auth.token, pwdinfo, reset,home])
|
|
227
|
+ }, [auth.token, pwdinfo, reset, home])
|
226
|
228
|
|
227
|
229
|
const saveCandidato = async (body) => {
|
228
|
230
|
let rest = new Service('/passwordcandidato/candidato')
|
|
@@ -231,11 +233,12 @@ function ModalForm(props) {
|
231
|
233
|
|
232
|
234
|
function onSubmit(fields) {
|
233
|
235
|
|
234
|
|
- let candi_body = candidatos.map( c => {
|
235
|
|
- return {...c,
|
|
236
|
+ let candi_body = candidatos.map(c => {
|
|
237
|
+ return {
|
|
238
|
+ ...c,
|
236
|
239
|
'nombrepuesto': 'test',
|
237
|
|
- 'nombreEmpresa' : 'dit',
|
238
|
|
- "idContrasenia" : password.id,
|
|
240
|
+ 'nombreEmpresa': 'dit',
|
|
241
|
+ "idContrasenia": password.id,
|
239
|
242
|
"sendmail": 1,
|
240
|
243
|
}
|
241
|
244
|
})
|
|
@@ -257,10 +260,9 @@ function ModalForm(props) {
|
257
|
260
|
}
|
258
|
261
|
|
259
|
262
|
rest.putQuery(body_req, auth.token)
|
260
|
|
- .then( async _result => {
|
261
|
|
- queryClient.invalidateQueries('passwords')
|
|
263
|
+ .then(async _result => {
|
262
|
264
|
|
263
|
|
- //TODO: insert into passwordcanidato/candidato
|
|
265
|
+ queryClient.invalidateQueries('passwords')
|
264
|
266
|
await saveCandidato(candi_body)
|
265
|
267
|
|
266
|
268
|
setTimeout(() => {
|
|
@@ -287,16 +289,18 @@ function ModalForm(props) {
|
287
|
289
|
|
288
|
290
|
return (
|
289
|
291
|
<Row>
|
290
|
|
- <Col>
|
291
|
|
- <form style={{ padding: !home? 20: 0, maxWidth: 950 }} onSubmit={handleSubmit(onSubmit)}>
|
|
292
|
+ <Col >
|
|
293
|
+ <form style={{ padding: !home ? 20 : 0, maxWidth: 950 }} onSubmit={handleSubmit(onSubmit)}>
|
292
|
294
|
<Stack spacing={4}>
|
293
|
295
|
|
294
|
296
|
<TextField
|
295
|
297
|
{...register('pwd')}
|
296
|
298
|
variant="filled"
|
297
|
|
- disabled
|
298
|
299
|
type="text"
|
299
|
300
|
label="Contraseña Cifrada"
|
|
301
|
+ InputProps={{
|
|
302
|
+ readOnly: home
|
|
303
|
+ }}
|
300
|
304
|
/>
|
301
|
305
|
|
302
|
306
|
<Stack direction={{ xs: 'column', sm: 'row' }} spacing={2}>
|
|
@@ -306,11 +310,13 @@ function ModalForm(props) {
|
306
|
310
|
variant="filled"
|
307
|
311
|
value={password ? atob(password.pwd) : ""}
|
308
|
312
|
type="text"
|
309
|
|
- disabled
|
|
313
|
+ InputProps={{
|
|
314
|
+ readOnly: home
|
|
315
|
+ }}
|
310
|
316
|
/>
|
311
|
317
|
|
312
|
318
|
{
|
313
|
|
- !home ?
|
|
319
|
+ !home ?
|
314
|
320
|
<FormControlLabel
|
315
|
321
|
label="Activo?"
|
316
|
322
|
control={
|
|
@@ -378,7 +384,7 @@ function ModalForm(props) {
|
378
|
384
|
</Controller>
|
379
|
385
|
</LocalizationProvider>
|
380
|
386
|
|
381
|
|
- { !home?
|
|
387
|
+ {!home ?
|
382
|
388
|
<DialogActions style={{ paddingTop: 25, 'justifyContent': "flex-start" }}>
|
383
|
389
|
<Button onClick={() => closeModal(false)}>
|
384
|
390
|
Cerrar
|
|
@@ -386,16 +392,16 @@ function ModalForm(props) {
|
386
|
392
|
<Button type="submit" style={{ color: 'white', background: 'var(--main)' }} >
|
387
|
393
|
Guardar
|
388
|
394
|
</Button>
|
389
|
|
- </DialogActions> :
|
|
395
|
+ </DialogActions> :
|
390
|
396
|
|
391
|
|
- <DialogActions
|
|
397
|
+ <DialogActions
|
392
|
398
|
style={{
|
393
|
399
|
justifyContent: "flex-start",
|
394
|
400
|
}} >
|
395
|
|
- <Button onClick={() => {
|
|
401
|
+ <Button onClick={() => {
|
396
|
402
|
console.log('close modal')
|
397
|
403
|
console.log(closeModal)
|
398
|
|
- closeModal(true)
|
|
404
|
+ closeModal(true)
|
399
|
405
|
}}>
|
400
|
406
|
Cerrar
|
401
|
407
|
</Button>
|
|
@@ -407,7 +413,7 @@ function ModalForm(props) {
|
407
|
413
|
</form>
|
408
|
414
|
<Toaster position="bottom-right" />
|
409
|
415
|
</Col>
|
410
|
|
- <Col>
|
|
416
|
+ <Col >
|
411
|
417
|
<Candidatos
|
412
|
418
|
home={home}
|
413
|
419
|
add={addCandidato}
|