diff --git a/app/components/KidsBrowser.tsx b/app/components/KidsBrowser.tsx new file mode 100644 index 0000000..f186c03 --- /dev/null +++ b/app/components/KidsBrowser.tsx @@ -0,0 +1,67 @@ +"use client"; + +import { useState } from "react"; +import type { Kid } from "@/app/data/kids"; +import KidCard from "@/app/components/KidCard"; + +/** Compara sin mayúsculas ni acentos: "sofia" encuentra a "Sofía Méndez". */ +function normalize(value: string): string { + return value + .normalize("NFD") + .replace(/\p{Diacritic}/gu, "") + .toLowerCase(); +} + +export default function KidsBrowser({ kids }: { kids: Kid[] }) { + const [query, setQuery] = useState(""); + const filtered = kids.filter((kid) => normalize(kid.name).includes(normalize(query))); + + return ( +
+ {/* Buscador */} +
+ + + + + setQuery(event.target.value)} + placeholder="Buscar niño…" + className="flex-1 border-none bg-transparent text-[15px] text-[#3F362E] outline-none placeholder:text-[#B6A99B]" + /> +
+ + {/* Encabezado de sección: sala + contador + divisor */} +
+ SALA SOLES + + {filtered.length} {filtered.length === 1 ? "niño" : "niños"} + + +
+ + {/* Grilla filtrada o estado vacío */} + {filtered.length > 0 ? ( +
+ {filtered.map((kid) => ( + + ))} +
+ ) : ( +
+ No hay niños que coincidan con la búsqueda. +
+ )} +
+ ); +}