export type Activity = { spot_id: string; waterbody_slug: string; waterbody: string; fish_slug: string; fish: string; x: number; y: number; best_bait: string | null; catches: number; unique_players: number; average_weight_g: number; max_weight_g: number; last_confirmed_at: string; activity_score: number; confidence_score: number; explanation: string; }; export type Spot = { id: string; waterbody_slug: string; waterbody: string; x: number; y: number; description: string | null; catches_24h: number; catches_3d: number; catches_7d: number; top_baits: string[] }; export type Catch = { id: string; fish: string; weight_g: number; bait: string | null; player_name: string | null; caught_at: string | null; reported_at: string; retrieve_method: string | null; retrieve_speed: number | null }; export type DictionaryItem = { id: string; slug: string; name_ru: string }; export type OfficialRecord = { id: string; fish: string; weight_g: number; waterbody: string; bait: string | null; player_name: string | null; record_date: string | null; category: string | null; region: string | null; source_url: string | null }; export type ImportRun = { id: string; started_at: string; finished_at: string | null; status: string; source_url: string; rows_seen: number; rows_created: number; rows_updated: number; error_summary: string | null }; const base = process.env.API_INTERNAL_URL || import.meta.env.API_INTERNAL_URL || "http://localhost:8000"; export async function api(path: string): Promise { const response = await fetch(`${base}${path}`); if (!response.ok) throw new Error(`API ${response.status}`); return response.json() as Promise; } export function kg(grams: number) { return `${(grams / 1000).toFixed(2)} кг`; } export function ago(value: string) { const minutes = Math.max(0, Math.round((Date.now() - new Date(value).getTime()) / 60000)); return minutes < 60 ? `${minutes} мин назад` : `${Math.floor(minutes / 60)} ч назад`; }