"use client"; import { useState } from "react"; import { useRouter } from "next/navigation"; import { formatDate } from "@/lib/format-date"; type ZipCodeSearchProps = { allStops?: Array<{ id: string; city: string; state: string; date: string; time: string; location: string; slug: string; }>; brandAccent?: "green" | "orange" | "blue"; }; export default function ZipCodeSearch({ allStops = [], brandAccent = "blue" }: ZipCodeSearchProps) { const router = useRouter(); const [zipCode, setZipCode] = useState(""); const [filteredStops, setFilteredStops] = useState([]); const [searched, setSearched] = useState(false); const isBlue = brandAccent === "blue"; return (
{/* Header */}

Find Stops Near You

Search by ZIP code or city name

{/* Search row */}
setZipCode(e.target.value)} onKeyDown={(e) => { if (e.key === "Enter") { if (!zipCode.trim()) return; const normalized = zipCode.trim().replace(/\D/g, ""); setFilteredStops(allStops.filter((s) => s.city.toLowerCase().includes(normalized) || s.location.toLowerCase().includes(normalized) || s.state.toLowerCase().includes(normalized.toUpperCase()))); setSearched(true); } }} className="w-full rounded-xl border border-stone-200 pl-11 pr-4 py-3.5 text-sm text-stone-900 placeholder-stone-400 bg-white outline-none focus:border-stone-900 focus:ring-1 focus:ring-stone-900 transition-colors shadow-sm" />
{/* Results */} {searched && (
{filteredStops.length > 0 ? (

{filteredStops.length} stop{filteredStops.length !== 1 ? "s" : ""} found

{filteredStops.map((stop) => ( ))}
) : (

No stops found for that location.

Try a nearby ZIP code or browse all stops below.

)}
)}
); }