|
|
@@ -1,6 +1,4 @@
|
|
|
import * as React from 'react';
|
|
|
-
|
|
|
-import { Edit as EditIcon, Send as SendIcon } from '@mui/icons-material'
|
|
|
import {
|
|
|
Button, Dialog, DialogActions, DialogContent, //DialogTitle,
|
|
|
FormControlLabel, Checkbox,
|
|
|
@@ -20,55 +18,18 @@ import { AdapterDateFns as DateFnsUtils } from '@mui/x-date-pickers/AdapterDateF
|
|
|
import { DesktopDatePicker } from '@mui/x-date-pickers/DesktopDatePicker';
|
|
|
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
|
|
|
|
|
|
-
|
|
|
-export function Operation(props) {
|
|
|
-
|
|
|
- let [open, setOpen] = React.useState(false);
|
|
|
- const handleOpen = (status) => setOpen(status);
|
|
|
-
|
|
|
- return (
|
|
|
- <div>
|
|
|
- <div className="operation_buttons">
|
|
|
- <EditIcon onClick={() => setOpen(true)} className="icon_op" />
|
|
|
- <SendIcon className="icon_op" />
|
|
|
- </div>
|
|
|
- {
|
|
|
- open ?
|
|
|
- <ModalEdit
|
|
|
- password={props}
|
|
|
- open={open}
|
|
|
- handleOpen={handleOpen}
|
|
|
- />
|
|
|
- : null
|
|
|
- }
|
|
|
- </div>
|
|
|
- )
|
|
|
-}
|
|
|
-
|
|
|
-function ModalEdit(props) {
|
|
|
-
|
|
|
+export function ModalEdit(props) {
|
|
|
let { password, open, handleOpen } = props
|
|
|
- const now = React.useRef(new Date());
|
|
|
let { pwd, plz } = password
|
|
|
const auth = useSelector((state) => state.token)
|
|
|
const getPassword = async () => {
|
|
|
- let rest = new Service(`/contrasenia/${pwd}/${plz}`)
|
|
|
+ let rest = new Service(`/contrasenia/${btoa(pwd)}/${plz}`)
|
|
|
return await rest.getQuery(auth.token)
|
|
|
}
|
|
|
|
|
|
let { data: result } = useQuery('contra', getPassword);
|
|
|
console.log('PWD INFO ', result)
|
|
|
|
|
|
- let initialValues = {
|
|
|
- id: result?.data?.id,
|
|
|
- pwd: result?.data?.pwd,
|
|
|
- deadpwd: result?.data?.deadpwd ? new Date(result?.data?.deadpwd) : now.current,
|
|
|
- state: result?.data?.state,
|
|
|
- dateToActived: result?.data.dateToActived ? new Date(result?.data?.dateToActived) : now.current,
|
|
|
- plaza_id: result?.data?.plaza_id,
|
|
|
- candidato_id: result?.data?.candidato_id
|
|
|
- }
|
|
|
-
|
|
|
return (
|
|
|
<Dialog
|
|
|
open={open}
|
|
|
@@ -78,8 +39,6 @@ function ModalEdit(props) {
|
|
|
>
|
|
|
<DialogContent>
|
|
|
<ModalForm
|
|
|
- //puestos={puestos}
|
|
|
- initialValues={initialValues}
|
|
|
handleOpen={handleOpen}
|
|
|
token={auth.token}
|
|
|
/>
|
|
|
@@ -140,21 +99,6 @@ function ModalForm(props) {
|
|
|
|
|
|
const { errors, touched, handleSubmit, getFieldProps, values, setValues } = formik;
|
|
|
|
|
|
- function fromBase64(text){
|
|
|
- try{
|
|
|
- return atob(text)
|
|
|
- }catch(_e){
|
|
|
- return text
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- React.useEffect(() => {
|
|
|
- setValues({
|
|
|
- ...props.initialValues,
|
|
|
- pwd: props.initialValues.pwd ? fromBase64(props.initialValues.pwd) : 'loading'
|
|
|
- })
|
|
|
- }, [props, setValues])
|
|
|
-
|
|
|
return (
|
|
|
<FormikProvider value={formik}>
|
|
|
<Form style={{ padding: 20, maxWidth: 950 }} autoComplete="off" noValidate onSubmit={handleSubmit}>
|
|
|
@@ -193,7 +137,6 @@ function ModalForm(props) {
|
|
|
}
|
|
|
label="Activa"
|
|
|
/>
|
|
|
-
|
|
|
</Stack>
|
|
|
|
|
|
|
|
|
@@ -239,36 +182,6 @@ function ModalForm(props) {
|
|
|
/>}
|
|
|
/>
|
|
|
</LocalizationProvider>
|
|
|
-
|
|
|
-
|
|
|
- {/*
|
|
|
- <Autocomplete
|
|
|
- {...getFieldProps('plaza_id')}
|
|
|
- onChange={(_a,current_list,_c,_individual,_f) => {
|
|
|
- console.log("CURRENT LIST : ",current_list)
|
|
|
- setValues({
|
|
|
- ...values,
|
|
|
- plaza_id:current_list
|
|
|
- })
|
|
|
- }}
|
|
|
- value={props.puestos.filter(p=> p.id=== values.plaza_id ).shift()}
|
|
|
- id="combo-box-demo"
|
|
|
- options={props.puestos}
|
|
|
- isOptionEqualToValue={
|
|
|
- (option, value) => option.nombrepuesto === value.nombrepuesto
|
|
|
- }
|
|
|
- getOptionLabel={(option) => {
|
|
|
- return option.nombrepuesto
|
|
|
- }}
|
|
|
- renderInput={(params) =>
|
|
|
- <TextField
|
|
|
- {...params}
|
|
|
- label="Puesto"
|
|
|
- />
|
|
|
- }
|
|
|
- />
|
|
|
-*/}
|
|
|
-
|
|
|
<DialogActions>
|
|
|
<Button onClick={() => props.handleOpen(false)}>
|
|
|
Cerrar
|