Code maintainability fixes
This commit is contained in:
18
src/services/plans.ts
Normal file
18
src/services/plans.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
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}`);
|
||||
};
|
||||
Reference in New Issue
Block a user