Files
DailyMeals/meal-plan-frontend/src/api/meal-plan.api.ts
Piotr Kus f15bb7a916 * Extended functionalities
* Added different UIs
2026-06-24 21:43:40 +02:00

22 lines
881 B
TypeScript

import { api } from "@/api/axiosInstance";
import type { MealPlanEntry, ShoppingListItem, UpsertMealPlanEntryInput } from "@/types/meal-plan.types";
export async function fetchMealPlanEntries(from: string, to: string): Promise<MealPlanEntry[]> {
const { data } = await api.get<MealPlanEntry[]>("/meal-plan", { params: { from, to } });
return data;
}
export async function upsertMealPlanEntry(input: UpsertMealPlanEntryInput): Promise<MealPlanEntry> {
const { data } = await api.put<MealPlanEntry>("/meal-plan", input);
return data;
}
export async function deleteMealPlanEntry(id: number): Promise<void> {
await api.delete(`/meal-plan/${id}`);
}
export async function fetchShoppingList(from: string, to: string): Promise<ShoppingListItem[]> {
const { data } = await api.get<ShoppingListItem[]>("/meal-plan/shopping-list", { params: { from, to } });
return data;
}