teqo-backup/src/lib/campaignHomeSearchHits.ts
Francisco Ignácio Fontoura Solla 05072547cd B48: home search results for municipalities and identity territories.
Staff Início posts to /campanha/home-search with scoped word-start matches, shared readout component, and simplify hardening (messages, fetch busy, malformed response guard).
2026-07-29 16:05:56 -03:00

26 lines
735 B
TypeScript

import type { MunicipalityVoteRankEntry } from '@/lib/municipalityVoteRank'
export type HomeSearchMunicipalityHit = {
kind: 'municipality'
slug: string
name: string
region: string
priority: 'alta' | 'normal' | null
votePosition2022: MunicipalityVoteRankEntry | null
}
export type HomeSearchTerritoryHit = {
kind: 'territory'
region: string
votes2022: number
}
export type HomeSearchSuccessResponse = {
status: 'success'
municipalities: HomeSearchMunicipalityHit[]
territories: HomeSearchTerritoryHit[]
}
export const homeSearchMunicipalityGroupHasHits = (
data: Pick<HomeSearchSuccessResponse, 'municipalities' | 'territories'>,
): boolean => data.municipalities.length > 0 || data.territories.length > 0