All files / client/empleados index.tsx

100% Statements 134/134
100% Branches 2/2
100% Functions 1/1
100% Lines 134/134

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 1351x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x  
import * as React from "react";
import {
  List,
  Datagrid,
  TextField,
  EditButton,
  DeleteButton,
  Create,
  SimpleForm,
  TextInput,
  NumberInput,
  DateInput,
  Edit,
  Show,
  SimpleShowLayout,
  DateField,
  NumberField,
  SelectInput,
  SelectField,
  Filter,
} from "react-admin";
import { AppBar, Toolbar, Typography, makeStyles } from "@material-ui/core";
 
const departamentos = [
  { id: "IT", name: "IT" },
  { id: "Recursos Humanos", name: "Recursos Humanos" },
  { id: "Ventas", name: "Ventas" },
  { id: "Marketing", name: "Marketing" },
];
 
const cargos = [
  { id: "Manager", name: "Manager" },
  { id: "Desarrollador", name: "Desarrollador" },
  { id: "Analista", name: "Analista" },
  { id: "Diseñador", name: "Diseñador" },
];
// Estilos personalizados para el AppBar
const useStyles = makeStyles(() => ({
  appBar: {
    backgroundColor: "#ff0000", // Color de fondo rojo
  },
  title: {
    flexGrow: 1,
  },
}));
 
const CustomAppBar: React.FC = () => {
  const classes = useStyles();
 
  return (
    <AppBar position="static" className={classes.appBar}>
      <Toolbar>
        <Typography variant="h6" className={classes.title}>
          LISTA DE EMPLEADOS
        </Typography>
        {/* Aquí puedes agregar más elementos de AppBar según tu diseño */}
      </Toolbar>
    </AppBar>
  );
};
 
const EmpleadoFilter: React.FC = (props) => (
  <Filter {...props}>
    <TextInput label="Nombre" source="nombre" alwaysOn />
  </Filter>
);
 
export const EmpleadoList: React.FC<any> = (props) => (
  <>
    <CustomAppBar /> {/* Incluye aquí tu AppBar personalizado */}
    <List {...props} filters={<EmpleadoFilter />} title="Lista de Empleados">
      <Datagrid>
        <TextField source="nombre" />
        <SelectField source="cargo" choices={cargos} />
        <SelectField source="departamento" choices={departamentos} />
        <DateField source="fechaContratacion" />
        <NumberField source="salario" />
        <TextField source="email" />
        <TextField source="telefono" />
        <EditButton />
        <DeleteButton />
      </Datagrid>
    </List>
  </>
);
 
export const EmpleadoEdit: React.FC<any> = (props) => (
  <>
    <CustomAppBar /> {/* Incluye aquí tu AppBar personalizado */}
    <Edit {...props}>
      <SimpleForm>
        <TextInput source="nombre" />
        <SelectInput source="cargo" choices={cargos} />
        <SelectInput source="departamento" choices={departamentos} />
        <TextInput source="email" />
        <TextInput source="telefono" />
      </SimpleForm>
    </Edit>
  </>
);
 
export const EmpleadoCreate: React.FC<any> = (props) => (
  <>
    <CustomAppBar />
    <Create {...props}>
      <SimpleForm>
        <TextInput source="nombre" />
        <SelectInput source="cargo" choices={cargos} />
        <SelectInput source="departamento" choices={departamentos} />
        <DateInput source="fechaContratacion" />
        <NumberInput source="salario" />
        <TextInput source="email" />
        <TextInput source="telefono" />
      </SimpleForm>
    </Create>
  </>
);
 
export const EmpleadoShow: React.FC<any> = (props) => (
  <>
    <CustomAppBar />
    <Show {...props}>
      <SimpleShowLayout>
        <TextField source="nombre" />
        <SelectField source="cargo" choices={cargos} />
        <SelectField source="departamento" choices={departamentos} />
        <DateField source="fechaContratacion" />
        <NumberField source="salario" />
        <TextField source="email" />
        <TextField source="telefono" />
      </SimpleShowLayout>
    </Show>
  </>
);