From 6a7dbef3f703779c8126b6e89e92869352f2746f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorem=20Ju=C3=A1rez?= Date: Mon, 6 Jul 2026 19:56:19 -0600 Subject: [PATCH] feat(panel): buscador de becarios en la lista MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Filtrado local sobre la lista ya cargada por nombre, celular, matrícula o institución (sin ida al backend). Botón para limpiar y mensaje de "sin resultados". Pensado para 30+ becarios. Co-Authored-By: Claude Fable 5 --- frontend/panel.html | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/frontend/panel.html b/frontend/panel.html index 0a9eb12..8e699ec 100644 --- a/frontend/panel.html +++ b/frontend/panel.html @@ -182,6 +182,7 @@ function VistaBecarios({ onOpen, onError }) { const [becarios, setBecarios] = useState(null); const [form, setForm] = useState(null); // null | {} (nuevo) | becario (editar) const [confirmBaja, setConfirmBaja] = useState(null); + const [q, setQ] = useState(""); const load = useCallback(async () => { try { setBecarios(await apiFetch("/becarios")); } catch (e) { onError(e.message); } }, [onError]); @@ -195,6 +196,12 @@ function VistaBecarios({ onOpen, onError }) { }; const pendientes = (becarios || []).filter((b) => b.estado === "pendiente"); const nuevoBtn = (size) => setForm({})}>{iconBtn("plus", { size: 16, color: "#fff", sw: 2.2 })}Nuevo becario; + // Buscador local sobre la lista ya cargada (nombre, celular, matrícula, institución). + const term = q.trim().toLowerCase(); + const filtrados = term + ? (becarios || []).filter((b) => + [b.nombre, b.telefono, b.matricula, b.institucion].some((c) => (c || "").toString().toLowerCase().includes(term))) + : (becarios || []); return (
@@ -204,8 +211,15 @@ function VistaBecarios({ onOpen, onError }) {
{becarios === null ?

Cargando…

: becarios.length === 0 ? : - - {becarios.map((b) => { +
+
+ setQ(e.target.value)} placeholder="Buscar por nombre, celular, matrícula o institución…" style={{ paddingRight: "34px" }} /> + {q && setQ("")} title="Limpiar" style={{ position: "absolute", right: "11px", top: "50%", transform: "translateY(-50%)", cursor: "pointer", display: "inline-flex" }}>{icons.x({ size: 15, color: palette.inkSoft, sw: 2.2 })}} +
+ {filtrados.length === 0 + ?

Sin resultados para «{q.trim()}».

+ :
+ {filtrados.map((b) => { const h = b.horas || { total_horas: 0, meta_horas: b.meta_horas, porcentaje: 0 }; return ( @@ -234,6 +248,7 @@ function VistaBecarios({ onOpen, onError }) { ); })}
} + } {form && { setForm(null); load(); }} onCancel={() => setForm(null)} onError={onError} />} {confirmBaja &&