50 lines
1.8 KiB
TypeScript
50 lines
1.8 KiB
TypeScript
import { Alumno, AlumnoSancion } from "@/app/types/sanction";
|
|
|
|
interface Props {
|
|
alumnoSanciones: AlumnoSancion[],
|
|
alumno?: Alumno
|
|
}
|
|
|
|
export default function TableSanction({ alumnoSanciones, alumno }: Props) {
|
|
|
|
const calcularFechaFin = (fechaInicio: string, duracionSemanas: number) => {
|
|
const fecha = new Date(fechaInicio);
|
|
fecha.setDate(fecha.getDate() + duracionSemanas * 7);
|
|
return fecha.toLocaleDateString();
|
|
};
|
|
|
|
return (
|
|
<div style={{ margin: "1rem 0" }}>
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>Cuenta</th>
|
|
<th>Motivo de la sanción</th>
|
|
<th>Duración (Semanas)</th>
|
|
<th>Fecha Sanción</th>
|
|
<th>Podrá utilizar el servicio hasta</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{alumnoSanciones.length > 0 ? (
|
|
alumnoSanciones.map((item) => (
|
|
<tr key={item.id_alumno_sancion}>
|
|
<td>{alumno?.id_cuenta}</td>
|
|
<td>{item.sancion.sancion}</td>
|
|
<td>{item.sancion.duracion}</td>
|
|
<td>{new Date(item.fecha_inicio).toLocaleDateString()}</td>
|
|
<td>
|
|
{calcularFechaFin(item.fecha_inicio, item.sancion.duracion)}
|
|
</td>
|
|
</tr>
|
|
))
|
|
) : (
|
|
<tr>
|
|
<td colSpan={5}>No hay sanciones registradas</td>
|
|
</tr>
|
|
)}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
)
|
|
} |