import { ExerciseDef, WorkoutSet } from '../types'; import { api } from './api'; export const getExercises = async (userId: string): Promise => { try { return await api.get('/exercises'); } catch { return []; } }; export const saveExercise = async (userId: string, exercise: ExerciseDef): Promise => { await api.post('/exercises', exercise); }; export const getLastSetForExercise = async (userId: string, exerciseId: string): Promise => { try { const response = await api.get<{ success: boolean; set?: WorkoutSet }>(`/exercises/${exerciseId}/last-set`); if (response.success && response.set) { return response.set; } return undefined; } catch (error) { console.error("Failed to fetch last set:", error); return undefined; } };