-
Notifications
You must be signed in to change notification settings - Fork 649
Expand file tree
/
Copy pathCustomerTable.jsx
More file actions
157 lines (150 loc) · 5.9 KB
/
CustomerTable.jsx
File metadata and controls
157 lines (150 loc) · 5.9 KB
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
import PropTypes from 'prop-types';
// material-ui
import {
Table,
TableBody,
TableCell,
TableContainer,
TableHead,
TableRow,
Chip,
Button,
Stack,
Typography,
Box,
Divider
} from '@mui/material';
// ==============================|| CRM - TABLA DE CLIENTES PREMIUM ||============================== //
export default function CustomerTable({ clientes, setClientes, onDelete }) {
// Mapeo de estilos por estado para mayor limpieza
const getStatusStyle = (estado) => {
const styles = {
'En Proceso': { color: 'primary', label: 'En Seguimiento' },
'Descartado': { color: 'error', label: 'Cerrado / Perdido' },
'Default': { color: 'secondary', label: estado }
};
return styles[estado] || styles['Default'];
};
return (
<Box>
<TableContainer>
<Table sx={{ minWidth: 700 }} aria-label="tabla de prospectos">
<TableHead sx={{ bgcolor: 'grey.50' }}>
<TableRow>
<TableCell sx={{ py: 2 }}>
<Typography variant="overline" sx={{ fontWeight: 700, color: 'text.secondary' }}>
Empresa / Cliente
</Typography>
</TableCell>
<TableCell>
<Typography variant="overline" sx={{ fontWeight: 700, color: 'text.secondary' }}>
Estado Actual
</Typography>
</TableCell>
<TableCell align="right">
<Typography variant="overline" sx={{ fontWeight: 700, color: 'text.secondary' }}>
Valor del Trato
</Typography>
</TableCell>
<TableCell align="center">
<Typography variant="overline" sx={{ fontWeight: 700, color: 'text.secondary' }}>
Flujo de Trabajo
</Typography>
</TableCell>
<TableCell align="right" />
</TableRow>
</TableHead>
<TableBody>
{clientes.map((row) => {
const status = getStatusStyle(row.estado);
return (
<TableRow key={row._id} hover sx={{ '&:last-child td, &:last-child th': { border: 0 } }}>
<TableCell>
<Stack spacing={0.5}>
<Typography variant="subtitle1" sx={{ color: 'primary.main', fontWeight: 600 }}>
{row.nombre}
</Typography>
<Typography variant="caption" color="text.secondary">
ID: {row._id.slice(-6).toUpperCase()}
</Typography>
</Stack>
</TableCell>
<TableCell>
<Chip
label={status.label}
size="small"
color={status.color}
variant="light" // Estilo Mantis: fondo suave, texto fuerte
sx={{ borderRadius: '4px', fontWeight: 600, fontSize: '0.7rem' }}
/>
</TableCell>
<TableCell align="right">
<Typography variant="subtitle1" sx={{ fontFamily: 'monospace', fontWeight: 700 }}>
${row.valor?.toLocaleString('en-US', { minimumFractionDigits: 2 })}
</Typography>
</TableCell>
<TableCell align="center">
<Stack direction="row" spacing={0.5} justifyContent="center">
<Button
size="small"
variant={row.estado === 'En Proceso' ? 'contained' : 'text'}
color="primary"
disableElevation
onClick={() => setClientes(row._id, 'En Proceso')}
sx={{ fontSize: '0.75rem', px: 1 }}
>
Activar
</Button>
<Divider orientation="vertical" flexItem sx={{ mx: 0.5, height: 15, alignSelf: 'center' }} />
<Button
size="small"
variant={row.estado === 'Descartado' ? 'contained' : 'text'}
color="inherit"
onClick={() => setClientes(row._id, 'Descartado')}
sx={{ fontSize: '0.75rem', px: 1, color: 'text.secondary' }}
>
Archivar
</Button>
</Stack>
</TableCell>
<TableCell align="right">
<Button
size="small"
variant="text"
color="error"
onClick={() => onDelete(row._id)}
sx={{
minWidth: 'auto',
fontSize: '0.7rem',
'&:hover': { bgcolor: 'error.lighter', fontWeight: 'bold' }
}}
>
ELIMINAR
</Button>
</TableCell>
</TableRow>
);
})}
{clientes.length === 0 && (
<TableRow>
<TableCell colSpan={5} align="center" sx={{ py: 10 }}>
<Stack alignItems="center" spacing={1}>
<Typography variant="h5" color="text.secondary">📪</Typography>
<Typography variant="body2" color="text.secondary">
No se encontraron registros activos en el sistema.
</Typography>
</Stack>
</TableCell>
</TableRow>
)}
</TableBody>
</Table>
</TableContainer>
</Box>
);
}
CustomerTable.propTypes = {
clientes: PropTypes.array.isRequired,
setClientes: PropTypes.func.isRequired,
onDelete: PropTypes.func.isRequired
};