Browse Source

password resume style

amenpunk 2 years ago
parent
commit
1f59413259
3 changed files with 45 additions and 39 deletions
  1. 8 0
      src/App.css
  2. 5 19
      src/Components/Password/Steps/candidato.jsx
  3. 32 20
      src/Components/Password/Steps/resume.jsx

+ 8 - 0
src/App.css

352
   /* margin: 10px !important;  */
352
   /* margin: 10px !important;  */
353
   /* border-left: 5px solid var(--main); */
353
   /* border-left: 5px solid var(--main); */
354
 }
354
 }
355
+.table_password th{
356
+  font-weight: bold;
357
+  padding-top: 12px;
358
+  padding-bottom: 12px;
359
+  text-align: left;
360
+  background-color: var(--main);
361
+  color: white;
362
+}

+ 5 - 19
src/Components/Password/Steps/candidato.jsx

7
 } from '@mui/material';
7
 } from '@mui/material';
8
 
8
 
9
 import { AddCircle } from '@mui/icons-material/';
9
 import { AddCircle } from '@mui/icons-material/';
10
-
11
 import { MailTable } from './MailTable';
10
 import { MailTable } from './MailTable';
12
 
11
 
13
 
12
 
18
     nombres:
17
     nombres:
19
       Yup.string()
18
       Yup.string()
20
         .min(2, 'Demasiado corto!')
19
         .min(2, 'Demasiado corto!')
21
-        .max(50, 'Demasiado largo!')
22
-        .required("Ingresa un nombre válido"),
20
+        .max(50, 'Demasiado largo!'),
23
     apellidos:
21
     apellidos:
24
       Yup.string()
22
       Yup.string()
25
-        .required("Ingresa un apellido válido")
26
         .min(2, 'Demasiado corto!').max(50, 'Demasiado Largo!'),
23
         .min(2, 'Demasiado corto!').max(50, 'Demasiado Largo!'),
27
     mail:
24
     mail:
28
       Yup.string()
25
       Yup.string()
29
         .email("Correo no valido")
26
         .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
   });
27
   });
41
 
28
 
42
   let { handleNext, handleBack, password, setPassword } = props
29
   let { handleNext, handleBack, password, setPassword } = props
47
       apellidos: "",
34
       apellidos: "",
48
       sendmail: "",
35
       sendmail: "",
49
       mail: "",
36
       mail: "",
50
-      candidatos : password.candidatos ? password.candidatos : [],
51
       nombrepuesto: password.nombrepuesto ? password.nombrepuesto : password.puesto[0].nombrepuesto,
37
       nombrepuesto: password.nombrepuesto ? password.nombrepuesto : password.puesto[0].nombrepuesto,
52
       nombreEmpresa: 'test'//password.nombreEmpresa ? password.nombreEmpresa : auth.getProfile().nombre,
38
       nombreEmpresa: 'test'//password.nombreEmpresa ? password.nombreEmpresa : auth.getProfile().nombre,
53
       // nombreEmpresa: password.nombreEmpresa ? password.nombreEmpresa : auth.getProfile().nombre,
39
       // nombreEmpresa: password.nombreEmpresa ? password.nombreEmpresa : auth.getProfile().nombre,
54
     },
40
     },
55
-    onSubmit: (fields) => {
56
-      setPassword({ ...password, ...fields })
41
+    onSubmit: () => {
42
+      //setPassword({ ...password, ...fields })
57
       handleNext()
43
       handleNext()
58
     },
44
     },
59
     validationSchema: CandidatoSchema,
45
     validationSchema: CandidatoSchema,
60
   });
46
   });
61
 
47
 
62
-  const { errors, touched, handleSubmit, getFieldProps, values } = formik;
48
+  const { errors, touched, handleSubmit, getFieldProps, values, resetForm } = formik;
63
 
49
 
