diff --git a/frontend/src/pages/Comisiones.jsx b/frontend/src/pages/Comisiones.jsx
index b1b4748..07f345d 100644
--- a/frontend/src/pages/Comisiones.jsx
+++ b/frontend/src/pages/Comisiones.jsx
@@ -1,5 +1,5 @@
// src/pages/Comisiones.jsx
-import { useState, useEffect, useMemo } from "react";
+import { useState, useEffect, useMemo, useRef } from "react";
import { api } from "../lib/api";
import { Loader, ErrorBox, Filters, Select } from "../components/UI";
import Modal from "../components/Modal";
@@ -7,8 +7,8 @@ import { useColumnasAjustables } from "../lib/useColumnasAjustables";
const MESES = ["ENERO","FEBRERO","MARZO","ABRIL","MAYO","JUNIO","JULIO","AGOSTO","SEPTIEMBRE","OCTUBRE","NOVIEMBRE","DICIEMBRE"];
const ANOS = [2024, 2025, 2026];
-const SEDES = ["TODOS", "LIMA", "AREQUIPA", "PIURA", "TRUJILLO"];
-const PROGRAMAS = ["TODOS", "SEMINARIOS", "OTROS", "TEAC", "TERC"];
+const SEDES = ["LIMA", "AREQUIPA", "PIURA", "TRUJILLO"];
+const PROGRAMAS = ["SEMINARIOS", "OTROS", "TEAC", "TERC"];
const COLS = ["VENDEDOR","INSCRITOS PAGADOS MES EN CURSO","MONTO PAGADO MES EN CURSO","INSCRITOS PAGADOS MES PASADO","MONTO PAGADO MES PASADO","AVANCE TOTAL","OPCIONES"];
// Mostaza transparente: resalta filas de alumnos con edición (override en Supabase)
const BG_EDITADO = "rgba(217,160,28,0.14)";
@@ -59,8 +59,10 @@ export default function Comisiones() {
const hoy = new Date();
const [ano, setAno] = useState(hoy.getFullYear());
const [mes, setMes] = useState(hoy.getMonth() + 1);
- const [sede, setSede] = useState("TODOS");
- const [programa, setPrograma] = useState("TODOS");
+ const [sedes, setSedes] = useState([]); // vacío = todas
+ const [programas, setProgramas] = useState([]); // vacío = todos
+ const sedesKey = useMemo(() => [...sedes].sort().join(","), [sedes]);
+ const programasKey = useMemo(() => [...programas].sort().join(","), [programas]);
const [filas, setFilas] = useState([]);
const [manualesAno, setManualesAno] = useState([]); // todos los del año (cache)
const [loading, setLoading] = useState(true);
@@ -99,7 +101,7 @@ export default function Comisiones() {
// Tabla de ventas (depende del mes, sede y programa) — Comisiones SÍ aplica overrides
function cargarTabla() {
setLoading(true); setError(null);
- api.ventas(ano, mes, sede, programa, true)
+ api.ventas(ano, mes, sedesKey || "TODOS", programasKey || "TODOS", true)
.then((res) => { setFilas(res.filas || []); setLoading(false); })
.catch((e) => { setError(e.message); setLoading(false); });
}
@@ -107,11 +109,11 @@ export default function Comisiones() {
useEffect(() => {
let activo = true;
setLoading(true); setError(null);
- api.ventas(ano, mes, sede, programa, true)
+ api.ventas(ano, mes, sedesKey || "TODOS", programasKey || "TODOS", true)
.then((res) => { if (activo) { setFilas(res.filas || []); setLoading(false); } })
.catch((e) => { if (activo) { setError(e.message); setLoading(false); } });
return () => { activo = false; };
- }, [ano, mes, sede, programa]);
+ }, [ano, mes, sedesKey, programasKey]);
// Cargar manuales del año cuando cambia el año (o al inicio)
useEffect(() => { cargarManuales(); }, [ano]);
@@ -139,11 +141,13 @@ export default function Comisiones() {
// Total general de AVANCE TOTAL = ventas + montos manuales
// (los manuales solo cuentan cuando NO hay filtro de sede/programa)
+ // Los manuales solo cuentan cuando NO hay filtro de sede ni programa (todos).
+ const sinFiltroSedeProg = sedes.length === 0 && programas.length === 0;
const totalAvance = useMemo(() => {
let s = total ? toNum(total[7]) : 0;
- if (sede==="TODOS" && programa==="TODOS") manuales.forEach((m) => { s += toNum(m.monto); });
+ if (sinFiltroSedeProg) manuales.forEach((m) => { s += toNum(m.monto); });
return s;
- }, [total, manuales, sede, programa]);
+ }, [total, manuales, sinFiltroSedeProg]);
const C = { textAlign: "center" }; // todas las columnas centradas
@@ -152,10 +156,10 @@ export default function Comisiones() {
🧮 Comisiones
-