"use client"; import { useState, useEffect } from "react"; import { useSearchParams } from "next/navigation"; import { FileText, Search } from "lucide-react"; import { useBills } from "@/lib/hooks/useBills"; import { BillCard } from "@/components/shared/BillCard"; const CHAMBERS = ["", "House", "Senate"]; const TOPICS = [ "", "healthcare", "taxation", "defense", "education", "immigration", "environment", "housing", "infrastructure", "technology", "agriculture", "judiciary", "foreign-policy", "veterans", "social-security", "trade", "budget", "energy", "banking", "transportation", "labor", ]; export default function BillsPage() { const searchParams = useSearchParams(); const [q, setQ] = useState(searchParams.get("q") ?? ""); const [chamber, setChamber] = useState(searchParams.get("chamber") ?? ""); const [topic, setTopic] = useState(searchParams.get("topic") ?? ""); const [hasText, setHasText] = useState(false); const [page, setPage] = useState(1); // Sync URL params → state so tag/topic links work when already on this page useEffect(() => { setQ(searchParams.get("q") ?? ""); setChamber(searchParams.get("chamber") ?? ""); setTopic(searchParams.get("topic") ?? ""); setPage(1); }, [searchParams]); const params = { ...(q && { q }), ...(chamber && { chamber }), ...(topic && { topic }), ...(hasText && { has_document: true }), page, per_page: 20, sort: "latest_action_date", }; const { data, isLoading } = useBills(params); return (
Browse and search US Congressional legislation