Pārlūkot izejas kodu

add user to list in password

amenpunk 3 gadi atpakaļ
vecāks
revīzija
d9be516759

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

@@ -179,7 +179,6 @@ function Manual(props) {
                     fullWidth
                     {...getFieldProps('nombrepuesto')}
                     error={Boolean(touched.nombrepuesto && errors.nombrepuesto)}
-                    helperText={touched.nombrepuesto && errors.nombrepuesto}
                     />
 
                   <FormControl fullWidth>
@@ -190,7 +189,6 @@ function Manual(props) {
                       label="Puesto Superior"
                       onChange={changePuestoSup}
                       {...getFieldProps('puestosuperior')}
-                      helperText={touched.puestosuperior && errors.puestosuperior}
                       error={Boolean(touched.puestosuperior && errors.puestosuperior)} >
                       {
                       data ?

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

@@ -2,7 +2,7 @@ import { Modal } from 'react-bootstrap'
 import * as React from 'react';
 
 import {
-  Box, Stepper, Step, Fade,
+  Box, Stepper, Step,
   StepLabel, Button, Typography
 } from '@mui/material'
 
@@ -24,12 +24,14 @@ export function HelpModal(props) {
     pwd: "",
     deadpwd: now.current,
     dateToActived: now.current,
-    nombres: "",
-    apellidos: "",
-    mail: "",
     sendmail: true,
     nombrepuesto: null,
     nombreEmpresa: null,
+    candidatos : [{
+      'nombres': 'ming',
+      'apellidos': 'mecca',
+      'mail': 'ming@gmail.com',
+    }]
   });
 
   const isStepSkipped = (step) => {
@@ -57,9 +59,6 @@ export function HelpModal(props) {
       pwd: "",
       deadpwd: now.current,
       dateToActived: now.current,
-      nombres: "",
-      apellidos: "",
-      mail: "",
       sendmail: true,
       nombrepuesto: null,
       nombreEmpresa: null,

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

@@ -7,21 +7,12 @@ import TableHead from '@mui/material/TableHead';
 import TableRow from '@mui/material/TableRow';
 import Paper from '@mui/material/Paper';
 
-import { RemoveSharp, DisabledByDefault } from '@mui/icons-material'
+import { DisabledByDefault } from '@mui/icons-material'
 
-function createData(name, calories, fat) {
-  return { name, calories, fat, icon : <DisabledByDefault color="primary"/>};
-}
+export function MailTable(props) {
 
-const rows = [
-  createData('Frozen yoghurt', 159, 6.0, ),
-  createData('Ice cream sandwich', 237, 9.0),
-  createData('Eclair', 262, 16.0, ),
-  createData('Cupcake', 305, 3.7,),
-  createData('Gingerbread', 356,21),
-];
+  let { users, remove } = props;
 
-export function MailTable() {
   return (
     <TableContainer component={Paper}>
       <Table aria-label="simple table">
@@ -34,14 +25,16 @@ export function MailTable() {
           </TableRow>
         </TableHead>
         <TableBody>
-          {rows.map((row) => (
-            <TableRow key={row.name} sx={{ '&:last-child td, &:last-child th': { border: 0 } }} >
+          {users.map((row,i) => (
+            <TableRow key={i} sx={{ '&:last-child td, &:last-child th': { border: 0 } }} >
               <TableCell component="th" scope="row">
-                {row.name}
+                {row.mail}
+              </TableCell>
+              <TableCell align="right">{row.nombres}</TableCell>
+              <TableCell align="right">{row.apellidos}</TableCell>
+              <TableCell align="right">
+                <DisabledByDefault onClick={() => remove(row.mail)} color="primary"/>
               </TableCell>
-              <TableCell align="right">{row.calories}</TableCell>
-              <TableCell align="right">{row.fat}</TableCell>
-              <TableCell align="right">{row.icon}</TableCell>
             </TableRow>
           ))}
         </TableBody>

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

@@ -3,15 +3,17 @@ import * as Yup from 'yup';
 import { useFormik, Form, FormikProvider } from 'formik';
 
 import {
-  Box, Button, FormControlLabel, Checkbox,
-  Stack, TextField, FormGroup, Divider, Typography,
+  Box, Button, Stack, TextField, Divider, Typography,
 } from '@mui/material';
 
+import { AddCircle } from '@mui/icons-material/';
+
 import { MailTable } from './MailTable';
 
 
 export function Candidato(props) {
 
+
   const CandidatoSchema = Yup.object().shape({
     nombres:
       Yup.string()
@@ -41,13 +43,14 @@ export function Candidato(props) {
 
   const formik = useFormik({
     initialValues: {
-      nombres: password.nombres,
-      apellidos: password.apellidos,
-      sendmail: password.sendmail,
-      mail: password.mail,
+      nombres: "",
+      apellidos: "",
+      sendmail: "",
+      mail: "",
+      candidatos : password.candidatos ? password.candidatos : [],
       nombrepuesto: password.nombrepuesto ? password.nombrepuesto : password.puesto[0].nombrepuesto,
-      // nombreEmpresa: password.nombreEmpresa ? password.nombreEmpresa : auth.getProfile().nombre,
       nombreEmpresa: 'test'//password.nombreEmpresa ? password.nombreEmpresa : auth.getProfile().nombre,
+      // nombreEmpresa: password.nombreEmpresa ? password.nombreEmpresa : auth.getProfile().nombre,
     },
     onSubmit: (fields) => {
       setPassword({ ...password, ...fields })
@@ -56,7 +59,26 @@ export function Candidato(props) {
     validationSchema: CandidatoSchema,
   });
 
-  const { errors, touched, handleSubmit, getFieldProps } = formik;
+  const { errors, touched, handleSubmit, getFieldProps, values } = formik;
+
+  const addToList = () => {
+    let user = {
+      'nombres': values.nombres,
+      'apellidos': values.apellidos,
+      'mail': values.mail,
+    }
+    let new_users = [...password.candidatos, user ]
+
+    setPassword({...password, candidatos: new_users })
+
+    console.log(values);
+  }
+
+  const removeFromList = (umail) => {
+    let without = password.candidatos.filter( user => user.mail !== umail )
+    setPassword({...password, candidatos: without })
+  }
+
 
   return (
     <FormikProvider style={{ padding: 25 }} value={formik}>
@@ -94,9 +116,16 @@ export function Candidato(props) {
               helperText={touched.mail && errors.mail}
             />
 
+            <Button onClick={addToList}>
+              <AddCircle/>
+            </Button>
+
           </Stack>
 
-          <MailTable />
+          <MailTable 
+            remove={removeFromList} 
+            users={password.candidatos}
+            />
 
           <Box sx={{ mb: 2 }}>
             <div style={{ paddingTop: 15 }}>