Files
TREK/client/src/utils/placeSearch.ts
T
Maurice f7782b9ef7 feat(planner): the places search also finds the description and the notes
The search box of the places list matched only name and address. It now also reads what was written about a place, through one helper the desktop list, its filter counts and the phone's browser share. (#2252)
2026-10-01 09:30:42 +02:00

19 lines
772 B
TypeScript

import type { Place } from '../types'
type Searchable = Pick<Place, 'name' | 'address' | 'description' | 'notes'>
/**
* Whether a place matches the search box of the places list (#2252). Name and
* address as before, and also the description and the notes, so a place found
* by what was written about it ("vegan", "book ahead") turns up too. One helper
* for the desktop list, its filter counts and the phone's browser, so the three
* can never disagree about what a search finds.
*/
export function placeMatchesSearch(place: Searchable, query: string): boolean {
const q = query.trim().toLowerCase()
if (!q) return true
return [place.name, place.address, place.description, place.notes].some(
field => !!field && field.toLowerCase().includes(q),
)
}