mirror of
https://github.com/fsolla/teqo.git
synced 2026-12-02 21:23:05 +00:00
- loadHomeSearchSuggestions returns scopeMunicipalities for client merge - useHomeSearchNearestMunicipality prompts once per session (B14 key) - mergeHomeSearchNearestMunicipality prefixes hit without geo copy - HomeSearchMunicipalityGroup wires suggest reorder for Início + drawer Closes #204 Co-authored-by: Francisco Solla <fsolla@users.noreply.github.com>
20 lines
798 B
TypeScript
20 lines
798 B
TypeScript
import type { HomeSearchMunicipalityHit } from '@/lib/campaignHomeSearchHits'
|
|
|
|
/**
|
|
* B117 — prefix the nearest in-scope município on suggest, deduping the server list.
|
|
* The hit uses the normal suggest shape — no geo reason or distance metadata.
|
|
*/
|
|
export const mergeHomeSearchNearestMunicipality = (input: {
|
|
nearestSlug: string | null | undefined
|
|
serverHits: readonly HomeSearchMunicipalityHit[]
|
|
hitBySlug: ReadonlyMap<string, HomeSearchMunicipalityHit>
|
|
}): HomeSearchMunicipalityHit[] => {
|
|
const slug = input.nearestSlug?.trim()
|
|
if (!slug) return [...input.serverHits]
|
|
|
|
const nearestHit = input.hitBySlug.get(slug)
|
|
if (!nearestHit) return [...input.serverHits]
|
|
|
|
const withoutDup = input.serverHits.filter((hit) => hit.slug !== slug)
|
|
return [nearestHit, ...withoutDup]
|
|
}
|