import type { Language } from "@/lib/i18n"; import type { LocationSearchResult, ReverseLocationResult } from "@/types/location"; export async function fetchLocations(query: string, language: Language, signal?: AbortSignal): Promise { const params = new URLSearchParams({ query, language }); const response = await fetch(`/api/locations/search?${params}`, { signal }); if (!response.ok) throw new Error("Location search is temporarily unavailable."); return response.json() as Promise; } export async function fetchReverseLocation(latitude: number, longitude: number, language: Language): Promise { const params = new URLSearchParams({ latitude: String(latitude), longitude: String(longitude), language }); const response = await fetch(`/api/locations/reverse?${params}`); if (!response.ok) throw new Error("Reverse location search is temporarily unavailable."); return response.json() as Promise; }