From 8084addb1e847b2e27e7e1fa566747e468f41c07 Mon Sep 17 00:00:00 2001 From: frcarlos <307100636@pcpuma.acatlan.unam.mx> Date: Wed, 14 Jan 2026 14:37:19 -0500 Subject: [PATCH] Recibo --- app/(private)/Reportes/ReportesClient.tsx | 58 +++++++++++++++ app/(private)/Reportes/page.tsx | 41 +---------- app/Components/Reportes/porRecibo.tsx | 61 +++++++++++++--- .../SearchDateBetween/SearchDateBetween.tsx | 73 +++++++++---------- tsconfig.json | 2 +- 5 files changed, 146 insertions(+), 89 deletions(-) create mode 100644 app/(private)/Reportes/ReportesClient.tsx diff --git a/app/(private)/Reportes/ReportesClient.tsx b/app/(private)/Reportes/ReportesClient.tsx new file mode 100644 index 0000000..65e838a --- /dev/null +++ b/app/(private)/Reportes/ReportesClient.tsx @@ -0,0 +1,58 @@ +'use client'; + +import { useState } from 'react'; +import Toggle from '@/app/Components/Global/Toggle/Toggle'; +import SearchDateBetween from '@/app/Components/SearchDateBetween/SearchDateBetween'; +import PorServicios from '@/app/Components/Reportes/porServicio'; +import PorRecibos from '@/app/Components/Reportes/porRecibo'; + +export default function ReportesClient({ + defaultKey, +}: { + defaultKey?: string; +}) { + const [desde, setDesde] = useState(null); + const [hasta, setHasta] = useState(null); + + return ( +
+

REPORTES

+ + + { + setDesde(d); + setHasta(h); + }} + /> + + + ), + }, + { + key: 'Por Servicio', + label: 'Por Servicio', + content: ( + <> + { + setDesde(d); + setHasta(h); + }} + /> + {/* */} + + ), + }, + ]} + /> +
+ ); +} diff --git a/app/(private)/Reportes/page.tsx b/app/(private)/Reportes/page.tsx index a328a07..b361760 100644 --- a/app/(private)/Reportes/page.tsx +++ b/app/(private)/Reportes/page.tsx @@ -1,48 +1,11 @@ -import Toggle from "@/app/Components/Global/Toggle/Toggle"; -import SearchDateBetween from "@/app/Components/SearchDateBetween/SearchDateBetween"; -import PorServicios from "@/app/Components/Reportes/porServicio"; -import PorRecibos from "@/app/Components/Reportes/porRecibo"; +import ReportesClient from './ReportesClient'; export default async function Page(props: { searchParams?: Promise<{ key: string; - numAcount: string; }>; }) { const params = await props.searchParams; - const key = params?.key && params.key; - return ( -
-

REPORTES

- - - - - - ), - }, - - { - key: "Por Servicio", - label: "Por Servicio", - content: ( - <> - - - - ), - }, - ]} - /> -
- ); + return ; } -//IO diff --git a/app/Components/Reportes/porRecibo.tsx b/app/Components/Reportes/porRecibo.tsx index 8590296..0b8fc60 100644 --- a/app/Components/Reportes/porRecibo.tsx +++ b/app/Components/Reportes/porRecibo.tsx @@ -1,17 +1,52 @@ -"use client"; -import { useState } from "react"; -import styles from "./Page.module.css"; +'use client'; -interface reportes { - Servicio: "Plotter"; - Total: "$1440.00"; +import { useEffect, useState } from 'react'; +import axios from 'axios'; + +interface ReporteRecibo { + Servicio: string; + Total: string; } -function PorRecibos() { - const [reportes, SetQuitarSanciones] = useState([]); +interface Props { + desde: string | null; + hasta: string | null; +} + +function PorRecibos({ desde, hasta }: Props) { + const [reportes, setReportes] = useState([]); + const [loading, setLoading] = useState(false); + + 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, + } + ); + + setReportes(res.data); + } catch (error) { + console.error('Error al obtener recibos', error); + } finally { + setLoading(false); + } + }; + + fetchRecibos(); + }, [desde, hasta]); + return ( -
- +
+ {loading &&

Cargando...

} + +
@@ -19,6 +54,12 @@ function PorRecibos() { + {reportes.length === 0 && !loading && ( + + + + )} + {reportes.map((reporte, index) => ( diff --git a/app/Components/SearchDateBetween/SearchDateBetween.tsx b/app/Components/SearchDateBetween/SearchDateBetween.tsx index 38102bb..d88ce18 100644 --- a/app/Components/SearchDateBetween/SearchDateBetween.tsx +++ b/app/Components/SearchDateBetween/SearchDateBetween.tsx @@ -1,51 +1,46 @@ -"use client"; +'use client'; -import { useState } from "react"; +import { useState } from 'react'; -function SearchDateBetween() { - const [startDate, setStartDate] = useState(""); - const [endDate, setEndDate] = useState(""); +interface Props { + onSearch: (desde: string, hasta: string) => void; +} + +function SearchDateBetween({ onSearch }: Props) { + const [startDate, setStartDate] = useState(''); + const [endDate, setEndDate] = useState(''); const handleSubmit = (e: React.FormEvent) => { e.preventDefault(); - console.log("Fecha inicio:", startDate); - console.log("Fecha fin:", endDate); - // Aquí puedes hacer la lógica para buscar entre fechas + if (!startDate || !endDate) return; + onSearch(startDate, endDate); }; return ( - <> -
- -
- setStartDate(e.target.value)} - placeholder="Fecha inicio" - /> -
- -
- setEndDate(e.target.value)} - placeholder="Fecha fin" - /> -
- - - +
+ +
+ setStartDate(e.target.value)} + /> +
+ + +
+ setEndDate(e.target.value)} + /> +
+ + + ); } export default SearchDateBetween; - -// By Tyrannuss diff --git a/tsconfig.json b/tsconfig.json index d8b9323..00978ef 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,7 +11,7 @@ "moduleResolution": "bundler", "resolveJsonModule": true, "isolatedModules": true, - "jsx": "preserve", + "jsx": "react-jsx", "incremental": true, "plugins": [ {
Servicio
No hay resultados
{reporte.Servicio}