Browse Source

add user to list in password

amenpunk 2 years ago
parent
commit
d9be516759

+ 0 - 2
src/Components/Modal/AgregarManual.js

@@ -179,7 +179,6 @@ function Manual(props) {
179 179
                     fullWidth
180 180
                     {...getFieldProps('nombrepuesto')}
181 181
                     error={Boolean(touched.nombrepuesto && errors.nombrepuesto)}
182
-                    helperText={touched.nombrepuesto && errors.nombrepuesto}
183 182
                     />
184 183
 
185 184
                   <FormControl fullWidth>
@@ -190,7 +189,6 @@ function Manual(props) {
190 189
                       label="Puesto Superior"
191 190
                       onChange={changePuestoSup}
192 191
                       {...getFieldProps('puestosuperior')}
193
-                      helperText={touched.puestosuperior && errors.puestosuperior}
194 192
                       error={Boolean(touched.puestosuperior && errors.puestosuperior)} >
195 193
                       {
196 194
                       data ?

+ 6 - 7
src/Components/Modal/PasswordModal.jsx

@@ -2,7 +2,7 @@ import { Modal } from 'react-bootstrap'
2 2
 import * as React from 'react';
3 3
 
4 4
 import {
5
-  Box, Stepper, Step, Fade,
5
+  Box, Stepper, Step,
6 6
   StepLabel, Button, Typography
7 7
 } from '@mui/material'
8 8
 
@@ -24,12 +24,14 @@ export function HelpModal(props) {
24 24
     pwd: "",
25 25
     deadpwd: now.current,
26 26
     dateToActived: now.current,
27
-    nombres: "",
28
-    apellidos: "",
29
-    mail: "",
30 27
     sendmail: true,
31 28
     nombrepuesto: null,
32 29
     nombreEmpresa: null,
30
+    candidatos : [{
31
+      'nombres': 'ming',
32
+      'apellidos': 'mecca',
33
+      'mail': 'ming@gmail.com',
34
+    }]
33 35
   });
34 36
 
35 37
   const isStepSkipped = (step) => {
@@ -57,9 +59,6 @@ export function HelpModal(props) {
57 59
       pwd: "",
58 60
       deadpwd: now.current,
59 61
       dateToActived: now.current,
60
-      nombres: "",
61
-      apellidos: "",
62
-      mail: "",
63 62
       sendmail: true,
64 63
       nombrepuesto: null,
65 64
       nombreEmpresa: null,

+ 11 - 18
src/Components/Password/Steps/MailTable.jsx

@@ -7,21 +7,12 @@ import TableHead from '@mui/material/TableHead';
7 7
 import TableRow from '@mui/material/TableRow';
8 8
 import Paper from '@mui/material/Paper';
9 9
 
10
-import { RemoveSharp, DisabledByDefault } from '@mui/icons-material'
10
+import { DisabledByDefault } from '@mui/icons-material'
11 11
 
12
-function createData(name, calories, fat) {
13
-  return { name, calories, fat, icon : <DisabledByDefault color="primary"/>};
14
-}
12
+export function MailTable(props) {
15 13
 
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
-];
14
+  let { users, remove } = props;
23 15
 
24
-export function MailTable() {
25 16
   return (
26 17
     <TableContainer component={Paper}>
27 18
       <Table aria-label="simple table">
@@ -34,14 +25,16 @@ export function MailTable() {
34 25
           </TableRow>
35 26
         </TableHead>
36 27
         <TableBody>
37
-          {rows.map((row) => (
38
-            <TableRow key={row.name} sx={{ '&:last-child td, &:last-child th': { border: 0 } }} >
28
+          {users.map((row,i) => (
29
+            <TableRow key={i} sx={{ '&:last-child td, &:last-child th': { border: 0 } }} >
39 30
               <TableCell component="th" scope="row">
40
-                {row.name}
31
+                {row.mail}
32
+              </TableCell>
33
+              <TableCell align="right">{row.nombres}</TableCell>
34
+              <TableCell align="right">{row.apellidos}</TableCell>
35
+              <TableCell align="right">
36
+                <DisabledByDefault onClick={() => remove(row.mail)} color="primary"/>
41 37
               </TableCell>
42
-              <TableCell align="right">{row.calories}</TableCell>
43
-              <TableCell align="right">{row.fat}</TableCell>
44
-              <TableCell align="right">{row.icon}</TableCell>
45 38
             </TableRow>
46 39
           ))}
47 40
         </TableBody>

+ 38 - 9
src/Components/Password/Steps/candidato.jsx

@@ -3,15 +3,17 @@ 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, Divider, Typography,
6
+  Box, Button, Stack, TextField, Divider, Typography,
8 7
 } from '@mui/material';
9 8
 
9
+import { AddCircle } from '@mui/icons-material/';
10
+
10 11
 import { MailTable } from './MailTable';
11 12
 
12 13
 
13 14
 export function Candidato(props) {
14 15
 
16
+
15 17
   const CandidatoSchema = Yup.object().shape({
16 18
     nombres:
17 19
       Yup.string()
@@ -41,13 +43,14 @@ export function Candidato(props) {
41 43
 
42 44
   const formik = useFormik({
43 45
     initialValues: {
44
-      nombres: password.nombres,
45
-      apellidos: password.apellidos,
46
-      sendmail: password.sendmail,
47
-      mail: password.mail,
46
+      nombres: "",
47
+      apellidos: "",
48
+      sendmail: "",
49
+      mail: "",
50
+      candidatos : password.candidatos ? password.candidatos : [],
48 51
       nombrepuesto: password.nombrepuesto ? password.nombrepuesto : password.puesto[0].nombrepuesto,
49
-      // nombreEmpresa: password.nombreEmpresa ? password.nombreEmpresa : auth.getProfile().nombre,
50 52
       nombreEmpresa: 'test'//password.nombreEmpresa ? password.nombreEmpresa : auth.getProfile().nombre,
53
+      // nombreEmpresa: password.nombreEmpresa ? password.nombreEmpresa : auth.getProfile().nombre,
51 54
     },
52 55
     onSubmit: (fields) => {
53 56
       setPassword({ ...password, ...fields })
@@ -56,7 +59,26 @@ export function Candidato(props) {
56 59
     validationSchema: CandidatoSchema,
57 60
   });
58 61
 
59
-  const { errors, touched, handleSubmit, getFieldProps } = formik;
62
+  const { errors, touched, handleSubmit, getFieldProps, values } = formik;
63
+
64
+  const addToList = () => {
65
+    let user = {
66
+      'nombres': values.nombres,
67
+      'apellidos': values.apellidos,
68
+      'mail': values.mail,
69
+    }
70
+    let new_users = [...password.candidatos, user ]
71
+
72
+    setPassword({...password, candidatos: new_users })
73
+
74
+    console.log(values);
75
+  }
76
+
77
+  const removeFromList = (umail) => {
78
+    let without = password.candidatos.filter( user => user.mail !== umail )
79
+    setPassword({...password, candidatos: without })
80
+  }
81
+
60 82
 
61 83
   return (
62 84
     <FormikProvider style={{ padding: 25 }} value={formik}>
@@ -94,9 +116,16 @@ export function Candidato(props) {
94 116
               helperText={touched.mail && errors.mail}
95 117
             />
96 118
 
119
+            <Button onClick={addToList}>
120
+              <AddCircle/>
121
+            </Button>
122
+
97 123
           </Stack>
98 124
 
99
-          <MailTable />
125
+          <MailTable 
126
+            remove={removeFromList} 
127
+            users={password.candidatos}
128
+            />
100 129
 
101 130
           <Box sx={{ mb: 2 }}>
102 131
             <div style={{ paddingTop: 15 }}>