|
@@ -63,6 +63,7 @@ function Candidatos(props) {
|
63
|
63
|
}
|
64
|
64
|
|
65
|
65
|
let user = {
|
|
66
|
+ 'id': -1,
|
66
|
67
|
'nombres': values.nombres,
|
67
|
68
|
'apellidos': values.apellidos,
|
68
|
69
|
'mail': values.mail,
|
|
@@ -127,10 +128,6 @@ function Candidatos(props) {
|
127
|
128
|
|
128
|
129
|
export function ModalEdit(props) {
|
129
|
130
|
|
130
|
|
- //TODO:
|
131
|
|
- //se debe crear un objeto de estado que almacena los nuevos cambios de la password
|
132
|
|
- //enviar por props las utilizades de edicion y eliminar
|
133
|
|
-
|
134
|
131
|
const auth = useSelector((state) => state.token)
|
135
|
132
|
let { password, open, handleOpen } = props
|
136
|
133
|
let { pwd, plz } = password
|
|
@@ -165,7 +162,7 @@ function ModalForm(props) {
|
165
|
162
|
|
166
|
163
|
let { pwdinfo, closeModal } = props
|
167
|
164
|
const auth = useSelector((state) => state.token)
|
168
|
|
- let [candidatos,setCandidatos] = React.useState([]);
|
|
165
|
+ let [candidatos, setCandidatos] = React.useState([]);
|
169
|
166
|
let [password, setPassword] = React.useState();
|
170
|
167
|
const queryClient = useQueryClient()
|
171
|
168
|
|
|
@@ -195,8 +192,8 @@ function ModalForm(props) {
|
195
|
192
|
|
196
|
193
|
let json_data = resp;
|
197
|
194
|
let mapCandi = resp.data.candidatospwds.map(pwd => {
|
198
|
|
- let { apellidos, nombre, mail } = pwd.candi
|
199
|
|
- return { nombres: nombre, apellidos, mail }
|
|
195
|
+ let { apellidos, nombre, mail,id } = pwd.candi
|
|
196
|
+ return { nombres: nombre, apellidos, mail, id }
|
200
|
197
|
})
|
201
|
198
|
|
202
|
199
|
json_data.data['candidatospwds'] = mapCandi;
|
|
@@ -207,11 +204,8 @@ function ModalForm(props) {
|
207
|
204
|
reset({
|
208
|
205
|
pwd: password.pwd,
|
209
|
206
|
deadpwd: password.deadpwd,
|
210
|
|
- state: parseInt( password.state ) === 1 ,
|
|
207
|
+ state: parseInt(password.state) === 1,
|
211
|
208
|
dateToActived: password.dateToActived,
|
212
|
|
- // id: password.id,
|
213
|
|
- // link: password.link,
|
214
|
|
- // plaza_id: password.plaza_id,
|
215
|
209
|
})
|
216
|
210
|
|
217
|
211
|
})
|
|
@@ -219,9 +213,23 @@ function ModalForm(props) {
|
219
|
213
|
|
220
|
214
|
}, [auth.token, pwdinfo, reset])
|
221
|
215
|
|
|
216
|
+ const saveCandidato = async (body) => {
|
|
217
|
+ let rest = new Service('/passwordcandidato/candidato')
|
|
218
|
+ return await rest.postQuery(body, auth.token)
|
|
219
|
+ }
|
222
|
220
|
|
223
|
221
|
|
224
|
222
|
function onSubmit(fields) {
|
|
223
|
+
|
|
224
|
+ let candi_body = candidatos.map( c => {
|
|
225
|
+ return {...c,
|
|
226
|
+ 'nombrepuesto': 'test',
|
|
227
|
+ 'nombreEmpresa' : 'dit',
|
|
228
|
+ "idContrasenia" : password.id,
|
|
229
|
+ "sendmail": 1,
|
|
230
|
+ }
|
|
231
|
+ })
|
|
232
|
+
|
225
|
233
|
let rest = new Service('/contrasenia/create');
|
226
|
234
|
let { deadpwd, dateToActived, pwd, state } = fields
|
227
|
235
|
|
|
@@ -229,7 +237,7 @@ function ModalForm(props) {
|
229
|
237
|
fields['deadpwd'] = new Date(deadpwd).toISOString();
|
230
|
238
|
fields['dateToActived'] = new Date(dateToActived).toISOString();
|
231
|
239
|
fields['link'] = 'www.psicoadmin.ditaca.org'
|
232
|
|
- fields['state'] = state ? 1: 0
|
|
240
|
+ fields['state'] = state ? 1 : 0
|
233
|
241
|
delete password['candidato_id'];
|
234
|
242
|
delete password['tokensecurity'];
|
235
|
243
|
delete password['candidatospwds'];
|
|
@@ -239,9 +247,12 @@ function ModalForm(props) {
|
239
|
247
|
}
|
240
|
248
|
|
241
|
249
|
rest.putQuery(body_req, auth.token)
|
242
|
|
- .then(result => {
|
243
|
|
- console.log('result: ', result)
|
|
250
|
+ .then( async result => {
|
244
|
251
|
queryClient.invalidateQueries('passwords')
|
|
252
|
+
|
|
253
|
+ //TODO: insert into passwordcanidato/candidato
|
|
254
|
+ await saveCandidato(candi_body)
|
|
255
|
+
|
245
|
256
|
setTimeout(() => {
|
246
|
257
|
closeModal(false)
|
247
|
258
|
}, 1000)
|
|
@@ -279,24 +290,22 @@ function ModalForm(props) {
|
279
|
290
|
/>
|
280
|
291
|
|
281
|
292
|
<Stack direction={{ xs: 'column', sm: 'row' }} spacing={2}>
|
282
|
|
-
|
283
|
293
|
<TextField
|
284
|
|
- value={ password ? atob(password.pwd ) : ""}
|
|
294
|
+ value={password ? atob(password.pwd) : ""}
|
285
|
295
|
type="text"
|
286
|
296
|
disabled
|
287
|
297
|
/>
|
288
|
|
-
|
289
|
298
|
<FormControlLabel
|
290
|
299
|
label="Activo?"
|
291
|
300
|
control={
|
292
|
301
|
<Controller
|
293
|
302
|
name="state"
|
294
|
303
|
control={control}
|
295
|
|
- render={({field:props}) =>
|
|
304
|
+ render={({ field: props }) =>
|
296
|
305
|
<Checkbox
|
297
|
306
|
style={{ color: 'var(--main)' }}
|
298
|
307
|
checked={props.value}
|
299
|
|
- onChange={(e) => props.onChange(e.target.checked) }
|
|
308
|
+ onChange={(e) => props.onChange(e.target.checked)}
|
300
|
309
|
/>
|
301
|
310
|
}
|
302
|
311
|
/>
|