64
   const addToList = () => {
50
   const addToList = () => {
65
     let user = {
51
     let user = {
70
     let new_users = [...password.candidatos, user ]
56
     let new_users = [...password.candidatos, user ]
71
 
57
 
72
     setPassword({...password, candidatos: new_users })
58
     setPassword({...password, candidatos: new_users })
73
-
59
+    resetForm();
74
     console.log(values);
60
     console.log(values);
75
   }
61
   }
76
 
62
 

+ 32 - 20
src/Components/Password/Steps/resume.jsx

10
 
10
 
11
 import { useMutation, useQueryClient } from 'react-query';
11
 import { useMutation, useQueryClient } from 'react-query';
12
 import { Service } from '../../../Utils/HTTP.js'
12
 import { Service } from '../../../Utils/HTTP.js'
13
-import useAuth from '../../../Auth/useAuth.js'
14
-import { useSelector } from 'react-query';
13
+import { useSelector } from 'react-redux';
15
 
14
 
16
 import { createTheme, ThemeProvider } from '@mui/material/styles';
15
 import { createTheme, ThemeProvider } from '@mui/material/styles';
17
 
16
 
32
 export function Resume(props) {
31
 export function Resume(props) {
33
 
32
 
34
   let { handleBack, password: key, handleClose,handleReset } = props
33
   let { handleBack, password: key, handleClose,handleReset } = props
34
+
35
   const fmt = React.useRef({ weekday: 'long', year: 'numeric', month: 'short', day: 'numeric' })
35
   const fmt = React.useRef({ weekday: 'long', year: 'numeric', month: 'short', day: 'numeric' })
36
   const [pwdID, setPwdID] = React.useState(null);
36
   const [pwdID, setPwdID] = React.useState(null);
37
   const [loading, setLoading] = React.useState(false);
37
   const [loading, setLoading] = React.useState(false);
38
+
38
   const auth = useSelector((state) => state.token)
39
   const auth = useSelector((state) => state.token)
39
-  // const token = auth.getToken();
40
+  const profile = useSelector((state) => state.user.profile)
40
   const queryClient = useQueryClient();
41
   const queryClient = useQueryClient();
41
 
42
 
42
   const savePassword = async (body) => {
43
   const savePassword = async (body) => {
57
     setLoading(true);
58
     setLoading(true);
58
 
59
 
59
     let {
60
     let {
60
-      deadpwd, dateToActived, puesto, pwd,
61
-      nombres, apellidos, sendmail, nombrepuesto, nombreEmpresa,mail
61
+      deadpwd, dateToActived, puesto, 
62
+      pwd,nombreEmpresa,nombrepuesto, candidatos
62
     } = key;
63
     } = key;
63
-    console.log("KEY: ", key)
64
 
64
 
65
     let pwdBody = {
65
     let pwdBody = {
66
       id: -1,
66
       id: -1,
80
 
80
 
81
         let candidatoBody = {
81
         let candidatoBody = {
82
           id: -1,
82
           id: -1,
83
-          nombres,
84
-          apellidos,
85
-          sendmail: sendmail ? 1 : 0,
86
-          mail,
83
+          //nombres,
84
+          //apellidos,
85
+          //sendmail: sendmail ? 1 : 0,
86
+          //mail,
87
           idContrasenia: password_id,
87
           idContrasenia: password_id,
88
           nombrepuesto,
88
           nombrepuesto,
89
           nombreEmpresa
89
           nombreEmpresa
118
     })
118
     })
119
   }
119
   }
120
 
120
 
121
+  const getLi = (user) => {
122
+    return ( 
123
+      <li style={{ listStyleType: 'none'}}>
124
+        {user.nombres + " " + user.apellidos} - {user.mail}
125
+      </li> 
126
+    )
127
+   }
128
+
121
   return (
129
   return (
122
     <React.Fragment>
130
     <React.Fragment>
123
       <ThemeProvider theme={theme}>
131
       <ThemeProvider theme={theme}>
128
         ) : null}
136
         ) : null}
129
         <Table>
137
         <Table>
130
           <thead>
138
           <thead>
131
-            <tr>
132
-              <th>{key.pwd}</th>
133
-              <th>{btoa(key.pwd)}</th>
139
+            <tr className="table_password">
140
+              <th>{"Contraseña: "}</th>
141
+              <th>{ key.pwd } - {btoa(key.pwd)}</th>
134
             </tr>
142
             </tr>
135
           </thead>
143
           </thead>
136
           <tbody>
144
           <tbody>
137
             <tr>
145
             <tr>
138
-              <td className="title_td">{"Candidato"}</td>
139
-              <td colSpan={2}>{key.nombres + " " + key.apellidos} - {key.mail}</td>
146
+              <td className="title_td">{"Candidatos:"}</td>
147
+              <td colSpan={2}>
148
+                <ul style={{ margin:0, padding:0}}>
149
+                  {key.candidatos.map(u => getLi(u))}
150
+                </ul>
151
+                </td>
140
             </tr>
152
             </tr>
141
             <tr>
153
             <tr>
142
-              <td className="title_td">{"Puesto"}</td>
154
+              <td className="title_td">{"Puesto:"}</td>
143
               <td colSpan={2}>{key.puesto.length > 0 ? key.puesto[0].nombrepuesto : ''}</td>
155
               <td colSpan={2}>{key.puesto.length > 0 ? key.puesto[0].nombrepuesto : ''}</td>
144
             </tr>
156
             </tr>
145
             <tr>
157
             <tr>
146
-              <td className="title_td">{"Empresa"}</td>
147
-              <td colSpan={2}>{key.nombreEmpresa}</td>
158
+              <td className="title_td">{"Empresa:"}</td>
159
+              <td colSpan={2}>{profile.nombre}</td>
148
             </tr>
160
             </tr>
149
             <tr>
161
             <tr>
150
-              <td className="title_td">{"Fecha Activación"}</td>
162
+              <td className="title_td">{"Fecha Activación:"}</td>
151
               <td colSpan={2}>{new Date(key.dateToActived).toLocaleDateString('es-GT', fmt.current)}</td>
163
               <td colSpan={2}>{new Date(key.dateToActived).toLocaleDateString('es-GT', fmt.current)}</td>
152
             </tr>
164
             </tr>
153
             <tr>
165
             <tr>
154
-              <td className="title_td">{"Fecha de Vencimiento"}</td>
166
+              <td className="title_td">{"Fecha de Vencimiento:"}</td>
155
               <td colSpan={2}>{new Date(key.deadpwd).toLocaleDateString('es-GT', fmt.current)}</td>
167
               <td colSpan={2}>{new Date(key.deadpwd).toLocaleDateString('es-GT', fmt.current)}</td>
156
             </tr>
168
             </tr>
157
           </tbody>
169
           </tbody>