"use client"; import { useEffect, useState } from "react"; import axios from "axios"; import DownloadReporteXLSX from "../Dowload/Reporte"; interface Recibo { id_recibo: number; folio_recibo: string; fecha_recibo: string; fecha_registro: string; monto: string; user: { usuario: string; }; } interface Props { desde: string | null; hasta: string | null; } function PorRecibos({ desde, hasta }: Props) { const [recibos, setRecibos] = useState([]); const [loading, setLoading] = useState(false); const columns = [ { header: "Folio", key: "folio", width: 15 }, { header: "Monto", key: "monto", width: 15 }, { header: "Fecha Recibo", key: "fechaRecibo", width: 18 }, { header: "Fecha Registro", key: "fechaRegistro", width: 22 }, { header: "Usuario", key: "usuario", width: 20 }, ]; useEffect(() => { if (!desde || !hasta) return; const fetchRecibos = async () => { setLoading(true); try { const res = await axios.post( `${process.env.NEXT_PUBLIC_API_URL}/recibo/rango`, { desde, hasta } ); setRecibos(res.data); } catch (error) { console.error("Error al obtener recibos", error); } finally { setLoading(false); } }; fetchRecibos(); }, [desde, hasta]); const formatearFechaMX = (fechaISO: string) => { return new Date(fechaISO).toLocaleString("es-MX", { timeZone: "America/Mexico_City", year: "numeric", month: "2-digit", day: "2-digit", hour: "2-digit", minute: "2-digit", second: "2-digit", }); }; return (
{recibos.length > 0 && }
{loading &&

Cargando...

} {!loading && recibos.length === 0 && ( )} {recibos.map((recibo) => ( ))}
Folio Monto fecha recibo fecha registro Usuario
No hay recibos en este rango
{recibo.folio_recibo} ${Number(recibo.monto).toFixed(2)} {recibo.fecha_recibo} {formatearFechaMX(recibo.fecha_registro)} {recibo.user.usuario}
); } export default PorRecibos;