diff --git a/app/(private)/Reportes/ReportesClient.tsx b/app/(private)/Reportes/ReportesClient.tsx index 9d7fc17..e6004fb 100644 --- a/app/(private)/Reportes/ReportesClient.tsx +++ b/app/(private)/Reportes/ReportesClient.tsx @@ -48,7 +48,7 @@ export default function ReportesClient({ setHasta(h); }} /> - {/* */} + ), }, diff --git a/app/Components/Reportes/porServicio.tsx b/app/Components/Reportes/porServicio.tsx index 73ef7b5..0f1e2cb 100644 --- a/app/Components/Reportes/porServicio.tsx +++ b/app/Components/Reportes/porServicio.tsx @@ -1,42 +1,86 @@ "use client"; -import { useState } from "react"; -interface servicios { - folio_recibo: "100255"; - monto: "40.00"; - fecha_recibo: "10/10/2025"; - fecha_registro: "10/10/2025 05:32:20 pm"; - usuario: "modulo1"; +import { useEffect, useState } from "react"; +import axios from "axios"; +import DownloadReporteXLSX from "../Dowload/Reporte"; + + +interface ServicioReporte { + id_servicio: number; + servicio: string; + total: string; } -function PorServicios() { - const [recibos, setRecibos] = useState([]); +interface Props { + desde: string | null; + hasta: string | null; +} + +function PorServicio({ desde, hasta }: Props) { + const [servicios, setServicios] = useState([]); + const [loading, setLoading] = useState(false); + + useEffect(() => { + if (!desde || !hasta) return; + + const fetchServicios = async () => { + setLoading(true); + try { + const res = await axios.post( + `${process.env.NEXT_PUBLIC_API_URL}/detalle-servicio/rango`, + { desde, hasta } + ); + + setServicios(res.data); + } catch (error) { + console.error("Error al obtener reporte por servicio", error); + } finally { + setLoading(false); + } + }; + + fetchServicios(); + }, [desde, hasta]); + return ( -
- - - - - - - - - - - - {recibos.map((recibo, index) => ( - - - - - - +
+ {servicios.length > 0 && } + +
+ {loading &&

Cargando...

} + +
Folio ReciboMontoFecha ReciboFecha RegistroUsuario
{recibo.folio_recibo}{recibo.monto}{recibo.fecha_recibo}{recibo.fecha_registro}{recibo.usuario}
+ + + + - ))} - -
ServicioMonto total
+ + + + {!loading && servicios.length === 0 && ( + + No hay servicios en este rango + + )} + + {servicios.map((servicio) => ( + + {servicio.servicio} + ${Number(servicio.total).toFixed(2)} + + ))} + + +
); } -export default PorServicios; +export default PorServicio; diff --git a/tsconfig.json b/tsconfig.json index 74f6560..e7ff3a2 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -15,7 +15,7 @@ "moduleResolution": "bundler", "resolveJsonModule": true, "isolatedModules": true, - "jsx": "preserve", + "jsx": "react-jsx", "incremental": true, "plugins": [ {