fix: align frontend API calls with backend routes and types

- Backend: rename routes /mealplan→/mealplans, /shoppinglist→/shopping
- Backend: simplify swap/reroll to entry-centric endpoints (by entryId)
- Frontend: fix all interfaces to use string GUIDs instead of numbers
- Frontend: fix field names (weekStart, date, totalAmount) to match backend JSON
- Frontend: shopping toggle by itemName instead of non-existent id
- Frontend: handle 204 No Content on DELETE responses
- Docker-compose: use env vars for DB credentials

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-16 06:49:41 +00:00
parent f58782774b
commit 1885abee64
10 changed files with 64 additions and 75 deletions

View File

@@ -5,7 +5,7 @@
<div>
<h1 class="text-2xl font-bold text-zinc-100">Wochenplan</h1>
<p v-if="store.currentPlan" class="text-zinc-500 text-sm mt-0.5">
{{ formatWeek(store.currentPlan.weekStartDate) }}
{{ formatWeek(store.currentPlan.weekStart) }}
</p>
</div>
<button
@@ -62,7 +62,7 @@
v-for="entry in sortedEntries"
:key="entry.id"
:entry="entry"
:day-name="getDayName(entry.dayOfWeek)"
:day-name="getDayName(entry.date)"
@swap="openSwapModal(entry)"
@reroll="handleReroll(entry)"
/>
@@ -121,12 +121,13 @@ const swapEntry = ref<MealPlanEntry | null>(null)
const DAY_NAMES = ['Sonntag', 'Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag']
function getDayName(dayOfWeek: number): string {
return DAY_NAMES[dayOfWeek] ?? `Tag ${dayOfWeek}`
function getDayName(dateStr: string): string {
const d = new Date(dateStr + 'T00:00:00')
return DAY_NAMES[d.getDay()] ?? dateStr
}
const sortedEntries = computed(() => {
return [...(store.currentPlan?.entries ?? [])].sort((a, b) => a.dayOfWeek - b.dayOfWeek)
return [...(store.currentPlan?.entries ?? [])].sort((a, b) => a.date.localeCompare(b.date))
})
function formatWeek(dateStr: string): string {
@@ -148,7 +149,7 @@ function openSwapModal(entry: MealPlanEntry): void {
}
}
async function handleSwapSelect(recipeId: number): Promise<void> {
async function handleSwapSelect(recipeId: string): Promise<void> {
if (!swapEntry.value) return
await store.swapMeal(swapEntry.value.id, recipeId)
swapEntry.value = null