19 lines
502 B
TypeScript
19 lines
502 B
TypeScript
import { WorkoutPlan } from '../types';
|
|
import { api } from './api';
|
|
|
|
export const getPlans = async (userId: string): Promise<WorkoutPlan[]> => {
|
|
try {
|
|
return await api.get<WorkoutPlan[]>('/plans');
|
|
} catch {
|
|
return [];
|
|
}
|
|
};
|
|
|
|
export const savePlan = async (userId: string, plan: WorkoutPlan): Promise<void> => {
|
|
await api.post('/plans', plan);
|
|
};
|
|
|
|
export const deletePlan = async (userId: string, id: string): Promise<void> => {
|
|
await api.delete(`/plans/${id}`);
|
|
};
|