import axios from "axios"; import { API_BASE_URL } from "../config/api"; export interface FitnessProfile { id?: string; clientId: string; height?: number; weight?: number; goals?: string; fitnessLevel: "beginner" | "intermediate" | "advanced"; medicalConditions?: string; dietaryRestrictions?: string; preferredWorkoutTime?: "morning" | "afternoon" | "evening"; workoutFrequency?: number; } export const fitnessProfileApi = { getFitnessProfile: async ( userId: string, token: string, ): Promise => { try { console.log( "Getting fitness profile with URL:", `${API_BASE_URL}/api/users/${userId}/fitness-profile`, ); const response = await axios.get( `${API_BASE_URL}/api/users/${userId}/fitness-profile`, { headers: { Authorization: `Bearer ${token}`, }, }, ); return response.data; } catch (error: any) { console.error( "Error fetching fitness profile:", error.message, error.response?.data, ); throw error; } }, updateFitnessProfile: async ( userId: string, data: Partial, token: string, ): Promise => { try { const response = await axios.put( `${API_BASE_URL}/api/users/${userId}/fitness-profile`, data, { headers: { Authorization: `Bearer ${token}`, }, }, ); return response.data; } catch (error: any) { console.error( "Error updating fitness profile:", error.message, error.response?.data, ); throw error; } }, createFitnessProfile: async ( data: Omit, token: string, ): Promise => { try { const response = await axios.post( `${API_BASE_URL}/api/users/${data.clientId}/fitness-profile`, data, { headers: { Authorization: `Bearer ${token}`, }, }, ); return response.data; } catch (error: any) { console.error( "Error creating fitness profile:", error.message, error.response?.data, ); throw error; } }, };