|
@@ -44,7 +44,7 @@ function Candidatos(props) {
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
- let { candidatos, add, remove } = props
|
|
|
|
|
|
|
+ let { candidatos, add, remove, home } = props
|
|
|
|
|
|
|
|
const formik = useFormik({
|
|
const formik = useFormik({
|
|
|
initialValues: {
|
|
initialValues: {
|
|
@@ -80,12 +80,16 @@ function Candidatos(props) {
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
|
<FormikProvider style={{ padding: 25 }} value={formik}>
|
|
<FormikProvider style={{ padding: 25 }} value={formik}>
|
|
|
- <Typography style={{ padding: 5, marginBottom: 15 }}>Ingresa la informacion del candidato</Typography>
|
|
|
|
|
|
|
+ <Typography style={{ padding: !home? 5: 0, marginBottom: !home? 15: 0 }}>
|
|
|
|
|
+ { home ? "": "Ingresa la informacion del candidato" }
|
|
|
|
|
+ </Typography>
|
|
|
<Divider />
|
|
<Divider />
|
|
|
<Form autoComplete="off" noValidate onSubmit={handleSubmit}>
|
|
<Form autoComplete="off" noValidate onSubmit={handleSubmit}>
|
|
|
<Stack spacing={3}>
|
|
<Stack spacing={3}>
|
|
|
- <Stack style={{ paddingTop: 15 }} direction={{ xs: 'column', sm: 'row' }} spacing={2}>
|
|
|
|
|
|
|
+
|
|
|
|
|
+ <Stack style={{ paddingTop:!home? 15 :0, background:'' }} direction={{ xs: 'column', sm: 'row' }} spacing={2}>
|
|
|
<TextField
|
|
<TextField
|
|
|
|
|
+ style={{ display: home ?'none': 'block',background:'' }}
|
|
|
label="Nombre"
|
|
label="Nombre"
|
|
|
{...getFieldProps('nombres')}
|
|
{...getFieldProps('nombres')}
|
|
|
error={Boolean(touched.nombres && errors.nombres)}
|
|
error={Boolean(touched.nombres && errors.nombres)}
|
|
@@ -93,6 +97,7 @@ function Candidatos(props) {
|
|
|
/>
|
|
/>
|
|
|
|
|
|
|
|
<TextField
|
|
<TextField
|
|
|
|
|
+ style={{ display: home ?'none': 'block' }}
|
|
|
label="Apellidos"
|
|
label="Apellidos"
|
|
|
{...getFieldProps('apellidos')}
|
|
{...getFieldProps('apellidos')}
|
|
|
error={Boolean(touched.apellidos && errors.apellidos)}
|
|
error={Boolean(touched.apellidos && errors.apellidos)}
|
|
@@ -100,8 +105,9 @@ function Candidatos(props) {
|
|
|
/>
|
|
/>
|
|
|
</Stack>
|
|
</Stack>
|
|
|
|
|
|
|
|
- <Stack direction={{ xs: 'column', sm: 'row' }} spacing={2}>
|
|
|
|
|
|
|
+ <Stack style={{ marginTop:0}} direction={{ xs: 'column', sm: 'row' }} spacing={2}>
|
|
|
<TextField
|
|
<TextField
|
|
|
|
|
+ style={{ display: home ?'none': 'block' }}
|
|
|
fullWidth
|
|
fullWidth
|
|
|
type="email"
|
|
type="email"
|
|
|
label="Correo Electronico"
|
|
label="Correo Electronico"
|
|
@@ -110,13 +116,14 @@ function Candidatos(props) {
|
|
|
helperText={touched.mail && errors.mail}
|
|
helperText={touched.mail && errors.mail}
|
|
|
/>
|
|
/>
|
|
|
|
|
|
|
|
- <Button type="submit">
|
|
|
|
|
|
|
+ <Button hidden={home} type="submit">
|
|
|
<AddCircle style={{ color: 'var(--main)' }} />
|
|
<AddCircle style={{ color: 'var(--main)' }} />
|
|
|
</Button>
|
|
</Button>
|
|
|
|
|
|
|
|
</Stack>
|
|
</Stack>
|
|
|
|
|
|
|
|
<MailTable
|
|
<MailTable
|
|
|
|
|
+ home={home}
|
|
|
remove={remove}
|
|
remove={remove}
|
|
|
users={candidatos}
|
|
users={candidatos}
|
|
|
/>
|
|
/>
|
|
@@ -130,7 +137,7 @@ function Candidatos(props) {
|
|
|
export function ModalEdit(props) {
|
|
export function ModalEdit(props) {
|
|
|
|
|
|
|
|
const auth = useSelector((state) => state.token)
|
|
const auth = useSelector((state) => state.token)
|
|
|
- let { password, open, handleOpen } = props
|
|
|
|
|
|
|
+ let { password, open, handleOpen, home } = props
|
|
|
let { pwd, plz } = password
|
|
let { pwd, plz } = password
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
@@ -144,6 +151,7 @@ export function ModalEdit(props) {
|
|
|
>
|
|
>
|
|
|
<DialogContent>
|
|
<DialogContent>
|
|
|
<ModalForm
|
|
<ModalForm
|
|
|
|
|
+ home={home}
|
|
|
pwdinfo={{ pwd, plz }}
|
|
pwdinfo={{ pwd, plz }}
|
|
|
closeModal={handleOpen}
|
|
closeModal={handleOpen}
|
|
|
token={auth.token}
|
|
token={auth.token}
|
|
@@ -161,7 +169,7 @@ export function Loading() {
|
|
|
|
|
|
|
|
function ModalForm(props) {
|
|
function ModalForm(props) {
|
|
|
|
|
|
|
|
- let { pwdinfo, closeModal } = props
|
|
|
|
|
|
|
+ let { pwdinfo, closeModal,home } = props
|
|
|
const auth = useSelector((state) => state.token)
|
|
const auth = useSelector((state) => state.token)
|
|
|
let [candidatos, setCandidatos] = React.useState([]);
|
|
let [candidatos, setCandidatos] = React.useState([]);
|
|
|
let [password, setPassword] = React.useState();
|
|
let [password, setPassword] = React.useState();
|
|
@@ -186,8 +194,10 @@ function ModalForm(props) {
|
|
|
|
|
|
|
|
React.useEffect(() => {
|
|
React.useEffect(() => {
|
|
|
let { pwd, plz } = pwdinfo;
|
|
let { pwd, plz } = pwdinfo;
|
|
|
|
|
+ console.log('PWDINOF',{pwd,plz})
|
|
|
|
|
+
|
|
|
|
|
+ let rest = new Service(`/contrasenia/${home ? pwd : btoa(pwd)}/${plz}`)
|
|
|
|
|
|
|
|
- let rest = new Service(`/contrasenia/${btoa(pwd)}/${plz}`)
|
|
|
|
|
rest.getQuery(auth.token)
|
|
rest.getQuery(auth.token)
|
|
|
.then(resp => {
|
|
.then(resp => {
|
|
|
|
|
|
|
@@ -212,14 +222,13 @@ function ModalForm(props) {
|
|
|
})
|
|
})
|
|
|
.catch(error => console.log(error))
|
|
.catch(error => console.log(error))
|
|
|
|
|
|
|
|
- }, [auth.token, pwdinfo, reset])
|
|
|
|
|
|
|
+ }, [auth.token, pwdinfo, reset,home])
|
|
|
|
|
|
|
|
const saveCandidato = async (body) => {
|
|
const saveCandidato = async (body) => {
|
|
|
let rest = new Service('/passwordcandidato/candidato')
|
|
let rest = new Service('/passwordcandidato/candidato')
|
|
|
return await rest.postQuery(body, auth.token)
|
|
return await rest.postQuery(body, auth.token)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
function onSubmit(fields) {
|
|
function onSubmit(fields) {
|
|
|
|
|
|
|
|
let candi_body = candidatos.map( c => {
|
|
let candi_body = candidatos.map( c => {
|
|
@@ -248,7 +257,7 @@ function ModalForm(props) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
rest.putQuery(body_req, auth.token)
|
|
rest.putQuery(body_req, auth.token)
|
|
|
- .then( async result => {
|
|
|
|
|
|
|
+ .then( async _result => {
|
|
|
queryClient.invalidateQueries('passwords')
|
|
queryClient.invalidateQueries('passwords')
|
|
|
|
|
|
|
|
//TODO: insert into passwordcanidato/candidato
|
|
//TODO: insert into passwordcanidato/candidato
|
|
@@ -279,7 +288,7 @@ function ModalForm(props) {
|
|
|
return (
|
|
return (
|
|
|
<Row>
|
|
<Row>
|
|
|
<Col>
|
|
<Col>
|
|
|
- <form style={{ padding: 20, maxWidth: 950 }} onSubmit={handleSubmit(onSubmit)}>
|
|
|
|
|
|
|
+ <form style={{ padding: !home? 20: 0, maxWidth: 950 }} onSubmit={handleSubmit(onSubmit)}>
|
|
|
<Stack spacing={4}>
|
|
<Stack spacing={4}>
|
|
|
|
|
|
|
|
<TextField
|
|
<TextField
|
|
@@ -299,22 +308,28 @@ function ModalForm(props) {
|
|
|
type="text"
|
|
type="text"
|
|
|
disabled
|
|
disabled
|
|
|
/>
|
|
/>
|
|
|
- <FormControlLabel
|
|
|
|
|
- label="Activo?"
|
|
|
|
|
- control={
|
|
|
|
|
- <Controller
|
|
|
|
|
- name="state"
|
|
|
|
|
- control={control}
|
|
|
|
|
- render={({ field: props }) =>
|
|
|
|
|
- <Checkbox
|
|
|
|
|
- style={{ color: 'var(--main)' }}
|
|
|
|
|
- checked={props.value}
|
|
|
|
|
- onChange={(e) => props.onChange(e.target.checked)}
|
|
|
|
|
|
|
+
|
|
|
|
|
+ {
|
|
|
|
|
+ !home ?
|
|
|
|
|
+ <FormControlLabel
|
|
|
|
|
+ label="Activo?"
|
|
|
|
|
+ control={
|
|
|
|
|
+ <Controller
|
|
|
|
|
+ name="state"
|
|
|
|
|
+ control={control}
|
|
|
|
|
+ render={({ field: props }) =>
|
|
|
|
|
+ <Checkbox
|
|
|
|
|
+ style={{ color: 'var(--main)' }}
|
|
|
|
|
+ checked={props.value}
|
|
|
|
|
+ onChange={(e) => props.onChange(e.target.checked)}
|
|
|
|
|
+ />
|
|
|
|
|
+ }
|
|
|
/>
|
|
/>
|
|
|
}
|
|
}
|
|
|
- />
|
|
|
|
|
- }
|
|
|
|
|
- />
|
|
|
|
|
|
|
+ /> : null
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
</Stack>
|
|
</Stack>
|
|
|
|
|
|
|
|
<LocalizationProvider dateAdapter={DateFnsUtils}>
|
|
<LocalizationProvider dateAdapter={DateFnsUtils}>
|
|
@@ -323,6 +338,7 @@ function ModalForm(props) {
|
|
|
control={control}
|
|
control={control}
|
|
|
render={({ field }) =>
|
|
render={({ field }) =>
|
|
|
<DesktopDatePicker
|
|
<DesktopDatePicker
|
|
|
|
|
+ disabled={home}
|
|
|
{...field}
|
|
{...field}
|
|
|
label="Fecha de Activación"
|
|
label="Fecha de Activación"
|
|
|
inputFormat="dd/MM/yyyy"
|
|
inputFormat="dd/MM/yyyy"
|
|
@@ -346,6 +362,7 @@ function ModalForm(props) {
|
|
|
render={({ field }) =>
|
|
render={({ field }) =>
|
|
|
<DesktopDatePicker
|
|
<DesktopDatePicker
|
|
|
{...field}
|
|
{...field}
|
|
|
|
|
+ disabled={home}
|
|
|
label="Fecha de Vencimiento"
|
|
label="Fecha de Vencimiento"
|
|
|
error={Boolean(errors?.deadpwd)}
|
|
error={Boolean(errors?.deadpwd)}
|
|
|
inputFormat="dd/MM/yyyy"
|
|
inputFormat="dd/MM/yyyy"
|
|
@@ -361,14 +378,30 @@ function ModalForm(props) {
|
|
|
</Controller>
|
|
</Controller>
|
|
|
</LocalizationProvider>
|
|
</LocalizationProvider>
|
|
|
|
|
|
|
|
- <DialogActions style={{ paddingTop: 25, 'justifyContent': "flex-start" }}>
|
|
|
|
|
- <Button onClick={() => closeModal(false)}>
|
|
|
|
|
- Cerrar
|
|
|
|
|
- </Button>
|
|
|
|
|
- <Button type="submit" style={{ color: 'white', background: 'var(--main)' }} >
|
|
|
|
|
- Guardar
|
|
|
|
|
- </Button>
|
|
|
|
|
- </DialogActions>
|
|
|
|
|
|
|
+ { !home?
|
|
|
|
|
+ <DialogActions style={{ paddingTop: 25, 'justifyContent': "flex-start" }}>
|
|
|
|
|
+ <Button onClick={() => closeModal(false)}>
|
|
|
|
|
+ Cerrar
|
|
|
|
|
+ </Button>
|
|
|
|
|
+ <Button type="submit" style={{ color: 'white', background: 'var(--main)' }} >
|
|
|
|
|
+ Guardar
|
|
|
|
|
+ </Button>
|
|
|
|
|
+ </DialogActions> :
|
|
|
|
|
+
|
|
|
|
|
+ <DialogActions
|
|
|
|
|
+ style={{
|
|
|
|
|
+ justifyContent: "flex-start",
|
|
|
|
|
+ }} >
|
|
|
|
|
+ <Button onClick={() => {
|
|
|
|
|
+ console.log('close modal')
|
|
|
|
|
+ console.log(closeModal)
|
|
|
|
|
+ closeModal(true)
|
|
|
|
|
+ }}>
|
|
|
|
|
+ Cerrar
|
|
|
|
|
+ </Button>
|
|
|
|
|
+ </DialogActions>
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
</Stack>
|
|
</Stack>
|
|
|
</form>
|
|
</form>
|
|
@@ -376,6 +409,7 @@ function ModalForm(props) {
|
|
|
</Col>
|
|
</Col>
|
|
|
<Col>
|
|
<Col>
|
|
|
<Candidatos
|
|
<Candidatos
|
|
|
|
|
+ home={home}
|
|
|
add={addCandidato}
|
|
add={addCandidato}
|
|
|
remove={removeCandidato}
|
|
remove={removeCandidato}
|
|
|
candidatos={candidatos}
|
|
candidatos={candidatos}
|