diff --git a/CLAUDE.md b/CLAUDE.md
index fe92e7d..0ca9d2a 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -7,13 +7,14 @@
> **Plattform:** Olares One (Kubernetes), Repo und CI auf Gitea — kein Supabase,
> kein Vercel (E-0001). Eigene Gestaltung, nicht AImighty (E-0002).
> Verteilung über den Markt, Repo öffentlich (E-0005).
-> **Status:** 26.11.22 — alle neun Arbeitspakete aus `docs/PROJEKTSTART.md` sind gebaut:
+> **Status:** 26.11.23 — alle neun Arbeitspakete aus `docs/PROJEKTSTART.md` sind gebaut:
> Anmeldung (Passkeys, Kinder mit Gerät + PIN), Gerichte (Link, Kochbuchfoto, AI über den
> Olares Router), Wünschen, Plan, Einkaufsliste (Echtzeit, offline), Kochmodus mit
> Bewertung, Web-App; Einzahl bei Stück-Mengen (26.11.15), Preise und Kosten mit Ampel
> (V2a, 26.11.16), Olares Router als Standard (26.11.17), untere Leiste am iPhone (26.11.18),
> Rolle „Jugendlich“ (26.11.19), Rezepte in einer Form (26.11.20),
-> Produkte je Gericht (26.11.21), Veto mit Gegenvorschlag (26.11.22). Offen sind V2b (Kassenbons)
+> Produkte je Gericht (26.11.21), Veto mit Gegenvorschlag (26.11.22),
+> bis zu 5 Fotos je Gericht (26.11.23). Offen sind V2b (Kassenbons)
> und der Magic Link.
> **Letzte Aktualisierung:** 7. November 2026
@@ -354,6 +355,14 @@ Vorlagen ersetzt. `tests/seed.test.ts` prüft die Dateien. Ein Haushalt
- **Tests:** Scheitert `beforeAll`, zählt vitest die Tests als übersprungen, nicht als
rot — nach jedem Lauf mit Datenbank muss „skipped“ 0 sein.
+## Fotos je Gericht (seit 26.11.23)
+
+- Bis zu 5 in `dish_photos` (Migration 0014, im Abzug), Dateien unter `/app/data/fotos/`.
+ `dishes.photo_path` bleibt das **Vorschaubild** — alle Anzeigen lesen weiter nur das.
+ Logik in `lib/dish-photos.ts` (`addPhoto`: erstes wird Vorschau, sechstes abgelehnt;
+ `setCover`; `removePhoto`: nächstes rückt nach). Hinzufügen: `WISHERS` (auch Kinder,
+ über „Foto vom Essen“ in der Bewertungskarte); Vorschau und Entfernen: `PLANNERS`.
+
## Rollen
- `admin`, `member`, `teen` (seit 26.11.19), `child`, `guest`. Wer was darf, steht nur
diff --git a/OlaresManifest.yaml b/OlaresManifest.yaml
index d047e27..ab2a21c 100644
--- a/OlaresManifest.yaml
+++ b/OlaresManifest.yaml
@@ -21,7 +21,7 @@ metadata:
title: What's cooking?
description: The family decides together what's for dinner — and the shopping list writes itself. Runs entirely on your own box.
icon: https://git.aimighty.olares.de/aimighty/bilder/raw/branch/main/lunch/icon.png
- version: 26.11.22
+ version: 26.11.23
categories:
- Applications
@@ -61,7 +61,7 @@ permission:
appData: true
spec:
- versionName: '26.11.22'
+ versionName: '26.11.23'
featuredImage: https://git.aimighty.olares.de/aimighty/bilder/raw/branch/main/lunch/icon.png
promoteImage:
diff --git a/app/(app)/gerichte/[id]/page.tsx b/app/(app)/gerichte/[id]/page.tsx
index d2cf773..b8be003 100644
--- a/app/(app)/gerichte/[id]/page.tsx
+++ b/app/(app)/gerichte/[id]/page.tsx
@@ -8,6 +8,9 @@ import { PortionScaler } from "@/components/dishes/portion-scaler";
import { requireSession } from "@/lib/auth/session";
import { withHousehold } from "@/lib/db";
import { getDish } from "@/lib/dishes";
+import { listPhotos } from "@/lib/dish-photos";
+import { WISHERS } from "@/lib/wishes";
+import { PhotoGallery } from "@/components/dishes/photo-gallery";
import { Confidence } from "@/components/costs/confidence";
import { CostSection } from "@/components/costs/cost-section";
import { STAPLE_SQL, dishCosts, householdCurrency, loadPrices } from "@/lib/costs";
@@ -23,11 +26,12 @@ export default async function DishPage({ params }: { params: Promise<{ id: strin
const locale = await getLocale();
const t = await getTranslations("dishes");
const tc = await getTranslations("costs");
- const { dish, people, cost, prices, currency, staples } = await withHousehold(session.householdId, async (c) => {
+ const { dish, people, cost, prices, currency, staples, photos } = await withHousehold(session.householdId, async (c) => {
const currency = await householdCurrency(c);
const prices = await loadPrices(c, currency);
return {
dish: await getDish(c, id, locale),
+ photos: await listPhotos(c, id),
people: (await c.query("select count(*)::int as n from members where role <> 'guest'")).rows[0].n as number,
cost: (await dishCosts(c, prices, [id])).get(id) ?? null,
prices,
@@ -39,6 +43,8 @@ export default async function DishPage({ params }: { params: Promise<{ id: strin
});
if (!dish) notFound();
const canWrite = session.role === "admin" || session.role === "member";
+ // Fotos hinzufügen dürfen alle, die mitessen; Vorschau und Entfernen nur, wer Gerichte pflegt.
+ const canAddPhoto = (WISHERS as readonly string[]).includes(session.role);
const meta = [dish.effortMinutes ? t("minutes", { n: dish.effortMinutes }) : null, dish.base ? t(`bases.${dish.base}`) : null]
.filter(Boolean)
.join(" · ");
@@ -54,7 +60,7 @@ export default async function DishPage({ params }: { params: Promise<{ id: strin
>
- {canWrite ? : null}
+ {canAddPhoto ? : null}
@@ -68,6 +74,7 @@ export default async function DishPage({ params }: { params: Promise<{ id: strin
) : null}
+ {photos.length ?
: null}
{canWrite ?
: null}
}) {
- const { id } = await params;
- const session = await guardWrite(request);
- if (isResponse(session)) return session;
- if (!/^[0-9a-f-]{36}$/.test(id)) return fail("invalid", 400);
- const form = await request.formData().catch(() => null);
- const file = form?.get("photo");
- if (!(file instanceof File)) return fail("invalid", 400);
- const old = await withHousehold(session.householdId, async (c) => (await c.query("select photo_path from dishes where id = $1", [id])).rows[0]);
- if (!old) return fail("notFound", 404);
- let relative: string;
- try {
- relative = await storePhoto(session.householdId, id, file);
- } catch (error) {
- if (error instanceof PhotoRejected) return fail("photo", 400);
- throw error;
- }
- await withHousehold(session.householdId, (c) => c.query("update dishes set photo_path = $2, updated_at = now() where id = $1", [id, relative]));
- if (old.photo_path && old.photo_path !== relative) await removePhoto(old.photo_path);
- return json({ photo: relative });
+// Früher: ein Foto je Gericht. Seit 26.11.23 fügt diese Adresse ein Foto zur
+// Sammlung hinzu (app/api/dishes/[id]/photos), damit ältere Oberflächen weiter gehen.
+export async function POST(request: Request, context: { params: Promise<{ id: string }> }) {
+ return addToCollection(request, context);
}
diff --git a/app/api/dishes/[id]/photos/[photoId]/route.ts b/app/api/dishes/[id]/photos/[photoId]/route.ts
new file mode 100644
index 0000000..d73a046
--- /dev/null
+++ b/app/api/dishes/[id]/photos/[photoId]/route.ts
@@ -0,0 +1,29 @@
+import { guardWrite, isResponse } from "@/lib/auth/guard";
+import { fail, json } from "@/lib/auth/http";
+import { PLANNERS } from "@/lib/auth/roles";
+import { withHousehold } from "@/lib/db";
+import { removePhoto, setCover } from "@/lib/dish-photos";
+
+export const dynamic = "force-dynamic";
+
+const ok = (s: string) => /^[0-9a-f-]{36}$/.test(s);
+
+// Vorschaubild wählen — nur, wer Gerichte pflegt.
+export async function PUT(request: Request, { params }: { params: Promise<{ id: string; photoId: string }> }) {
+ const { id, photoId } = await params;
+ const session = await guardWrite(request, [...PLANNERS]);
+ if (isResponse(session)) return session;
+ if (!ok(id) || !ok(photoId)) return fail("invalid", 400);
+ const done = await withHousehold(session.householdId, (c) => setCover(c, id, photoId));
+ return done ? json({ ok: true }) : fail("notFound", 404);
+}
+
+// Foto entfernen — nur, wer Gerichte pflegt.
+export async function DELETE(request: Request, { params }: { params: Promise<{ id: string; photoId: string }> }) {
+ const { id, photoId } = await params;
+ const session = await guardWrite(request, [...PLANNERS]);
+ if (isResponse(session)) return session;
+ if (!ok(id) || !ok(photoId)) return fail("invalid", 400);
+ const done = await withHousehold(session.householdId, (c) => removePhoto(c, id, photoId));
+ return done ? json({ ok: true }) : fail("notFound", 404);
+}
diff --git a/app/api/dishes/[id]/photos/route.ts b/app/api/dishes/[id]/photos/route.ts
new file mode 100644
index 0000000..5dd20f0
--- /dev/null
+++ b/app/api/dishes/[id]/photos/route.ts
@@ -0,0 +1,25 @@
+import { guardWrite, isResponse } from "@/lib/auth/guard";
+import { fail, json } from "@/lib/auth/http";
+import { withHousehold } from "@/lib/db";
+import { addPhoto } from "@/lib/dish-photos";
+import { PhotoRejected } from "@/lib/photos";
+import { WISHERS } from "@/lib/wishes";
+
+export const dynamic = "force-dynamic";
+
+// Foto hinzufügen: alle, die mitessen (auch Kinder nach dem Kochen), bis fünf je Gericht.
+export async function POST(request: Request, { params }: { params: Promise<{ id: string }> }) {
+ const { id } = await params;
+ const session = await guardWrite(request, [...WISHERS]);
+ if (isResponse(session)) return session;
+ if (!/^[0-9a-f-]{36}$/.test(id)) return fail("invalid", 400);
+ const form = await request.formData().catch(() => null);
+ const file = form?.get("photo");
+ if (!(file instanceof File)) return fail("invalid", 400);
+ try {
+ return json(await withHousehold(session.householdId, (c) => addPhoto(c, session.householdId, id, session.memberId, file)), 201);
+ } catch (error) {
+ if (error instanceof PhotoRejected) return fail(error.message === "full" ? "full" : error.message === "dish" ? "notFound" : "photo", error.message === "dish" ? 404 : 400);
+ throw error;
+ }
+}
diff --git a/app/api/dishes/route.ts b/app/api/dishes/route.ts
index a89b9f8..dc23371 100644
--- a/app/api/dishes/route.ts
+++ b/app/api/dishes/route.ts
@@ -3,17 +3,16 @@ import { fail, json, readJson } from "@/lib/auth/http";
import { dishInput, InvalidAmount, saveDish } from "@/lib/dishes";
import { withHousehold } from "@/lib/db";
import { fetchPublic } from "@/lib/fetch-safe";
-import { storePhotoBytes } from "@/lib/photos";
+import { addPhoto } from "@/lib/dish-photos";
export const dynamic = "force-dynamic";
// Das Bild einer importierten Seite: holen wie die Seite (lib/fetch-safe.ts),
// verkleinern wie ein eigenes Foto. Klappt es nicht, bleibt das Gericht ohne Bild.
-async function attachImage(householdId: string, dishId: string, url: string) {
+async function attachImage(householdId: string, dishId: string, memberId: string, url: string) {
try {
const { body } = await fetchPublic(url, "image");
- const relative = await storePhotoBytes(householdId, dishId, body);
- await withHousehold(householdId, (c) => c.query("update dishes set photo_path = $2 where id = $1", [dishId, relative]));
+ await withHousehold(householdId, (c) => addPhoto(c, householdId, dishId, memberId, body));
} catch {
// ohne Bild weiter
}
@@ -27,7 +26,7 @@ export async function POST(request: Request) {
if (!body.success) return fail("invalid", 400);
try {
const id = await withHousehold(session.householdId, (c) => saveDish(c, session.householdId, session.memberId, body.data));
- if (body.data.imageUrl) await attachImage(session.householdId, id, body.data.imageUrl);
+ if (body.data.imageUrl) await attachImage(session.householdId, id, session.memberId, body.data.imageUrl);
return json({ id }, 201);
} catch (error) {
if (error instanceof InvalidAmount) return fail("amount", 400);
diff --git a/app/api/fotos/[id]/[photoId]/route.ts b/app/api/fotos/[id]/[photoId]/route.ts
new file mode 100644
index 0000000..a1ebabc
--- /dev/null
+++ b/app/api/fotos/[id]/[photoId]/route.ts
@@ -0,0 +1,23 @@
+import { guardRead, isResponse } from "@/lib/auth/guard";
+import { fail } from "@/lib/auth/http";
+import { withHousehold } from "@/lib/db";
+import { readPhoto } from "@/lib/photos";
+
+export const dynamic = "force-dynamic";
+
+// Ein Foto aus der Sammlung eines Gerichts — nur für den eigenen Haushalt (Zeilensicherheit).
+export async function GET(_: Request, { params }: { params: Promise<{ id: string; photoId: string }> }) {
+ const { id, photoId } = await params;
+ const session = await guardRead();
+ if (isResponse(session)) return session;
+ if (!/^[0-9a-f-]{36}$/.test(id) || !/^[0-9a-f-]{36}$/.test(photoId)) return fail("invalid", 400);
+ const row = await withHousehold(session.householdId, async (c) =>
+ (await c.query("select path from dish_photos where id = $1 and dish_id = $2", [photoId, id])).rows[0],
+ );
+ if (!row) return fail("notFound", 404);
+ const body = await readPhoto(row.path).catch(() => null);
+ if (!body) return fail("notFound", 404);
+ return new Response(new Uint8Array(body), {
+ headers: { "content-type": "image/webp", "cache-control": "private, max-age=31536000, immutable" },
+ });
+}
diff --git a/components/cooking/rate-card.tsx b/components/cooking/rate-card.tsx
index fb0f486..5ac9a61 100644
--- a/components/cooking/rate-card.tsx
+++ b/components/cooking/rate-card.tsx
@@ -1,14 +1,14 @@
"use client";
-import { Heart, ThumbsDown, ThumbsUp } from "lucide-react";
+import { Camera, Heart, ThumbsDown, ThumbsUp } from "lucide-react";
import { useRouter } from "next/navigation";
import { useTranslations } from "next-intl";
-import { useState } from "react";
+import { useRef, useState } from "react";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { cn } from "@/lib/utils";
-type ToRate = { slotId: string; title: string; cookName: string | null; isCook: boolean; thanked: boolean };
+type ToRate = { slotId: string; dishId: string; title: string; cookName: string | null; isCook: boolean; thanked: boolean };
// Bewerten (Konzept, „Bewerten“): Daumen hoch oder runter, optional ein Satz,
// und ein Dankeschön an den Koch. Fünf Sekunden, am Tisch.
@@ -19,6 +19,20 @@ export function RateCard({ item }: { item: ToRate }) {
const [comment, setComment] = useState("");
const [thanked, setThanked] = useState(item.thanked);
const [busy, setBusy] = useState(false);
+ const [photo, setPhoto] = useState<"idle" | "done" | "full" | "error">("idle");
+ const file = useRef(null);
+
+ // Foto vom Essen: geht in die Sammlung des Gerichts (bis fünf), auch für Kinder.
+ async function addPhoto(f: File) {
+ setBusy(true);
+ const form = new FormData();
+ form.append("photo", f);
+ const res = await fetch(`/api/dishes/${item.dishId}/photos`, { method: "POST", body: form }).catch(() => null);
+ setBusy(false);
+ if (file.current) file.current.value = "";
+ if (res?.ok) setPhoto("done");
+ else setPhoto((await res?.json().catch(() => ({})))?.error === "full" ? "full" : "error");
+ }
async function post(url: string, body?: object) {
setBusy(true);
@@ -63,6 +77,20 @@ export function RateCard({ item }: { item: ToRate }) {
) : null}
+ e.target.files?.[0] && addPhoto(e.target.files[0])}
+ />
+
{!item.isCook && item.cookName ? (