Преглед на файлове

password multiple users form config

amenpunk преди 2 години
родител
ревизия
541197749b

+ 13 - 13
src/Components/Generics/loading.jsx

@@ -1,20 +1,20 @@
1 1
 import React from "react";
2 2
 import '../../Css/loading.css'
3 3
 
4
-export function Loading( ) {
4
+export function Loading() {
5 5
 
6
-    const types = [
7
-        "dot-pulse","dot-elastic","dot-flashing", "dot-collision", "dot-revolution", "dot-carousel", 
8
-        "dot-fire","dot-spin","dot-falling", "dot-stretching"
9
-    ];
6
+  const types = [
7
+    "dot-pulse", "dot-elastic", "dot-flashing", "dot-collision", "dot-revolution", "dot-carousel",
8
+    "dot-fire", "dot-spin", "dot-falling", "dot-stretching"
9
+  ];
10 10
 
11
-    return(
12
-        <div className="loading_or_content">
13
-            <div className="snippet" data-title=".dot-pulse">
14
-                <div className="stage">
15
-                    <div className={types[0]}></div>
16
-                </div>
17
-            </div>
11
+  return (
12
+    <div className="loading_or_content">
13
+      <div className="snippet" data-title=".dot-pulse">
14
+        <div className="stage">
15
+          <div className={types[0]}></div>
18 16
         </div>
19
-    )
17
+      </div>
18
+    </div>
19
+  )
20 20
 }

+ 158 - 158
src/Components/Modal/PasswordModal.jsx

@@ -2,8 +2,8 @@ import { Modal } from 'react-bootstrap'
2 2
 import * as React from 'react';
3 3
 
4 4
 import {
5
-    Box, Stepper, Step,
6
-    StepLabel, Button, Typography
5
+  Box, Stepper, Step, Fade,
6
+  StepLabel, Button, Typography
7 7
 } from '@mui/material'
8 8
 
9 9
 import { Puesto } from '../Password/Steps/puesto'
@@ -13,160 +13,160 @@ import { Resume } from '../Password/Steps/resume'
13 13
 
14 14
 export function HelpModal(props) {
15 15
 
16
-    let { visible, handleClose } = props
17
-    const now = React.useRef(new Date());
18
-
19
-    const [activeStep, setActiveStep] = React.useState(0);
20
-    const [skipped, setSkipped] = React.useState(new Set());
21
-
22
-    const [password, setPassword] = React.useState({
23
-        puesto: [],
24
-        pwd: "",
25
-        deadpwd: now.current,
26
-        dateToActived: now.current,
27
-        nombres:"",
28
-        apellidos:"",
29
-        mail:"",
30
-        sendmail:true,
31
-        nombrepuesto:null,
32
-        nombreEmpresa:null,
33
-    });
34
-
35
-    const isStepSkipped = (step) => {
36
-        return skipped.has(step);
37
-    };
38
-
39
-    const handleNext = () => {
40
-        let newSkipped = skipped;
41
-        if (isStepSkipped(activeStep)) {
42
-            newSkipped = new Set(newSkipped.values());
43
-            newSkipped.delete(activeStep);
44
-        }
45
-
46
-        setActiveStep((prevActiveStep) => prevActiveStep + 1);
47
-        setSkipped(newSkipped);
48
-    };
49
-
50
-    const handleBack = () => {
51
-        setActiveStep((prevActiveStep) => prevActiveStep - 1);
52
-    };
53
-
54
-    const handleReset = () => {
55
-        setPassword({
56
-            puesto: [],
57
-            pwd: "",
58
-            deadpwd: now.current,
59
-            dateToActived: now.current,
60
-            nombres:"",
61
-            apellidos:"",
62
-            mail:"",
63
-            sendmail:true,
64
-            nombrepuesto:null,
65
-            nombreEmpresa:null,
66
-        })
67
-        setActiveStep(0);
68
-    };
69
-
70
-
71
-    const steps = [
72
-        {
73
-            label: 'Puesto',
74
-            operation:
75
-                <Puesto
76
-                    handleNext={handleNext}
77
-                    handleBack={handleBack}
78
-                    password={password}
79
-                    setPassword={setPassword}
80
-                />
81
-        },
82
-        {
83
-            label: 'Contraseña',
84
-            operation:
85
-                <Password
86
-                    handleNext={handleNext}
87
-                    handleBack={handleBack}
88
-                    password={password}
89
-                    setPassword={setPassword}
90
-                />
91
-        },
92
-        {
93
-            label: 'Candidato',
94
-            operation:
95
-                <Candidato
96
-                    handleNext={handleNext}
97
-                    handleBack={handleBack}
98
-                    password={password}
99
-                    setPassword={setPassword}
100
-                />
101
-        },
102
-        {
103
-            label: 'Confirmar',
104
-            operation: 
105
-                <Resume
106
-                    handleBack={handleBack}
107
-                    password={password}
108
-                    handleClose={handleClose}
109
-                    handleReset={handleReset}
110
-                />
111
-        },
112
-    ];
113
-
114
-
115
-    return (
116
-        <Modal size="lg"
117
-            aria-labelledby="contained-modal-title-vcenter"
118
-            centered show={visible}
119
-            onHide={handleClose}
120
-        >
121
-            <Modal.Header>
122
-                <button type="button" className="close" onClick={handleClose}>&times;</button>
123
-                <h4 className="modal-title">Crear Contraseña</h4>
124
-            </Modal.Header>
125
-            <Modal.Body className="modal-body">
126
-
127
-                <Box sx={{ width: '100%' }}>
128
-                    <Stepper
129
-                        sx={{
130
-                            flexWrap: 'wrap'
131
-                        }}
132
-                        activeStep={activeStep}>
133
-                        {steps.map((step, index) => {
134
-                            const stepProps = {};
135
-                            const labelProps = {};
136
-                            if (isStepSkipped(index)) {
137
-                                stepProps.completed = false;
138
-                            }
139
-                            return (
140
-                                <Step key={step.label} {...stepProps}>
141
-                                    <StepLabel
142
-                                        sx={{ margin: 1 }}
143
-                                        {...labelProps}>{step.label}</StepLabel>
144
-                                </Step>
145
-                            );
146
-                        })}
147
-                    </Stepper>
148
-                    {activeStep === steps.length ? (
149
-                        <React.Fragment>
150
-                            <Typography sx={{ mt: 2, mb: 1 }}>
151
-                                All steps completed - you&apos;re finished
152
-                            </Typography>
153
-                            <Box sx={{ display: 'flex', flexDirection: 'row', pt: 2 }}>
154
-                                <Box sx={{ flex: '1 1 auto' }} />
155
-                                <Button onClick={handleReset}>Reiniciar</Button>
156
-                            </Box>
157
-                        </React.Fragment>
158
-                    ) : (
159
-                        <React.Fragment>
160
-
161
-                            <Box style={{ padding: 18, marginTop: 2 }}>
162
-                                {steps[activeStep].operation}
163
-                            </Box>
164
-
165
-                        </React.Fragment>
166
-                    )}
167
-                </Box>
168
-
169
-            </Modal.Body>
170
-        </Modal>
171
-    )
16
+  let { visible, handleClose } = props
17
+  const now = React.useRef(new Date());
18
+
19
+  const [activeStep, setActiveStep] = React.useState(0);
20
+  const [skipped, setSkipped] = React.useState(new Set());
21
+
22
+  const [password, setPassword] = React.useState({
23
+    puesto: [],
24
+    pwd: "",
25
+    deadpwd: now.current,
26
+    dateToActived: now.current,
27
+    nombres: "",
28
+    apellidos: "",
29
+    mail: "",
30
+    sendmail: true,
31
+    nombrepuesto: null,
32
+    nombreEmpresa: null,
33
+  });
34
+
35
+  const isStepSkipped = (step) => {
36
+    return skipped.has(step);
37
+  };
38
+
39
+  const handleNext = () => {
40
+    let newSkipped = skipped;
41
+    if (isStepSkipped(activeStep)) {
42
+      newSkipped = new Set(newSkipped.values());
43
+      newSkipped.delete(activeStep);
44
+    }
45
+
46
+    setActiveStep((prevActiveStep) => prevActiveStep + 1);
47
+    setSkipped(newSkipped);
48
+  };
49
+
50
+  const handleBack = () => {
51
+    setActiveStep((prevActiveStep) => prevActiveStep - 1);
52
+  };
53
+
54
+  const handleReset = () => {
55
+    setPassword({
56
+      puesto: [],
57
+      pwd: "",
58
+      deadpwd: now.current,
59
+      dateToActived: now.current,
60
+      nombres: "",
61
+      apellidos: "",
62
+      mail: "",
63
+      sendmail: true,
64
+      nombrepuesto: null,
65
+      nombreEmpresa: null,
66
+    })
67
+    setActiveStep(0);
68
+  };
69
+
70
+
71
+  const steps = [
72
+    {
73
+      label: 'Puesto',
74
+      operation:
75
+        <Puesto
76
+          handleNext={handleNext}
77
+          handleBack={handleBack}
78
+          password={password}
79
+          setPassword={setPassword}
80
+        />
81
+    },
82
+    {
83
+      label: 'Contraseña',
84
+      operation:
85
+        <Password
86
+          handleNext={handleNext}
87
+          handleBack={handleBack}
88
+          password={password}
89
+          setPassword={setPassword}
90
+        />
91
+    },
92
+    {
93
+      label: 'Candidatos',
94
+      operation:
95
+        <Candidato
96
+          handleNext={handleNext}
97
+          handleBack={handleBack}
98
+          password={password}
99
+          setPassword={setPassword}
100
+        />
101
+    },
102
+    {
103
+      label: 'Confirmar',
104
+      operation:
105
+        <Resume
106
+          handleBack={handleBack}
107
+          password={password}
108
+          handleClose={handleClose}
109
+          handleReset={handleReset}
110
+        />
111
+    },
112
+  ];
113
+
114
+
115
+  return (
116
+    <Modal size="lg"
117
+      aria-labelledby="contained-modal-title-vcenter"
118
+      centered show={visible}
119
+      onHide={handleClose}
120
+    >
121
+      <Modal.Header>
122
+        <button type="button" className="close" onClick={handleClose}>&times;</button>
123
+        <h4 className="modal-title">Crear Contraseña</h4>
124
+      </Modal.Header>
125
+      <Modal.Body className="modal-body">
126
+
127
+        <Box sx={{ width: '100%' }}>
128
+          <Stepper
129
+            sx={{
130
+              flexWrap: 'wrap'
131
+            }}
132
+            activeStep={activeStep}>
133
+            {steps.map((step, index) => {
134
+              const stepProps = {};
135
+              const labelProps = {};
136
+              if (isStepSkipped(index)) {
137
+                stepProps.completed = false;
138
+              }
139
+              return (
140
+                <Step key={step.label} {...stepProps}>
141
+                  <StepLabel
142
+                    sx={{ margin: 1 }}
143
+                    {...labelProps}>{step.label}</StepLabel>
144
+                </Step>
145
+              );
146
+            })}
147
+          </Stepper>
148
+          {activeStep === steps.length ? (
149
+            <React.Fragment>
150
+              <Typography sx={{ mt: 2, mb: 1 }}>
151
+                All steps completed - you&apos;re finished
152
+              </Typography>
153
+              <Box sx={{ display: 'flex', flexDirection: 'row', pt: 2 }}>
154
+                <Box sx={{ flex: '1 1 auto' }} />
155
+                <Button onClick={handleReset}>Reiniciar</Button>
156
+              </Box>
157
+            </React.Fragment>
158
+          ) : (
159
+            <React.Fragment>
160
+
161
+              <Box style={{ padding: 18, marginTop: 2 }}>
162
+                {steps[activeStep].operation}
163
+              </Box>
164
+
165
+            </React.Fragment>
166
+          )}
167
+        </Box>
168
+
169
+      </Modal.Body>
170
+    </Modal>
171
+  )
172 172
 }

+ 27 - 30
src/Components/Password/CustomToolbar.jsx

@@ -1,6 +1,6 @@
1 1
 import React from "react";
2 2
 import {
3
-    IconButton, Tooltip
3
+  IconButton, Tooltip
4 4
 } from '@mui/material';
5 5
 
6 6
 import { Add as AddIcon } from '@mui/icons-material'
@@ -8,36 +8,33 @@ import { HelpModal as PasswordModal } from '../../Components/Modal/PasswordModal
8 8
 
9 9
 export default class CustomToolbar extends React.Component {
10 10
 
11
-    constructor(props){
12
-        super(props);
13
-        this.state = {
14
-            visible : false
15
-        }
16
-    }
17
-
18
-    setVisible = () => this.setState({ visible : false});
19
-
20
-    handleClick = () => {
21
-        console.log("is visible  :",  this.state.visible );
22
-        this.setState({ visible : !this.state.visible })
23
-    }
24
-
25
-
26
-    render() {
27
-
28
-        let { visible } = this.state;
29
-
30
-        return (
31
-            <React.Fragment>
32
-                <Tooltip title={"custom icon"}>
33
-                    <IconButton onClick={this.handleClick}>
34
-                        <AddIcon />
35
-                    </IconButton>
36
-                </Tooltip>
37
-                <PasswordModal visible={visible} handleClose={this.setVisible} />
38
-            </React.Fragment>
39
-        );
11
+  constructor(props) {
12
+    super(props);
13
+    this.state = {
14
+      visible: false
40 15
     }
16
+  }
17
+
18
+  setVisible = () => this.setState({ visible: false });
19
+
20
+  handleClick = () => {
21
+    console.log("is visible  :", this.state.visible);
22
+    this.setState({ visible: !this.state.visible })
23
+  }
24
+
25
+  render() {
26
+    let { visible } = this.state;
27
+    return (
28
+      <React.Fragment>
29
+        <Tooltip title={"custom icon"}>
30
+          <IconButton onClick={this.handleClick}>
31
+            <AddIcon />
32
+          </IconButton>
33
+        </Tooltip>
34
+        <PasswordModal visible={visible} handleClose={this.setVisible} />
35
+      </React.Fragment>
36
+    );
37
+  }
41 38
 
42 39
 }
43 40
 

+ 233 - 234
src/Components/Password/Operation.jsx

@@ -2,18 +2,18 @@ import * as React from 'react';
2 2
 
3 3
 import { Edit as EditIcon, Send as SendIcon } from '@mui/icons-material'
4 4
 import {
5
-    Button, Dialog, DialogActions, DialogContent, //DialogTitle,
6
-    FormControlLabel, Checkbox,
7
-    TextField, Stack,
8
-    // Autocomplete
5
+  Button, Dialog, DialogActions, DialogContent, //DialogTitle,
6
+  FormControlLabel, Checkbox,
7
+  TextField, Stack,
8
+  // Autocomplete
9 9
 } from '@mui/material'
10 10
 
11 11
 import toast, { Toaster } from 'react-hot-toast';
12 12
 import * as Yup from 'yup';
13 13
 
14
-import { useQuery, useQueryClient   } from 'react-query'
14
+import { useQuery, useQueryClient } from 'react-query'
15 15
 import { Service } from '../../Utils/HTTP.js'
16
-import useAuth from '../../Auth/useAuth.js';
16
+import { useSelector } from 'react-redux'
17 17
 
18 18
 import { useFormik, Form, FormikProvider } from 'formik';
19 19
 
@@ -22,226 +22,225 @@ import { DesktopDatePicker, LocalizationProvider } from '@mui/lab';
22 22
 
23 23
 export function Operation(props) {
24 24
 
25
-    let [open, setOpen] = React.useState(false);
26
-    const handleOpen = (status) => setOpen(status);
27
-
28
-    return (
29
-        <div>
30
-            <div className="operation_buttons">
31
-                <EditIcon onClick={() => setOpen(true)} className="icon_op" />
32
-                <SendIcon className="icon_op" />
33
-            </div>
34
-            {
35
-                open ?
36
-                    <ModalEdit
37
-                        password={props}
38
-                        open={open}
39
-                        handleOpen={handleOpen}
40
-                    />
41
-                    : null
42
-            }
43
-        </div>
44
-    )
25
+  let [open, setOpen] = React.useState(false);
26
+  const handleOpen = (status) => setOpen(status);
27
+
28
+  return (
29
+    <div>
30
+      <div className="operation_buttons">
31
+        <EditIcon onClick={() => setOpen(true)} className="icon_op" />
32
+        <SendIcon className="icon_op" />
33
+      </div>
34
+      {
35
+        open ?
36
+          <ModalEdit
37
+            password={props}
38
+            open={open}
39
+            handleOpen={handleOpen}
40
+          />
41
+          : null
42
+      }
43
+    </div>
44
+  )
45 45
 }
46 46
 
47 47
 function ModalEdit(props) {
48 48
 
49
-    let { password, open, handleOpen } = props
50
-    const now = React.useRef(new Date());
51
-    let { pwd, plz } = password
52
-    const auth = useAuth();
53
-    const token = React.useRef(auth.getToken());
54
-    const getPassword = async () => {
55
-        let rest = new Service(`/contrasenia/${pwd}/${plz}`)
56
-        return await rest.getQuery(token.current)
57
-    }
58
-
59
-    let { data: result } = useQuery('contra', getPassword);
60
-    console.log('PWD INFO ',result)
61
-    //
62
-    // const getPuestos = async () => {
63
-    //     let rest = new Service('/plaza/getall')
64
-    //     return rest.getQuery(token.current);
65
-    // }
66
-    //
67
-    // let { data } = useQuery('puestos', getPuestos)
68
-    // let puestos = data ? data.data.map(({ nombrepuesto, id }) => ({ nombrepuesto, id })) : []
69
-
70
-    let initialValues = {
71
-        id: result?.data?.id,
72
-        pwd: result?.data?.pwd,
73
-        deadpwd: result?.data?.deadpwd ? new Date(result?.data?.deadpwd) : now.current,
74
-        state: result?.data?.state,
75
-        dateToActived: result?.data.dateToActived ? new Date(result?.data?.dateToActived) : now.current,
76
-        plaza_id: result?.data?.plaza_id,
77
-        candidato_id : result?.data?.candidato_id
78
-    }
79
-
80
-    return (
81
-        <Dialog
82
-            open={open}
83
-            onClose={() => handleOpen(false)}
84
-            aria-labelledby="alert-dialog-title"
85
-            aria-describedby="alert-dialog-description"
86
-        >
87
-            <DialogContent>
88
-                <ModalForm
89
-                    //puestos={puestos}
90
-                    initialValues={initialValues}
91
-                    handleOpen={handleOpen}
92
-                    token={token.current}
93
-                />
94
-            </DialogContent>
95
-        </Dialog>
96
-    )
49
+  let { password, open, handleOpen } = props
50
+  const now = React.useRef(new Date());
51
+  let { pwd, plz } = password
52
+  const auth = useSelector((state) => state.token)
53
+  const getPassword = async () => {
54
+    let rest = new Service(`/contrasenia/${pwd}/${plz}`)
55
+    return await rest.getQuery(auth.token)
56
+  }
57
+
58
+  let { data: result } = useQuery('contra', getPassword);
59
+  console.log('PWD INFO ', result)
60
+  //
61
+  // const getPuestos = async () => {
62
+  //     let rest = new Service('/plaza/getall')
63
+  //     return rest.getQuery(token.current);
64
+  // }
65
+  //
66
+  // let { data } = useQuery('puestos', getPuestos)
67
+  // let puestos = data ? data.data.map(({ nombrepuesto, id }) => ({ nombrepuesto, id })) : []
68
+
69
+  let initialValues = {
70
+    id: result?.data?.id,
71
+    pwd: result?.data?.pwd,
72
+    deadpwd: result?.data?.deadpwd ? new Date(result?.data?.deadpwd) : now.current,
73
+    state: result?.data?.state,
74
+    dateToActived: result?.data.dateToActived ? new Date(result?.data?.dateToActived) : now.current,
75
+    plaza_id: result?.data?.plaza_id,
76
+    candidato_id: result?.data?.candidato_id
77
+  }
78
+
79
+  return (
80
+    <Dialog
81
+      open={open}
82
+      onClose={() => handleOpen(false)}
83
+      aria-labelledby="alert-dialog-title"
84
+      aria-describedby="alert-dialog-description"
85
+    >
86
+      <DialogContent>
87
+        <ModalForm
88
+          //puestos={puestos}
89
+          initialValues={initialValues}
90
+          handleOpen={handleOpen}
91
+          token={auth.token}
92
+        />
93
+      </DialogContent>
94
+    </Dialog>
95
+  )
97 96
 }
98 97
 
99 98
 function ModalForm(props) {
100 99
 
101
-    const pwdSchema = Yup.object().shape({
102
-        id: Yup.number(),
103
-        pwd: Yup.string().required("Escoge un nombre valido"),
104
-        deadpwd: Yup.date().required("Escoge una fecha valida"),
105
-        state: Yup.number(),
106
-        dateToActived: Yup.date('Escoge una fecha valida').required("Escoge una fecha valida"),
107
-        //plaza_id: Yup.array().required("Escoge una plaza valida")
108
-        //plaza_id: Yup.array().required("Escoge una plaza valida")
109
-    })
110
-
111
-    const queryClient = useQueryClient();
112
-
113
-    const formik = useFormik({
114
-        initialValues: {
115
-            state: 1,
116
-            pwd:"",
117
-            deadpwd:"",
118
-            dateToActived:"",
119
-            // plaza_id:[],
120
-        },
121
-        onSubmit: (fields) => {
122
-
123
-            let rest = new Service('/contrasenia/create');
124
-            let { deadpwd,dateToActived,pwd } = fields
125
-            
126
-            fields['pwd'] = btoa(pwd);
127
-            fields['deadpwd'] = new Date(deadpwd).toISOString();
128
-            fields['dateToActived'] = new Date(dateToActived).toISOString();
129
-            fields['candidato_id'] = props.initialValues.candidato_id
130
-            fields['plaza_id'] = props.initialValues.plaza_id
131
-
132
-            rest.put(fields, props.token)
133
-                .then(result => {
134
-                    queryClient.invalidateQueries('passwords')
135
-                    console.log(result)
136
-                    setTimeout(()=>{
137
-                        props.handleOpen(false)
138
-                    },1000)
139
-                    toast.success("Contraseña Actualizada")
140
-                })
141
-                .catch(bad => {
142
-                    console.log('ERROR',bad)
143
-                    toast.error("Ocurrio un error")
144
-                })
145
-        },
146
-        validationSchema: pwdSchema,
147
-    })
100
+  const pwdSchema = Yup.object().shape({
101
+    id: Yup.number(),
102
+    pwd: Yup.string().required("Escoge un nombre valido"),
103
+    deadpwd: Yup.date().required("Escoge una fecha valida"),
104
+    state: Yup.number(),
105
+    dateToActived: Yup.date('Escoge una fecha valida').required("Escoge una fecha valida"),
106
+    //plaza_id: Yup.array().required("Escoge una plaza valida")
107
+    //plaza_id: Yup.array().required("Escoge una plaza valida")
108
+  })
109
+
110
+  const queryClient = useQueryClient();
111
+
112
+  const formik = useFormik({
113
+    initialValues: {
114
+      state: 1,
115
+      pwd: "",
116
+      deadpwd: "",
117
+      dateToActived: "",
118
+      // plaza_id:[],
119
+    },
120
+    onSubmit: (fields) => {
121
+
122
+      let rest = new Service('/contrasenia/create');
123
+      let { deadpwd, dateToActived, pwd } = fields
124
+
125
+      fields['pwd'] = btoa(pwd);
126
+      fields['deadpwd'] = new Date(deadpwd).toISOString();
127
+      fields['dateToActived'] = new Date(dateToActived).toISOString();
128
+      fields['candidato_id'] = props.initialValues.candidato_id
129
+      fields['plaza_id'] = props.initialValues.plaza_id
130
+
131
+      rest.put(fields, props.token)
132
+        .then(result => {
133
+          queryClient.invalidateQueries('passwords')
134
+          console.log(result)
135
+          setTimeout(() => {
136
+            props.handleOpen(false)
137
+          }, 1000)
138
+          toast.success("Contraseña Actualizada")
139
+        })
140
+        .catch(bad => {
141
+          console.log('ERROR', bad)
142
+          toast.error("Ocurrio un error")
143
+        })
144
+    },
145
+    validationSchema: pwdSchema,
146
+  })
148 147
 
149
-    const { errors, touched, handleSubmit, getFieldProps, values, setValues } = formik;
148
+  const { errors, touched, handleSubmit, getFieldProps, values, setValues } = formik;
150 149
 
151
-    React.useEffect(() => {
152
-        setValues({ 
153
-            ...props.initialValues,
154
-            pwd : props.initialValues.pwd ? atob( props.initialValues.pwd ) : 'loading'
155
-        })
156
-    }, [props, setValues])
157
-
158
-    return (
159
-        <FormikProvider value={formik}>
160
-            <Form style={{ padding: 20, maxWidth: 950 }} autoComplete="off" noValidate onSubmit={handleSubmit}>
161
-                <Stack spacing={4}>
162
-                    <TextField
163
-                        value={btoa( values.pwd )}
164
-                        variant="filled"
165
-                        disabled
166
-                        fullWidth
167
-                        type="text"
168
-                        label="Contraseña Cifrada"
169
-                        />
170
-
171
-                    <Stack direction={{ xs: 'column', sm: 'row' }} spacing={2}>
172
-
173
-                        <TextField
174
-                            type="text"
175
-                            label="Contraseña"
176
-                            {...getFieldProps('pwd')}
177
-                            error={Boolean(touched.pwd && errors.pwd)}
178
-                            helperText={touched.pwd && errors.pwd}
179
-                        />
180
-
181
-                        <FormControlLabel
182
-                            control={
183
-                                <Checkbox
184
-                                    checked={values.state === 1}
185
-                                    onChange={(event) => {
186
-                                        let check = event.target.checked;
187
-                                        setValues({
188
-                                            ...values,
189
-                                            state: check ? 1 : 0
190
-                                        })
191
-                                    }}
192
-                                />
193
-                            }
194
-                            label="Activa"
195
-                        />
196
-
197
-                    </Stack>
198
-                        
199
-
200
-                    <LocalizationProvider
201
-                        dateAdapter={DateFnsUtils}>
202
-                        <DesktopDatePicker
203
-                            label="Fecha de Activación"
204
-                            fullWidth
205
-                            inputFormat="dd/MM/yyyy"
206
-                            value={values.dateToActived}
207
-                            onChange={(val) => setValues({ ...values, dateToActived: val }) }
208
-                            renderInput={(params) =>
209
-                                <TextField
210
-                                    {...getFieldProps('dateToActived')}
211
-                                    error={Boolean(touched.dateToActived && errors.dateToActived)}
212
-                                    helperText={touched.dateToActived && errors.dateToActived}
213
-                                    disabled={true}
214
-                                    label="Fecha de Activación"
215
-                                    fullWidth
216
-                                    {...params}
217
-                                />}
218
-                        />
219
-                    </LocalizationProvider>
220
-
221
-                    <LocalizationProvider
222
-                        dateAdapter={DateFnsUtils}>
223
-                        <DesktopDatePicker
224
-                            label="Fecha de Vencimiento"
225
-                            fullWidth
226
-                            inputFormat="dd/MM/yyyy"
227
-                            {...getFieldProps('deadpwd')}
228
-                            value={values.deadpwd}
229
-                            onChange={(val) => setValues({ ...values, deadpwd: new Date(val) })
230
-                            }
231
-                            renderInput={(params) =>
232
-                                <TextField
233
-                                    error={Boolean(touched.deadpwd && errors.deadpwd)}
234
-                                    helperText={touched.deadpwd && errors.deadpwd}
235
-                                    disabled={true}
236
-                                    label="Fecha de Vencimiento"
237
-                                    fullWidth
238
-                                    {...params}
239
-                                />}
240
-                        />
241
-                    </LocalizationProvider>
242
-
243
-
244
-                    {/*
150
+  React.useEffect(() => {
151
+    setValues({
152
+      ...props.initialValues,
153
+      pwd: props.initialValues.pwd ? atob(props.initialValues.pwd) : 'loading'
154
+    })
155
+  }, [props, setValues])
156
+
157
+  return (
158
+    <FormikProvider value={formik}>
159
+      <Form style={{ padding: 20, maxWidth: 950 }} autoComplete="off" noValidate onSubmit={handleSubmit}>
160
+        <Stack spacing={4}>
161
+          <TextField
162
+            value={btoa(values.pwd)}
163
+            variant="filled"
164
+            disabled
165
+            fullWidth
166
+            type="text"
167
+            label="Contraseña Cifrada"
168
+          />
169
+
170
+          <Stack direction={{ xs: 'column', sm: 'row' }} spacing={2}>
171
+
172
+            <TextField
173
+              type="text"
174
+              label="Contraseña"
175
+              {...getFieldProps('pwd')}
176
+              error={Boolean(touched.pwd && errors.pwd)}
177
+              helperText={touched.pwd && errors.pwd}
178
+            />
179
+
180
+            <FormControlLabel
181
+              control={
182
+                <Checkbox
183
+                  checked={values.state === 1}
184
+                  onChange={(event) => {
185
+                    let check = event.target.checked;
186
+                    setValues({
187
+                      ...values,
188
+                      state: check ? 1 : 0
189
+                    })
190
+                  }}
191
+                />
192
+              }
193
+              label="Activa"
194
+            />
195
+
196
+          </Stack>
197
+
198
+
199
+          <LocalizationProvider
200
+            dateAdapter={DateFnsUtils}>
201
+            <DesktopDatePicker
202
+              label="Fecha de Activación"
203
+              fullWidth
204
+              inputFormat="dd/MM/yyyy"
205
+              value={values.dateToActived}
206
+              onChange={(val) => setValues({ ...values, dateToActived: val })}
207
+              renderInput={(params) =>
208
+                <TextField
209
+                  {...getFieldProps('dateToActived')}
210
+                  error={Boolean(touched.dateToActived && errors.dateToActived)}
211
+                  helperText={touched.dateToActived && errors.dateToActived}
212
+                  disabled={true}
213
+                  label="Fecha de Activación"
214
+                  fullWidth
215
+                  {...params}
216
+                />}
217
+            />
218
+          </LocalizationProvider>
219
+
220
+          <LocalizationProvider
221
+            dateAdapter={DateFnsUtils}>
222
+            <DesktopDatePicker
223
+              label="Fecha de Vencimiento"
224
+              fullWidth
225
+              inputFormat="dd/MM/yyyy"
226
+              {...getFieldProps('deadpwd')}
227
+              value={values.deadpwd}
228
+              onChange={(val) => setValues({ ...values, deadpwd: new Date(val) })
229
+              }
230
+              renderInput={(params) =>
231
+                <TextField
232
+                  error={Boolean(touched.deadpwd && errors.deadpwd)}
233
+                  helperText={touched.deadpwd && errors.deadpwd}
234
+                  disabled={true}
235
+                  label="Fecha de Vencimiento"
236
+                  fullWidth
237
+                  {...params}
238
+                />}
239
+            />
240
+          </LocalizationProvider>
241
+
242
+
243
+          {/*
245 244
                     <Autocomplete
246 245
                         {...getFieldProps('plaza_id')}
247 246
                         onChange={(_a,current_list,_c,_individual,_f) => {
@@ -269,24 +268,24 @@ function ModalForm(props) {
269 268
                     />
270 269
 */}
271 270
 
272
-                    <DialogActions>
273
-                        <Button onClick={() => props.handleOpen(false)}>
274
-                            Cerrar
275
-                        </Button>
276
-                        <Button
277
-                            type="submit"
278
-                            className="registerBtn"
279
-                            style={{ color: 'white' }}
280
-                            >
281
-                            Guardar
282
-                        </Button>
283
-                    </DialogActions>
284
-
285
-                </Stack>
286
-            </Form>
287
-            <Toaster position="bottom-right" />
288
-        </FormikProvider >
289
-    )
271
+          <DialogActions>
272
+            <Button onClick={() => props.handleOpen(false)}>
273
+              Cerrar
274
+            </Button>
275
+            <Button
276
+              type="submit"
277
+              className="registerBtn"
278
+              style={{ color: 'white' }}
279
+            >
280
+              Guardar
281
+            </Button>
282
+          </DialogActions>
283
+
284
+        </Stack>
285
+      </Form>
286
+      <Toaster position="bottom-right" />
287
+    </FormikProvider >
288
+  )
290 289
 
291 290
 }
292 291
 

+ 47 - 47
src/Components/Password/Rows.js

@@ -1,58 +1,58 @@
1 1
 import { Operation } from './Operation'
2 2
 
3 3
 export const Encabezados = [
4
-    {
5
-        name: 'name',
6
-        numeric: false,
7
-        disablePadding: true,
8
-        label: 'Nombre',
9
-    },
10
-    {
11
-        name: 'activacion',
12
-        numeric: false,
13
-        disablePadding: true,
14
-        label: 'Fecha Activación',
15
-    },
16
-    {
17
-        name: 'dead',
18
-        numeric: false,
19
-        disablePadding: true,
20
-        label: 'Fecha vencimiento',
21
-    },
22
-    {
23
-        name: 'op',
24
-        numeric: false,
25
-        disablePadding: true,
26
-        label: 'Operación',
27
-        options: {
28
-            filter: false,
29
-            sort: false,
30
-        }
31
-    },
4
+  {
5
+    name: 'name',
6
+    numeric: false,
7
+    disablePadding: true,
8
+    label: 'Nombre',
9
+  },
10
+  {
11
+    name: 'activacion',
12
+    numeric: false,
13
+    disablePadding: true,
14
+    label: 'Fecha Activación',
15
+  },
16
+  {
17
+    name: 'dead',
18
+    numeric: false,
19
+    disablePadding: true,
20
+    label: 'Fecha vencimiento',
21
+  },
22
+  {
23
+    name: 'op',
24
+    numeric: false,
25
+    disablePadding: true,
26
+    label: 'Operación',
27
+    options: {
28
+      filter: false,
29
+      sort: false,
30
+    }
31
+  },
32 32
 ]
33 33
 
34 34
 export const niveles_educativos = [
35
-    "Primaria",
36
-    "Basico",
37
-    "Diversificado",
38
-    "Tecnico",
39
-    "Pregrado / Licenciatura",
40
-    "Postgrado / Maestria",
41
-    "Doctorado",
42
-    "Diplomado",
43
-    "Certificacion",
44
-    "Cursos"
35
+  "Primaria",
36
+  "Basico",
37
+  "Diversificado",
38
+  "Tecnico",
39
+  "Pregrado / Licenciatura",
40
+  "Postgrado / Maestria",
41
+  "Doctorado",
42
+  "Diplomado",
43
+  "Certificacion",
44
+  "Cursos"
45 45
 ]
46 46
 
47 47
 export function Build(pwds) {
48
-    return pwds.map(password => {
49
-        let {pwd , deadpwd, dateToActived, plaza_id} = password
50
-        return {
51
-            name:pwd, //user.nombre,
52
-            activacion:dateToActived, //user.apellidos,
53
-            daed: deadpwd,//,user.mail,
54
-            op: <Operation plz={plaza_id} pwd={pwd} />
55
-        }
56
-    })
48
+  return pwds.map(password => {
49
+    let { pwd, deadpwd, dateToActived, plaza_id } = password
50
+    return {
51
+      name: pwd,
52
+      activacion: new Date().toUTCString(),//dateToActived, 
53
+      dead: new Date().toUTCString(), //deadpwd,
54
+      op: <Operation plz={plaza_id} pwd={pwd} />
55
+    }
56
+  })
57 57
 }
58 58
 

+ 51 - 0
src/Components/Password/Steps/MailTable.jsx

@@ -0,0 +1,51 @@
1
+import * as React from 'react';
2
+import Table from '@mui/material/Table';
3
+import TableBody from '@mui/material/TableBody';
4
+import TableCell from '@mui/material/TableCell';
5
+import TableContainer from '@mui/material/TableContainer';
6
+import TableHead from '@mui/material/TableHead';
7
+import TableRow from '@mui/material/TableRow';
8
+import Paper from '@mui/material/Paper';
9
+
10
+import { RemoveSharp, DisabledByDefault } from '@mui/icons-material'
11
+
12
+function createData(name, calories, fat) {
13
+  return { name, calories, fat, icon : <DisabledByDefault color="primary"/>};
14
+}
15
+
16
+const rows = [
17
+  createData('Frozen yoghurt', 159, 6.0, ),
18
+  createData('Ice cream sandwich', 237, 9.0),
19
+  createData('Eclair', 262, 16.0, ),
20
+  createData('Cupcake', 305, 3.7,),
21
+  createData('Gingerbread', 356,21),
22
+];
23
+
24
+export function MailTable() {
25
+  return (
26
+    <TableContainer component={Paper}>
27
+      <Table aria-label="simple table">
28
+        <TableHead>
29
+          <TableRow>
30
+            <TableCell>Correo</TableCell>
31
+            <TableCell align="right">Nombres</TableCell>
32
+            <TableCell align="right">Apellidos</TableCell>
33
+            <TableCell align="right"></TableCell>
34
+          </TableRow>
35
+        </TableHead>
36
+        <TableBody>
37
+          {rows.map((row) => (
38
+            <TableRow key={row.name} sx={{ '&:last-child td, &:last-child th': { border: 0 } }} >
39
+              <TableCell component="th" scope="row">
40
+                {row.name}
41
+              </TableCell>
42
+              <TableCell align="right">{row.calories}</TableCell>
43
+              <TableCell align="right">{row.fat}</TableCell>
44
+              <TableCell align="right">{row.icon}</TableCell>
45
+            </TableRow>
46
+          ))}
47
+        </TableBody>
48
+      </Table>
49
+    </TableContainer>
50
+  );
51
+}

+ 113 - 142
src/Components/Password/Steps/candidato.jsx

@@ -3,152 +3,123 @@ import * as Yup from 'yup';
3 3
 import { useFormik, Form, FormikProvider } from 'formik';
4 4
 
5 5
 import {
6
-    Box, Button, FormControlLabel, Checkbox,
7
-    Stack, TextField, FormGroup,
6
+  Box, Button, FormControlLabel, Checkbox,
7
+  Stack, TextField, FormGroup, Divider, Typography,
8 8
 } from '@mui/material';
9 9
 
10
-import useAuth from '../../../Auth/useAuth';
10
+import { MailTable } from './MailTable';
11 11
 
12 12
 
13 13
 export function Candidato(props) {
14 14
 
15
-    const auth = useAuth();
16
-
17
-    const CandidatoSchema = Yup.object().shape({
18
-        nombres:
19
-            Yup.string()
20
-                .min(2, 'Demasiado corto!')
21
-                .max(50, 'Demasiado largo!')
22
-                .required("Ingresa un nombre válido"),
23
-        apellidos:
24
-            Yup.string()
25
-                .required("Ingresa un apellido válido")
26
-                .min(2, 'Demasiado corto!').max(50, 'Demasiado Largo!'),
27
-        mail:
28
-            Yup.string()
29
-                .email("Correo no valido")
30
-                .required("Ingrea un puesto válido"),
31
-        sendmail:
32
-            Yup.bool()
33
-                .required('Ingresa un nivel educativo válido'),
34
-        nombrepuesto:
35
-            Yup.string('Ingresa un valor válido')
36
-                .required('Ingresa un nombre válido'),
37
-        nombreEmpresa:
38
-            Yup.string('Ingresa un valor válido')
39
-                .required('Ingresa un nombre válido'),
40
-    });
41
-
42
-    let { handleNext, handleBack, password, setPassword } = props
43
-
44
-    const formik = useFormik({
45
-        initialValues: {
46
-            nombres: password.nombres,
47
-            apellidos: password.apellidos,
48
-            sendmail: password.sendmail,
49
-            mail : password.mail,
50
-            nombrepuesto: password.nombrepuesto ? password.nombrepuesto: password.puesto[0].nombrepuesto,
51
-            nombreEmpresa: password.nombreEmpresa ? password.nombreEmpresa : auth.getProfile().nombre,
52
-        },
53
-        onSubmit: (fields) => {
54
-            setPassword({ ...password, ...fields })
55
-            handleNext()
56
-        },
57
-        validationSchema: CandidatoSchema,
58
-    });
59
-
60
-    const { errors, touched, handleSubmit, getFieldProps } = formik;
61
-
62
-    return (
63
-        <FormikProvider style={{ padding: 25 }} value={formik}>
64
-            <Form autoComplete="off" noValidate onSubmit={handleSubmit}>
65
-                <Stack spacing={3}>
66
-                    <Stack direction={{ xs: 'column', sm: 'row' }} spacing={2}>
67
-                        <TextField
68
-                            label="Nombre"
69
-                            fullWidth
70
-                            {...getFieldProps('nombres')}
71
-                            error={Boolean(touched.nombres && errors.nombres)}
72
-                            helperText={touched.nombres && errors.nombres}
73
-                        />
74
-
75
-                        <TextField
76
-                            label="Apellidos"
77
-                            fullWidth
78
-                            {...getFieldProps('apellidos')}
79
-                            error={Boolean(touched.apellidos && errors.apellidos)}
80
-                            helperText={touched.apellidos && errors.apellidos}
81
-                        />
82
-                    </Stack>
83
-
84
-                    <Stack direction={{ xs: 'column', sm: 'row' }} spacing={2}>
85
-                        <TextField
86
-                            fullWidth
87
-                            type="email"
88
-                            label="Correo Electronico"
89
-                            {...getFieldProps('mail')}
90
-                            error={Boolean(touched.mail && errors.mail)}
91
-                            helperText={touched.mail && errors.mail}
92
-                        />
93
-                        <FormGroup>
94
-
95
-                            <FormControlLabel
96
-                                control={
97
-                                    <Checkbox
98
-                                        {...getFieldProps('sendmail')}
99
-                                        defaultChecked
100
-                                        color="default"
101
-                                    />
102
-                                }
103
-                                label="Enviar Correo"
104
-                            />
105
-                        </FormGroup>
106
-                    </Stack>
107
-
108
-
109
-
110
-                    <Stack direction={{ xs: 'column', sm: 'row' }} spacing={4}>
111
-                        <TextField
112
-                            fullWidth
113
-                            type="text"
114
-                            label="Puesto"
115
-                            {...getFieldProps('nombrepuesto')}
116
-                            error={Boolean(touched.nombrepuesto && errors.nombrepuesto)}
117
-                            helperText={touched.nombrepuesto && errors.nombrepuesto}
118
-                        />
119
-                        <TextField
120
-                            fullWidth
121
-                            type="text"
122
-                            label="Empresa"
123
-                            {...getFieldProps('nombreEmpresa')}
124
-                            error={Boolean(touched.nombreEmpresa && errors.nombreEmpresa)}
125
-                            helperText={touched.nombreEmpresa && errors.nombreEmpresa}
126
-                        />
127
-                    </Stack>
128
-
129
-
130
-                    <Box sx={{ mb: 2 }}>
131
-                        <div style={{ paddingTop: 15 }}>
132
-                            <Button
133
-                                type="submit"
134
-                                className="registerBtn"
135
-                                variant="contained"
136
-                                sx={{ mt: 1, mr: 1 }}
137
-                            >
138
-                                {'Siguiente'}
139
-                            </Button>
140
-                            <Button
141
-                                disabled={false}
142
-                                onClick={handleBack}
143
-                                sx={{ mt: 1, mr: 1 }}
144
-                            >
145
-                                Regresar
146
-                            </Button>
147
-                        </div>
148
-                    </Box>
149
-
150
-                </Stack>
151
-            </Form>
152
-        </FormikProvider>
153
-    );
15
+  const CandidatoSchema = Yup.object().shape({
16
+    nombres:
17
+      Yup.string()
18
+        .min(2, 'Demasiado corto!')
19
+        .max(50, 'Demasiado largo!')
20
+        .required("Ingresa un nombre válido"),
21
+    apellidos:
22
+      Yup.string()
23
+        .required("Ingresa un apellido válido")
24
+        .min(2, 'Demasiado corto!').max(50, 'Demasiado Largo!'),
25
+    mail:
26
+      Yup.string()
27
+        .email("Correo no valido")
28
+        .required("Ingrea un puesto válido"),
29
+    sendmail:
30
+      Yup.bool()
31
+        .required('Ingresa un nivel educativo válido'),
32
+    nombrepuesto:
33
+      Yup.string('Ingresa un valor válido')
34
+        .required('Ingresa un nombre válido'),
35
+    nombreEmpresa:
36
+      Yup.string('Ingresa un valor válido')
37
+        .required('Ingresa un nombre válido'),
38
+  });
39
+
40
+  let { handleNext, handleBack, password, setPassword } = props
41
+
42
+  const formik = useFormik({
43
+    initialValues: {
44
+      nombres: password.nombres,
45
+      apellidos: password.apellidos,
46
+      sendmail: password.sendmail,
47
+      mail: password.mail,
48
+      nombrepuesto: password.nombrepuesto ? password.nombrepuesto : password.puesto[0].nombrepuesto,
49
+      // nombreEmpresa: password.nombreEmpresa ? password.nombreEmpresa : auth.getProfile().nombre,
50
+      nombreEmpresa: 'test'//password.nombreEmpresa ? password.nombreEmpresa : auth.getProfile().nombre,
51
+    },
52
+    onSubmit: (fields) => {
53
+      setPassword({ ...password, ...fields })
54
+      handleNext()
55
+    },
56
+    validationSchema: CandidatoSchema,
57
+  });
58
+
59
+  const { errors, touched, handleSubmit, getFieldProps } = formik;
60
+
61
+  return (
62
+    <FormikProvider style={{ padding: 25 }} value={formik}>
63
+      <Form autoComplete="off" noValidate onSubmit={handleSubmit}>
64
+
65
+        <Typography style={{ paddingBottom :15 }}>Ingresa uno o mas destinos</Typography>
66
+        <Divider/>
67
+
68
+        <Stack spacing={3}>
69
+          <Stack style={{paddingTop: 15}} direction={{ xs: 'column', sm: 'row' }} spacing={2}>
70
+            <TextField
71
+              label="Nombre"
72
+              fullWidth
73
+              {...getFieldProps('nombres')}
74
+              error={Boolean(touched.nombres && errors.nombres)}
75
+              helperText={touched.nombres && errors.nombres}
76
+            />
77
+
78
+            <TextField
79
+              label="Apellidos"
80
+              fullWidth
81
+              {...getFieldProps('apellidos')}
82
+              error={Boolean(touched.apellidos && errors.apellidos)}
83
+              helperText={touched.apellidos && errors.apellidos}
84
+            />
85
+          </Stack>
86
+
87
+          <Stack direction={{ xs: 'column', sm: 'row' }} spacing={2}>
88
+            <TextField
89
+              fullWidth
90
+              type="email"
91
+              label="Correo Electronico"
92
+              {...getFieldProps('mail')}
93
+              error={Boolean(touched.mail && errors.mail)}
94
+              helperText={touched.mail && errors.mail}
95
+            />
96
+
97
+          </Stack>
98
+
99
+          <MailTable />
100
+
101
+          <Box sx={{ mb: 2 }}>
102
+            <div style={{ paddingTop: 15 }}>
103
+              <Button
104
+                type="submit"
105
+                className="registerBtn"
106
+                variant="contained"
107
+                sx={{ mt: 1, mr: 1 }}
108
+              >
109
+                {'Siguiente'}
110
+              </Button>
111
+              <Button
112
+                disabled={false}
113
+                onClick={handleBack}
114
+                sx={{ mt: 1, mr: 1 }}
115
+              >
116
+                Regresar
117
+              </Button>
118
+            </div>
119
+          </Box>
120
+
121
+        </Stack>
122
+      </Form>
123
+    </FormikProvider>
124
+  );
154 125
 }

+ 105 - 105
src/Components/Password/Steps/puesto.js

@@ -15,116 +15,116 @@ import {
15 15
 
16 16
 import { useQuery } from 'react-query';
17 17
 import { Service } from '../../../Utils/HTTP.js'
18
-import useAuth from '../../../Auth/useAuth'
18
+// import useAuth from '../../../Auth/useAuth'
19
+import { useSelector } from 'react-redux'
19 20
 
20 21
 const delete_icon = <CheckBoxOutlineBlankIcon fontSize="small" />;
21 22
 const checkedIcon = <CheckBoxIcon fontSize="small" />;
22 23
 
23 24
 
24
-
25 25
 export function Puesto(props) {
26 26
 
27
-    const auth = useAuth();
28
-    const token = auth.getToken();
29
-
30
-    const PlazaScheme = Yup.object().shape({
31
-        puesto: 
32
-        Yup.array()
33
-        .required('Escoge un puesto valido')
34
-        .min(1,"Debes escoger por lo menos un puesto")
35
-        .max(1,"Debes escoger un solo puesto")
36
-    });
37
-    
38
-    const getPuestos = async () => {
39
-        let rest = new Service('/plaza/getall')
40
-        return rest.getQuery(token);
41
-    }
42
-
43
-    let { data } = useQuery('puestos', getPuestos)
44
-    let puestos = data ? data.data.map( ({ nombrepuesto, id  }) => ({ nombrepuesto, id } )) : []
45
-
46
-    let {  handleNext, handleBack, password, setPassword } = props
47
-
48
-    const formik = useFormik({
49
-        initialValues: {
50
-            puesto: password.puesto
51
-        },
52
-        onSubmit: (fields) => {
53
-            setPassword({
54
-                ...password,
55
-                puesto : fields.puesto
56
-            })
57
-            handleNext()
58
-        },
59
-        validationSchema: PlazaScheme,
60
-    });
61
-
62
-    const { errors, touched,handleSubmit, getFieldProps,setValues } = formik;
63
-
64
-    return (
65
-        <FormikProvider style={{ padding : 25 }} value={formik}>
66
-            <Form autoComplete="off" noValidate onSubmit={handleSubmit}>
67
-                <Stack spacing={2}>
68
-                    <Autocomplete
69
-                        disableCloseOnSelect={false}
70
-                        {...getFieldProps('puesto')}
71
-                        onChange={(_a,current_list,_c,_individual,_f) => {
72
-                            setValues({
73
-                                puesto:current_list
74
-                            })
75
-                        }}
76
-                        isOptionEqualToValue={(option, value) => option.nombrepuesto === value.nombrepuesto}
77
-                        multiple
78
-                        id="checkboxes-tags-demo"
79
-                        options={puestos}
80
-                        getOptionLabel={(option) => { 
81
-                            return option.nombrepuesto 
82
-                        }}
83
-                        renderOption={(props, option, { selected }) => (
84
-                            <li {...props}>
85
-                                <Checkbox
86
-                                    icon={delete_icon}
87
-                                    checkedIcon={checkedIcon}
88
-                                    style={{ marginRight: 8 }}
89
-                                    checked={selected}
90
-                                    />
91
-                                {option.nombrepuesto}
92
-                            </li>
93
-                        )}
94
-                        renderInput={(params) => (
95
-                            <TextField 
96
-                                // {...getFieldProps('puesto')}
97
-                                error={Boolean(touched.puesto && errors.puesto)}
98
-                                helperText={touched.puesto && errors.puesto}
99
-                                {...params} 
100
-                                label="Escribe el nombre del puesto" 
101
-                                placeholder="Puesto" 
102
-                            />
103
-                        )}
104
-                    />
105
-
106
-                    <Box sx={{ mb: 2 }}>
107
-                        <div style={{ paddingTop  : 15}}>
108
-                            <Button
109
-                                type="submit"
110
-                                className="registerBtn" 
111
-                                variant="contained"
112
-                                sx={{ mt: 1, mr: 1 }}
113
-                            >
114
-                                {'Siguiente'}
115
-                            </Button>
116
-                            <Button
117
-                                disabled={true}
118
-                                onClick={handleBack}
119
-                                sx={{ mt: 1, mr: 1 }}
120
-                            >
121
-                                Regresar
122
-                            </Button>
123
-                        </div>
124
-                    </Box>
125
-
126
-                </Stack>
127
-            </Form>
128
-        </FormikProvider>
129
-    );
27
+  const auth = useSelector((state) => state.token);
28
+  // const token = auth.getToken();
29
+
30
+  const PlazaScheme = Yup.object().shape({
31
+    puesto: 
32
+    Yup.array()
33
+    .required('Escoge un puesto valido')
34
+    .min(1,"Debes escoger por lo menos un puesto")
35
+    .max(1,"Debes escoger un solo puesto")
36
+  });
37
+
38
+  const getPuestos = async () => {
39
+    let rest = new Service('/plaza/getall')
40
+    return rest.getQuery(auth.token);
41
+  }
42
+
43
+  let { data } = useQuery('puestos', getPuestos)
44
+  let puestos = data ? data.data.map( ({ nombrepuesto, id  }) => ({ nombrepuesto, id } )) : []
45
+
46
+  let {  handleNext, handleBack, password, setPassword } = props
47
+
48
+  const formik = useFormik({
49
+    initialValues: {
50
+      puesto: password.puesto
51
+    },
52
+    onSubmit: (fields) => {
53
+      setPassword({
54
+        ...password,
55
+        puesto : fields.puesto
56
+      })
57
+      handleNext()
58
+    },
59
+    validationSchema: PlazaScheme,
60
+  });
61
+
62
+  const { errors, touched,handleSubmit, getFieldProps,setValues } = formik;
63
+
64
+  return (
65
+    <FormikProvider style={{ padding : 25 }} value={formik}>
66
+      <Form autoComplete="off" noValidate onSubmit={handleSubmit}>
67
+        <Stack spacing={2}>
68
+          <Autocomplete
69
+            disableCloseOnSelect={false}
70
+            {...getFieldProps('puesto')}
71
+            onChange={(_a,current_list,_c,_individual,_f) => {
72
+              setValues({
73
+                puesto:current_list
74
+              })
75
+            }}
76
+            isOptionEqualToValue={(option, value) => option.nombrepuesto === value.nombrepuesto}
77
+            multiple
78
+            id="checkboxes-tags-demo"
79
+            options={puestos}
80
+            getOptionLabel={(option) => { 
81
+              return option.nombrepuesto 
82
+            }}
83
+            renderOption={(props, option, { selected }) => (
84
+              <li {...props}>
85
+                <Checkbox
86
+                  icon={delete_icon}
87
+                  checkedIcon={checkedIcon}
88
+                  style={{ marginRight: 8 }}
89
+                  checked={selected}
90
+                  />
91
+                {option.nombrepuesto}
92
+              </li>
93
+            )}
94
+            renderInput={(params) => (
95
+              <TextField 
96
+                // {...getFieldProps('puesto')}
97
+                error={Boolean(touched.puesto && errors.puesto)}
98
+                helperText={touched.puesto && errors.puesto}
99
+                {...params} 
100
+                label="Escribe el nombre del puesto" 
101
+                placeholder="Puesto" 
102
+                />
103
+            )}
104
+            />
105
+
106
+          <Box sx={{ mb: 2 }}>
107
+            <div style={{ paddingTop  : 15}}>
108
+              <Button
109
+                type="submit"
110
+                className="registerBtn" 
111
+                variant="contained"
112
+                sx={{ mt: 1, mr: 1 }}
113
+              >
114
+                {'Siguiente'}
115
+              </Button>
116
+              <Button
117
+                disabled={true}
118
+                onClick={handleBack}
119
+                sx={{ mt: 1, mr: 1 }}
120
+              >
121
+                Regresar
122
+              </Button>
123
+            </div>
124
+          </Box>
125
+
126
+        </Stack>
127
+      </Form>
128
+    </FormikProvider>
129
+  );
130 130
 }

+ 87 - 88
src/Components/Password/Steps/puestoV2.js

@@ -9,95 +9,94 @@ import {
9 9
 
10 10
 import { useQuery } from 'react-query';
11 11
 import { Service } from '../../../Utils/HTTP.js'
12
-import useAuth from '../../../Auth/useAuth'
12
+import { useSelector } from 'react-query';
13 13
 
14 14
 
15 15
 export function Puesto(props) {
16
-    
17
-    const auth = useAuth();
18
-    const token = auth.getToken();
19
-
20
-    const PlazaScheme = Yup.object().shape({
21
-        puesto_id: 
22
-        Yup.number()
23
-        .positive('Escoge un puesto válido')
24
-        .required('Escoge un puesto válido')
25
-    });
26
-
27
-
28
-    const getPuestos = async () => {
29
-        let rest = new Service('/plaza/getall')
30
-        return rest.getQuery(token);
31
-    }
32
-
33
-    let { data } = useQuery('puetos', getPuestos)
34
-    console.log("puestos >>", data )
35
-
36
-    let {  handleNext, handleBack, password, setPassword } = props
37
-
38
-    const formik = useFormik({
39
-        initialValues: {
40
-            puesto_id: password.puesto_id
41
-        },
42
-        onSubmit: (fields) => {
43
-            setPassword({...password, ...fields})
44
-            handleNext()
45
-        },
46
-        validationSchema: PlazaScheme,
47
-    });
48
-
49
-    const [age, setAge] = React.useState('');
50
-
51
-    const handleChange = (event) => setAge(event.target.value);
52
-
53
-    const { handleSubmit, touched, errors, getFieldProps } = formik;
54
-
55
-    return (
56
-        <FormikProvider style={{ padding : 25 }} value={formik}>
57
-            <Form autoComplete="off" noValidate onSubmit={handleSubmit}>
58
-                <Stack spacing={2}>
59
-
60
-                    <FormControl fullWidth>
61
-                        <InputLabel id="demo-simple-select-label">Puestos</InputLabel>
62
-                        <Select
63
-                            labelId="demo-simple-select-label"
64
-                            id="demo-simple-select"
65
-                            value={age}
66
-                            label="Puestos"
67
-                            onChange={handleChange}
68
-                            {...getFieldProps('puesto_id')}
69
-                            error={Boolean(touched.puesto_id && errors.puesto_id)}
70
-                        >
71
-                            <MenuItem value={10}>Full Stack</MenuItem>
72
-                            <MenuItem value={20}>Web Developer</MenuItem>
73
-                            <MenuItem value={30}>Database Administrator</MenuItem>
74
-                        </Select>
75
-                    </FormControl>
76
-                    <label className="feedback_error">
77
-                        {touched.puesto_id && errors.puesto_id}
78
-                    </label>
79
-                    <Box sx={{ mb: 2 }}>
80
-                        <div style={{ paddingTop  : 15}}>
81
-                            <Button
82
-                                type="submit"
83
-                                className="registerBtn" 
84
-                                variant="contained"
85
-                                sx={{ mt: 1, mr: 1 }}
86
-                            >
87
-                                {'Siguiente'}
88
-                            </Button>
89
-                            <Button
90
-                                disabled={false}
91
-                                onClick={handleBack}
92
-                                sx={{ mt: 1, mr: 1 }}
93
-                            >
94
-                                Regresar
95
-                            </Button>
96
-                        </div>
97
-                    </Box>
98
-
99
-                </Stack>
100
-            </Form>
101
-        </FormikProvider>
102
-    );
16
+
17
+  const auth = useSelector((state) => state.token)
18
+
19
+  const PlazaScheme = Yup.object().shape({
20
+    puesto_id: 
21
+    Yup.number()
22
+    .positive('Escoge un puesto válido')
23
+    .required('Escoge un puesto válido')
24
+  });
25
+
26
+
27
+  const getPuestos = async () => {
28
+    let rest = new Service('/plaza/getall')
29
+    return rest.getQuery(auth.token);
30
+  }
31
+
32
+  let { data } = useQuery('puetos', getPuestos)
33
+  console.log("puestos >>", data )
34
+
35
+  let {  handleNext, handleBack, password, setPassword } = props
36
+
37
+  const formik = useFormik({
38
+    initialValues: {
39
+      puesto_id: password.puesto_id
40
+    },
41
+    onSubmit: (fields) => {
42
+      setPassword({...password, ...fields})
43
+      handleNext()
44
+    },
45
+    validationSchema: PlazaScheme,
46
+  });
47
+
48
+  const [age, setAge] = React.useState('');
49
+
50
+  const handleChange = (event) => setAge(event.target.value);
51
+
52
+  const { handleSubmit, touched, errors, getFieldProps } = formik;
53
+
54
+  return (
55
+    <FormikProvider style={{ padding : 25 }} value={formik}>
56
+      <Form autoComplete="off" noValidate onSubmit={handleSubmit}>
57
+        <Stack spacing={2}>
58
+
59
+          <FormControl fullWidth>
60
+            <InputLabel id="demo-simple-select-label">Puestos</InputLabel>
61
+            <Select
62
+              labelId="demo-simple-select-label"
63
+              id="demo-simple-select"
64
+              value={age}
65
+              label="Puestos"
66
+              onChange={handleChange}
67
+              {...getFieldProps('puesto_id')}
68
+              error={Boolean(touched.puesto_id && errors.puesto_id)}
69
+            >
70
+              <MenuItem value={10}>Full Stack</MenuItem>
71
+              <MenuItem value={20}>Web Developer</MenuItem>
72
+              <MenuItem value={30}>Database Administrator</MenuItem>
73
+            </Select>
74
+          </FormControl>
75
+          <label className="feedback_error">
76
+            {touched.puesto_id && errors.puesto_id}
77
+          </label>
78
+          <Box sx={{ mb: 2 }}>
79
+            <div style={{ paddingTop  : 15}}>
80
+              <Button
81
+                type="submit"
82
+                className="registerBtn" 
83
+                variant="contained"
84
+                sx={{ mt: 1, mr: 1 }}
85
+              >
86
+                {'Siguiente'}
87
+              </Button>
88
+              <Button
89
+                disabled={false}
90
+                onClick={handleBack}
91
+                sx={{ mt: 1, mr: 1 }}
92
+              >
93
+                Regresar
94
+              </Button>
95
+            </div>
96
+          </Box>
97
+
98
+        </Stack>
99
+      </Form>
100
+    </FormikProvider>
101
+  );
103 102
 }

+ 155 - 154
src/Components/Password/Steps/resume.jsx

@@ -11,6 +11,7 @@ import toast, { Toaster } from 'react-hot-toast';
11 11
 import { useMutation, useQueryClient } from 'react-query';
12 12
 import { Service } from '../../../Utils/HTTP.js'
13 13
 import useAuth from '../../../Auth/useAuth.js'
14
+import { useSelector } from 'react-query';
14 15
 
15 16
 import { createTheme, ThemeProvider } from '@mui/material/styles';
16 17
 
@@ -30,164 +31,164 @@ let theme = createTheme({
30 31
 
31 32
 export function Resume(props) {
32 33
 
33
-    let { handleBack, password: key, handleClose,handleReset } = props
34
-    const fmt = React.useRef({ weekday: 'long', year: 'numeric', month: 'short', day: 'numeric' })
35
-    const [pwdID, setPwdID] = React.useState(null);
36
-    const [loading, setLoading] = React.useState(false);
37
-    const auth = useAuth();
38
-    const token = auth.getToken();
39
-    const queryClient = useQueryClient();
40
-
41
-    const savePassword = async (body) => {
42
-        let rest = new Service('/contrasenia/create')
43
-        return await rest.postQuery(body, token)
34
+  let { handleBack, password: key, handleClose,handleReset } = props
35
+  const fmt = React.useRef({ weekday: 'long', year: 'numeric', month: 'short', day: 'numeric' })
36
+  const [pwdID, setPwdID] = React.useState(null);
37
+  const [loading, setLoading] = React.useState(false);
38
+  const auth = useSelector((state) => state.token)
39
+  // const token = auth.getToken();
40
+  const queryClient = useQueryClient();
41
+
42
+  const savePassword = async (body) => {
43
+    let rest = new Service('/contrasenia/create')
44
+    return await rest.postQuery(body, auth.token)
45
+  }
46
+
47
+  const saveCandidato = async (body) => {
48
+    let rest = new Service('/passwordcandidato/candidato')
49
+    return await rest.postQuery(body, auth.token)
50
+  }
51
+
52
+  const pwdMutation = useMutation('password', savePassword);
53
+  const candiMutation = useMutation('candidato', saveCandidato);
54
+
55
+  const saveStepper = () => {
56
+
57
+    setLoading(true);
58
+
59
+    let {
60
+      deadpwd, dateToActived, puesto, pwd,
61
+      nombres, apellidos, sendmail, nombrepuesto, nombreEmpresa,mail
62
+    } = key;
63
+    console.log("KEY: ", key)
64
+
65
+    let pwdBody = {
66
+      id: -1,
67
+      pwd: btoa(pwd),
68
+      link: "www.psicoadmin.com",
69
+      deadpwd: new Date(deadpwd).toISOString(),
70
+      state: 1,
71
+      dateToActived: new Date(dateToActived).toISOString(),
72
+      plaza_id: puesto[0].id
44 73
     }
45 74
 
46
-    const saveCandidato = async (body) => {
47
-        let rest = new Service('/passwordcandidato/candidato')
48
-        return await rest.postQuery(body, token)
49
-    }
50
-
51
-    const pwdMutation = useMutation('password', savePassword);
52
-    const candiMutation = useMutation('candidato', saveCandidato);
53
-
54
-    const saveStepper = () => {
55
-
56
-        setLoading(true);
57
-
58
-        let {
59
-            deadpwd, dateToActived, puesto, pwd,
60
-            nombres, apellidos, sendmail, nombrepuesto, nombreEmpresa,mail
61
-        } = key;
62
-        console.log("KEY: ", key)
63
-
64
-        let pwdBody = {
65
-            id: -1,
66
-            pwd: btoa(pwd),
67
-            link: "www.psicoadmin.com",
68
-            deadpwd: new Date(deadpwd).toISOString(),
69
-            state: 1,
70
-            dateToActived: new Date(dateToActived).toISOString(),
71
-            plaza_id: puesto[0].id
75
+    pwdMutation.mutate(pwdBody, {
76
+      onSuccess: (data) => {
77
+
78
+        let { id: password_id } = data.data;
79
+        setPwdID(password_id);
80
+
81
+        let candidatoBody = {
82
+          id: -1,
83
+          nombres,
84
+          apellidos,
85
+          sendmail: sendmail ? 1 : 0,
86
+          mail,
87
+          idContrasenia: password_id,
88
+          nombrepuesto,
89
+          nombreEmpresa
72 90
         }
73 91
 
74
-        pwdMutation.mutate(pwdBody, {
75
-            onSuccess: (data) => {
76
-
77
-                let { id: password_id } = data.data;
78
-                setPwdID(password_id);
79
-
80
-                let candidatoBody = {
81
-                    id: -1,
82
-                    nombres,
83
-                    apellidos,
84
-                    sendmail: sendmail ? 1 : 0,
85
-                    mail,
86
-                    idContrasenia: password_id,
87
-                    nombrepuesto,
88
-                    nombreEmpresa
89
-                }
90
-
91
-                candiMutation.mutate(candidatoBody, {
92
-                    onSuccess: (data) => {
93
-
94
-                        queryClient.invalidateQueries('passwords')
95
-                        toast.success("Contraseña agregada exitosamente!!")
96
-                        setTimeout(() => {
97
-                            console.log("OK LETS GO >> ", data,pwdID)
98
-                            setLoading(false);
99
-                            handleClose();
100
-                            handleReset();
101
-                        }, 1000)
102
-
103
-                    },
104
-                    onError: () => {
105
-                        toast.error("Ups!! error al crear el candidato")
106
-                        setLoading(false);
107
-                    }
108
-                })
109
-
110
-
111
-            },
112
-            onError: () => {
113
-                console.log("No se pudo guardar pwd")
114
-                setLoading(false);
115
-                toast.error("Ups!! Ocurrio un error, inténtalo más tarde")
116
-            }
92
+        candiMutation.mutate(candidatoBody, {
93
+          onSuccess: (data) => {
94
+
95
+            queryClient.invalidateQueries('passwords')
96
+            toast.success("Contraseña agregada exitosamente!!")
97
+            setTimeout(() => {
98
+              console.log("OK LETS GO >> ", data,pwdID)
99
+              setLoading(false);
100
+              handleClose();
101
+              handleReset();
102
+            }, 1000)
103
+
104
+          },
105
+          onError: () => {
106
+            toast.error("Ups!! error al crear el candidato")
107
+            setLoading(false);
108
+          }
117 109
         })
118
-    }
119 110
 
120
-    return (
121
-        <React.Fragment>
122
-            <ThemeProvider theme={theme}>
123
-                {loading ? (
124
-                    <Box sx={{ paddingBottom: 3 }}>
125
-                        <LinearProgress color="inherit" />
126
-                    </Box>
127
-                ) : null}
128
-                <Table>
129
-                    <thead>
130
-                        <tr>
131
-                            <th>{key.pwd}</th>
132
-                            <th>{btoa(key.pwd)}</th>
133
-                        </tr>
134
-                    </thead>
135
-                    <tbody>
136
-                        <tr>
137
-                            <td className="title_td">{"Candidato"}</td>
138
-                            <td colSpan={2}>{key.nombres + " " + key.apellidos} - {key.mail}</td>
139
-                        </tr>
140
-                        <tr>
141
-                            <td className="title_td">{"Puesto"}</td>
142
-                            <td colSpan={2}>{key.puesto.length > 0 ? key.puesto[0].nombrepuesto : ''}</td>
143
-                        </tr>
144
-                        <tr>
145
-                            <td className="title_td">{"Empresa"}</td>
146
-                            <td colSpan={2}>{key.nombreEmpresa}</td>
147
-                        </tr>
148
-                        <tr>
149
-                            <td className="title_td">{"Fecha Activación"}</td>
150
-                            <td colSpan={2}>{new Date(key.dateToActived).toLocaleDateString('es-GT', fmt.current)}</td>
151
-                        </tr>
152
-                        <tr>
153
-                            <td className="title_td">{"Fecha de Vencimiento"}</td>
154
-                            <td colSpan={2}>{new Date(key.deadpwd).toLocaleDateString('es-GT', fmt.current)}</td>
155
-                        </tr>
156
-                    </tbody>
157
-                </Table>
158
-
159
-
160
-                <Box sx={{ mb: 2 }}>
161
-                    <div style={{ paddingTop: 15 }}>
162
-                        <Button
163
-                            disabled={loading}
164
-                            style={{
165
-                                color: loading ? 'white' : ''
166
-                            }}
167
-                            onClick={saveStepper}
168
-                            className="registerBtn"
169
-                            variant="contained"
170
-                            sx={{ mt: 1, mr: 1 }}
171
-                        >
172
-                            {'Guardar'}
173
-                        </Button>
174
-                        <Button
175
-                            disabled={loading}
176
-                            onClick={handleBack}
177
-                            sx={{ mt: 1, mr: 1 }}
178
-                        >
179
-                            Regresar
180
-                        </Button>
181
-                    </div>
182
-                </Box>
183
-            </ThemeProvider>
184
-            <Backdrop
185
-                sx={{ color: '#fd4b4b', zIndex: (theme) => theme.zIndex.drawer + 1 }}
186
-                open={loading}
187
-                onClick={() => console.log("close fetching")} >
188
-                <CircularProgress color="inherit" />
189
-            </Backdrop>
190
-            <Toaster position="bottom-right" />
191
-        </React.Fragment>
192
-    )
111
+
112
+      },
113
+      onError: () => {
114
+        console.log("No se pudo guardar pwd")
115
+        setLoading(false);
116
+        toast.error("Ups!! Ocurrio un error, inténtalo más tarde")
117
+      }
118
+    })
119
+  }
120
+
121
+  return (
122
+    <React.Fragment>
123
+      <ThemeProvider theme={theme}>
124
+        {loading ? (
125
+          <Box sx={{ paddingBottom: 3 }}>
126
+            <LinearProgress color="inherit" />
127
+          </Box>
128
+        ) : null}
129
+        <Table>
130
+          <thead>
131
+            <tr>
132
+              <th>{key.pwd}</th>
133
+              <th>{btoa(key.pwd)}</th>
134
+            </tr>
135
+          </thead>
136
+          <tbody>
137
+            <tr>
138
+              <td className="title_td">{"Candidato"}</td>
139
+              <td colSpan={2}>{key.nombres + " " + key.apellidos} - {key.mail}</td>
140
+            </tr>
141
+            <tr>
142
+              <td className="title_td">{"Puesto"}</td>
143
+              <td colSpan={2}>{key.puesto.length > 0 ? key.puesto[0].nombrepuesto : ''}</td>
144
+            </tr>
145
+            <tr>
146
+              <td className="title_td">{"Empresa"}</td>
147
+              <td colSpan={2}>{key.nombreEmpresa}</td>
148
+            </tr>
149
+            <tr>
150
+              <td className="title_td">{"Fecha Activación"}</td>
151
+              <td colSpan={2}>{new Date(key.dateToActived).toLocaleDateString('es-GT', fmt.current)}</td>
152
+            </tr>
153
+            <tr>
154
+              <td className="title_td">{"Fecha de Vencimiento"}</td>
155
+              <td colSpan={2}>{new Date(key.deadpwd).toLocaleDateString('es-GT', fmt.current)}</td>
156
+            </tr>
157
+          </tbody>
158
+        </Table>
159
+
160
+
161
+        <Box sx={{ mb: 2 }}>
162
+          <div style={{ paddingTop: 15 }}>
163
+            <Button
164
+              disabled={loading}
165
+              style={{
166
+                color: loading ? 'white' : ''
167
+              }}
168
+              onClick={saveStepper}
169
+              className="registerBtn"
170
+              variant="contained"
171
+              sx={{ mt: 1, mr: 1 }}
172
+            >
173
+              {'Guardar'}
174
+            </Button>
175
+            <Button
176
+              disabled={loading}
177
+              onClick={handleBack}
178
+              sx={{ mt: 1, mr: 1 }}
179
+            >
180
+              Regresar
181
+            </Button>
182
+          </div>
183
+        </Box>
184
+      </ThemeProvider>
185
+      <Backdrop
186
+        sx={{ color: '#fd4b4b', zIndex: (theme) => theme.zIndex.drawer + 1 }}
187
+        open={loading}
188
+        onClick={() => console.log("close fetching")} >
189
+        <CircularProgress color="inherit" />
190
+      </Backdrop>
191
+      <Toaster position="bottom-right" />
192
+    </React.Fragment>
193
+  )
193 194
 }

+ 2 - 1
src/Pages/ContrasV2.jsx

@@ -9,6 +9,7 @@ import { TableStyle, TextLabels } from '../Components/Password/TableStyle'
9 9
 import { useQuery } from 'react-query';
10 10
 import { Service } from '../Utils/HTTP.js'
11 11
 import { useSelector } from 'react-redux';
12
+import  { Loading } from '../Components/Generics/loading'
12 13
 
13 14
 export function Contrasv2() {
14 15
 
@@ -23,7 +24,7 @@ export function Contrasv2() {
23 24
   console.log(data,status)
24 25
 
25 26
   if(status === 'loading'){
26
-    return <h1>loading...</h1>
27
+    return <Loading/>
27 28
   }
28 29
 
29 30
   const options = {