feat: add consent-based GPS location

This commit is contained in:
zv
2026-06-01 20:28:03 +02:00
parent f5898ced4f
commit ce2e1176fa
9 changed files with 256 additions and 4 deletions

View File

@@ -1,5 +1,5 @@
import type { Language } from "@/lib/i18n";
import type { LocationSearchResult } from "@/types/location";
import type { LocationSearchResult, ReverseLocationResult } from "@/types/location";
export async function fetchLocations(query: string, language: Language, signal?: AbortSignal): Promise<LocationSearchResult[]> {
const params = new URLSearchParams({ query, language });
@@ -7,3 +7,10 @@ export async function fetchLocations(query: string, language: Language, signal?:
if (!response.ok) throw new Error("Location search is temporarily unavailable.");
return response.json() as Promise<LocationSearchResult[]>;
}
export async function fetchReverseLocation(latitude: number, longitude: number, language: Language): Promise<ReverseLocationResult> {
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<ReverseLocationResult>;
}