* Extended functionalities
* Added different UIs
This commit is contained in:
21
meal-plan-frontend/src/api/meal-plan.api.ts
Normal file
21
meal-plan-frontend/src/api/meal-plan.api.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
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;
|
||||
}
|
||||
Reference in New Issue
Block a user