Word-start on name, municipality count on the row, shared HomeSearchHitRow; POST /campanha/home-search aggregates advisors alongside municipalities.
30 lines
928 B
TypeScript
30 lines
928 B
TypeScript
'use client'
|
|
|
|
import type { ReactNode } from 'react'
|
|
|
|
import { useHomeSearch } from '@/components/campaign/dashboard/HomeSearchContext'
|
|
import { useHomeSearchResults } from '@/components/campaign/dashboard/HomeSearchResultsContext'
|
|
import { homeSearchHasAnyHits } from '@/lib/campaignHomeSearchHits'
|
|
|
|
export const HomeSearchResultsShell = ({ children }: { children: ReactNode }) => {
|
|
const { query } = useHomeSearch()
|
|
const { results, resultKind } = useHomeSearchResults()
|
|
|
|
const showEmpty =
|
|
query.isActive &&
|
|
resultKind === 'search' &&
|
|
results.status === 'success' &&
|
|
!homeSearchHasAnyHits(results.data)
|
|
|
|
return (
|
|
<>
|
|
{children}
|
|
{results.status === 'error' ? (
|
|
<p className="text-sm text-destructive" role="alert">
|
|
{results.message}
|
|
</p>
|
|
) : null}
|
|
{showEmpty ? <p className="text-sm text-muted-foreground">Nenhum resultado.</p> : null}
|
|
</>
|
|
)
|
|
}
|