* feat(campanha): responsive grid and viewport cap for home search results (B54) Adds HomeSearchResultsLayout with 1/2/3-column breakpoints and allocateHitBudget so Municípios keep priority while total hits stay within per-viewport limits. Closes #8 * fix(campanha): un-export knip-unused home search budget helpers
38 lines
1.4 KiB
TypeScript
38 lines
1.4 KiB
TypeScript
'use client'
|
|
|
|
import { useHomeSearchHitLimit } from '@/components/campaign/dashboard/HomeSearchHitBudgetContext'
|
|
import { HomeSearchHitRow } from '@/components/campaign/dashboard/HomeSearchHitRow'
|
|
import { useHomeSearchResults } from '@/components/campaign/dashboard/HomeSearchResultsContext'
|
|
import { formatHomeSearchMunicipalityCount } from '@/lib/campaignHomeSearchHits'
|
|
import { sliceHomeSearchHits } from '@/lib/homeSearchHitBudget'
|
|
import { HOME_SEARCH_GROUP_HEADING_CLASS, HOME_SEARCH_GROUP_LIST_CLASS } from '@/lib/homeSearchUi'
|
|
|
|
export const HomeSearchAdvisorGroup = () => {
|
|
const { results } = useHomeSearchResults()
|
|
const hitLimit = useHomeSearchHitLimit('advisors')
|
|
|
|
if (results.status !== 'success') return null
|
|
|
|
const { advisors } = results.data
|
|
if (advisors.length === 0) return null
|
|
|
|
const visibleAdvisors = sliceHomeSearchHits(advisors, hitLimit)
|
|
if (visibleAdvisors.length === 0) return null
|
|
|
|
return (
|
|
<section aria-label="Assessores" className="flex flex-col gap-0.5">
|
|
<h2 className={HOME_SEARCH_GROUP_HEADING_CLASS}>Assessores</h2>
|
|
<ul className={HOME_SEARCH_GROUP_LIST_CLASS}>
|
|
{visibleAdvisors.map((hit) => (
|
|
<li key={hit.id}>
|
|
<HomeSearchHitRow
|
|
href={`/campanha/assessores/${hit.id}`}
|
|
primary={hit.name}
|
|
secondary={formatHomeSearchMunicipalityCount(hit.municipalityCount)}
|
|
/>
|
|
</li>
|
|
))}
|
|
</ul>
|
|
</section>
|
|
)
|
|
}
|