diff --git a/app/(private)/Inscritos/Inscripciones.tsx b/app/(private)/Inscritos/Inscripciones.tsx index 2b3fa12..79d5fe4 100644 --- a/app/(private)/Inscritos/Inscripciones.tsx +++ b/app/(private)/Inscritos/Inscripciones.tsx @@ -97,14 +97,7 @@ export default function Inscripciones() { url = `${envConfig.apiUrl}/alumno-inscrito/inscritos/anio/${periodoInicio}/${periodoFin}`; } -if (tipo === "mes") { - if (!anio) { - alert("Selecciona un año"); - return; - } - url = `${envConfig.apiUrl}/alumno-inscrito/inscritos/mes/${anio}`; -} try { console.log("URL:", url); @@ -214,7 +207,6 @@ if (tipo === "mes") {
@@ -263,21 +255,6 @@ if (tipo === "mes") { )} - - {/* MES */} -{tipo === "mes" && ( - <> - - -)} - diff --git a/app/(private)/Reportes/ReportesClient.tsx b/app/(private)/Reportes/ReportesClient.tsx index c202a95..c812b09 100644 --- a/app/(private)/Reportes/ReportesClient.tsx +++ b/app/(private)/Reportes/ReportesClient.tsx @@ -5,6 +5,7 @@ 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 MonthYearPicker from "@/app/Components/MonthYearPicker/MonthYearPicker"; export default function ReportesClient({ defaultKey, @@ -26,8 +27,8 @@ export default function ReportesClient({ label: "Por recibo", content: ( <> - { + { setDesde(d); setHasta(h); }} @@ -41,8 +42,8 @@ export default function ReportesClient({ label: "Por Servicio", content: ( <> - { + { setDesde(d); setHasta(h); }} diff --git a/app/Components/MonthYearPicker/MonthYearPicker.tsx b/app/Components/MonthYearPicker/MonthYearPicker.tsx new file mode 100644 index 0000000..1ca7689 --- /dev/null +++ b/app/Components/MonthYearPicker/MonthYearPicker.tsx @@ -0,0 +1,75 @@ +"use client"; + +import { useEffect, useState } from "react"; + +interface Props { + onChange: (desde: string, hasta: string) => void; + initialYear?: number; +} + +export default function MonthYearPicker({ + onChange, + initialYear, +}: Props) { + const currentYear = new Date().getFullYear(); + + const [mes, setMes] = useState(null); + const [anio, setAnio] = useState( + initialYear || currentYear + ); + + // Generar rango automáticamente + useEffect(() => { + if (mes !== null && anio !== null) { + const inicio = new Date(anio, mes, 1); + const fin = new Date(anio, mes + 1, 0); + + const formato = (fecha: Date) => + fecha.toISOString().split("T")[0]; + + onChange(formato(inicio), formato(fin)); + } + }, [mes, anio, onChange]); + + return ( +
+ {/* MES */} + + + +
+ ); +} \ No newline at end of file