'use client' import { useRouter } from 'next/navigation' import { useState } from 'react' import { useCampaignListTransition } from '@/components/campaign/shared/CampaignListPending' import { Button } from '@/components/ui/button' /** * Name-search form for simple list pages (lideranças, organizações, * dobradinhas): keeps the input value locally (optimistic) and navigates in a * transition so the results region dims instead of a dead full-page wait. */ export const CampaignSearchForm = ({ ariaLabel, placeholder, initialQuery, basePath, }: { ariaLabel: string placeholder: string initialQuery: string /** List route; the query lands as `?q=` (serializable — no function props across the RSC boundary). */ basePath: string }) => { const router = useRouter() const { isPending, startTransition } = useCampaignListTransition() const [query, setQuery] = useState(initialQuery) const hrefForQuery = (value: string) => value ? `${basePath}?q=${encodeURIComponent(value)}` : basePath return (
) }