|
|
@@ -63,6 +63,7 @@ function Candidatos(props) {
|
|
|
}
|
|
|
|
|
|
let user = {
|
|
|
+ 'id': -1,
|
|
|
'nombres': values.nombres,
|
|
|
'apellidos': values.apellidos,
|
|
|
'mail': values.mail,
|
|
|
@@ -127,10 +128,6 @@ function Candidatos(props) {
|
|
|
|
|
|
export function ModalEdit(props) {
|
|
|
|
|
|
- //TODO:
|
|
|
- //se debe crear un objeto de estado que almacena los nuevos cambios de la password
|
|
|
- //enviar por props las utilizades de edicion y eliminar
|
|
|
-
|
|
|
const auth = useSelector((state) => state.token)
|
|
|
let { password, open, handleOpen } = props
|
|
|
let { pwd, plz } = password
|
|
|
@@ -165,7 +162,7 @@ function ModalForm(props) {
|
|
|
|
|
|
let { pwdinfo, closeModal } = props
|
|
|
const auth = useSelector((state) => state.token)
|
|
|
- let [candidatos,setCandidatos] = React.useState([]);
|
|
|
+ let [candidatos, setCandidatos] = React.useState([]);
|
|
|
let [password, setPassword] = React.useState();
|
|
|
const queryClient = useQueryClient()
|
|
|
|
|
|
@@ -195,8 +192,8 @@ function ModalForm(props) {
|
|
|
|
|
|
let json_data = resp;
|
|
|
let mapCandi = resp.data.candidatospwds.map(pwd => {
|
|
|
- let { apellidos, nombre, mail } = pwd.candi
|
|
|
- return { nombres: nombre, apellidos, mail }
|
|
|
+ let { apellidos, nombre, mail,id } = pwd.candi
|
|
|
+ return { nombres: nombre, apellidos, mail, id }
|
|
|
})
|
|
|
|
|
|
json_data.data['candidatospwds'] = mapCandi;
|
|
|
@@ -207,11 +204,8 @@ function ModalForm(props) {
|
|
|
reset({
|
|
|
pwd: password.pwd,
|
|
|
deadpwd: password.deadpwd,
|
|
|
- state: parseInt( password.state ) === 1 ,
|
|
|
+ state: parseInt(password.state) === 1,
|
|
|
dateToActived: password.dateToActived,
|
|
|
- // id: password.id,
|
|
|
- // link: password.link,
|
|
|
- // plaza_id: password.plaza_id,
|
|
|
})
|
|
|
|
|
|
})
|
|
|
@@ -219,9 +213,23 @@ function ModalForm(props) {
|
|
|
|
|
|
}, [auth.token, pwdinfo, reset])
|
|
|
|
|
|
+ const saveCandidato = async (body) => {
|
|
|
+ let rest = new Service('/passwordcandidato/candidato')
|
|
|
+ return await rest.postQuery(body, auth.token)
|
|
|
+ }
|
|
|
|
|
|
|
|
|
function onSubmit(fields) {
|
|
|
+
|
|
|
+ let candi_body = candidatos.map( c => {
|
|
|
+ return {...c,
|
|
|
+ 'nombrepuesto': 'test',
|
|
|
+ 'nombreEmpresa' : 'dit',
|
|
|
+ "idContrasenia" : password.id,
|
|
|
+ "sendmail": 1,
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
let rest = new Service('/contrasenia/create');
|
|
|
let { deadpwd, dateToActived, pwd, state } = fields
|
|
|
|
|
|
@@ -229,7 +237,7 @@ function ModalForm(props) {
|
|
|
fields['deadpwd'] = new Date(deadpwd).toISOString();
|
|
|
fields['dateToActived'] = new Date(dateToActived).toISOString();
|
|
|
fields['link'] = 'www.psicoadmin.ditaca.org'
|
|
|
- fields['state'] = state ? 1: 0
|
|
|
+ fields['state'] = state ? 1 : 0
|
|
|
delete password['candidato_id'];
|
|
|
delete password['tokensecurity'];
|
|
|
delete password['candidatospwds'];
|
|
|
@@ -239,9 +247,12 @@ function ModalForm(props) {
|
|
|
}
|
|
|
|
|
|
rest.putQuery(body_req, auth.token)
|
|
|
- .then(result => {
|
|
|
- console.log('result: ', result)
|
|
|
+ .then( async result => {
|
|
|
queryClient.invalidateQueries('passwords')
|
|
|
+
|
|
|
+ //TODO: insert into passwordcanidato/candidato
|
|
|
+ await saveCandidato(candi_body)
|
|
|
+
|
|
|
setTimeout(() => {
|
|
|
closeModal(false)
|
|
|
}, 1000)
|
|
|
@@ -279,24 +290,22 @@ function ModalForm(props) {
|
|
|
/>
|
|
|
|
|
|
<Stack direction={{ xs: 'column', sm: 'row' }} spacing={2}>
|
|
|
-
|
|
|
<TextField
|
|
|
- value={ password ? atob(password.pwd ) : ""}
|
|
|
+ value={password ? atob(password.pwd) : ""}
|
|
|
type="text"
|
|
|
disabled
|
|
|
/>
|
|
|
-
|
|
|
<FormControlLabel
|
|
|
label="Activo?"
|
|
|
control={
|
|
|
<Controller
|
|
|
name="state"
|
|
|
control={control}
|
|
|
- render={({field:props}) =>
|
|
|
+ render={({ field: props }) =>
|
|
|
<Checkbox
|
|
|
style={{ color: 'var(--main)' }}
|
|
|
checked={props.value}
|
|
|
- onChange={(e) => props.onChange(e.target.checked) }
|
|
|
+ onChange={(e) => props.onChange(e.target.checked)}
|
|
|
/>
|
|
|
}
|
|
|
/>
|