import axios from "axios"; const API_BASE = process.env.VITE_APP_API_URL || "https://cycle-rider.ru"; export const api = axios.create({ baseURL: API_BASE, timeout: 10000, }); export interface WorkoutItem { id: string; name: string; created_by: string; created_at: string; description: string; cadence: number; heart_rate: number; max_cadence: number; max_heart_rate: number; temperature: number; speed: number; power: number; max_speed: number; max_power: number; duraion_sec: number; distantion: number; attachment: { url: string } | null; latitude: number; longitude: number; is_public: boolean; workouted_at: string; external_links?: { values: Array<{ type: string; value: string }> }; photos?: Array<{ id: string; url: string; size: number; latitude: number | null; longitude: number | null; }>; } export interface WorkoutListResponse { results: WorkoutItem[]; } export interface WorkoutDetailResponse { workout: WorkoutItem; results: Array<{ timestamp: number; longitude: number; latitude: number; elevation: number | null; power: number | null; heart_rate: number | null; speed: number | null; }>; } export async function getPublicWorkouts(): Promise { const res = await api.get("/api/v0/public/workouts"); return res.data.results; } export async function getPublicWorkout( id: string, ): Promise { const res = await api.get( `/api/v0/public/workouts/${id}`, ); return res.data; }