diff --git a/CLAUDE.md b/CLAUDE.md
index dedb75c..13372e0 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -7,14 +7,15 @@
> **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.27 — alle neun Arbeitspakete aus `docs/PROJEKTSTART.md` sind gebaut:
+> **Status:** 26.11.28 — 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),
-> bis zu 5 Fotos je Gericht (26.11.23), Gerichte einsprechen (26.11.24), Kassenbons (V2b, 26.11.25). Offen ist der
+> bis zu 5 Fotos je Gericht (26.11.23), Gerichte einsprechen (26.11.24), Kassenbons (V2b, 26.11.25),
+> Führung (26.11.27), Präsentationsmodus und Küchendisplay (26.11.28). Offen ist der
> Magic Link (braucht SMTP).
> **Letzte Aktualisierung:** 7. November 2026
@@ -394,6 +395,19 @@ Vorlagen ersetzt. `tests/seed.test.ts` prüft die Dateien. Ein Haushalt
übersprungen, ausgeblendet, „Fertig“ gesehen) und `members.seen_intro` (Migration 0017).
- Tests auf „Heute“ greifen Inhaltskarten über `main article h2`, nicht die erste h2.
+## Präsentation und Küchendisplay (seit 26.11.28)
+
+- `/praesentieren/[id]` (außerhalb von `(app)`, ohne Leiste): jedes Rezept groß, hochkant
+ untereinander, quer nebeneinander. Blättern: linkes Drittel der Bühne zurück, sonst
+ weiter, Wischen, Pfeiltasten, große Knöpfe unten. `?portionen=` kommt vom Plan.
+- Kochmodus und Präsentation teilen `components/cooking/kit.tsx` (Wake Lock, Timer
+ gegen die Uhr, Mengen). Die Präsentation ruft keine API — nur Ansehen und Timer.
+- Küchendisplay = Kindergerät mit `kind = 'kitchen'` (Migration 0018), Keks
+ `lunch_kueche`, Link `/kuechendisplay/`. Keine Sitzung: `/kueche` und die
+ Präsentation lesen über `lib/kitchen.ts` (`presenter`, `upcoming`), Fotos über
+ `readerHousehold()`. Jede andere Seite führt dorthin (`requireSession`), jede API sagt 401.
+ `currentKidDevice` sieht nur `kind = 'kids'` — ein Küchendisplay führt nie zur PIN.
+
## Rollen
- `admin`, `member`, `teen` (seit 26.11.19), `child`, `guest`. Wer was darf, steht nur
diff --git a/OlaresManifest.yaml b/OlaresManifest.yaml
index 5078931..8136c52 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.27
+ version: 26.11.28
categories:
- Applications
@@ -61,7 +61,7 @@ permission:
appData: true
spec:
- versionName: '26.11.27'
+ versionName: '26.11.28'
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 b8be003..19fefb7 100644
--- a/app/(app)/gerichte/[id]/page.tsx
+++ b/app/(app)/gerichte/[id]/page.tsx
@@ -1,4 +1,4 @@
-import { ChevronLeft } from "lucide-react";
+import { ChevronLeft, MonitorPlay } from "lucide-react";
import Link from "next/link";
import { notFound } from "next/navigation";
import { getLocale, getTranslations } from "next-intl/server";
@@ -76,6 +76,15 @@ export default async function DishPage({ params }: { params: Promise<{ id: strin
{photos.length ? : null}
{canWrite ? : null}
+ {dish.steps.length || dish.ingredients.length ? (
+
+
+ {t("detail.present")}
+
+ ) : null}
now() order by created_at`,
)
).rows;
@@ -110,8 +110,11 @@ export default async function MorePage() {
-
-
+
+ d.kind === "kids")} />
+
+
+ d.kind === "kitchen")} />
>
) : null}
diff --git a/app/api/auth/kids/device/route.ts b/app/api/auth/kids/device/route.ts
index df2f2cd..731697a 100644
--- a/app/api/auth/kids/device/route.ts
+++ b/app/api/auth/kids/device/route.ts
@@ -7,15 +7,16 @@ import { loadInstance } from "@/lib/auth/webauthn";
export const dynamic = "force-dynamic";
-// Einmal-Link einlösen: Dieses Gerät wird zum Kindergerät (Keks lunch_kids).
+// Einmal-Link einlösen: Dieses Gerät wird zum Kindergerät (Keks lunch_kids)
+// oder zum Küchendisplay (Keks lunch_kueche).
// POST statt GET, damit eine Link-Vorschau im Messenger den Link nicht verbraucht.
export async function POST(request: Request) {
const instance = await withAuth(loadInstance);
if (!instance || !sameOrigin(request, instance.origin)) return fail("origin", 403);
- const body = z.object({ token: z.string().min(20).max(100) }).safeParse(await readJson(request));
+ const body = z.object({ token: z.string().min(20).max(100), kind: z.enum(["kids", "kitchen"]).default("kids") }).safeParse(await readJson(request));
if (!body.success) return fail("invalid", 400);
const ip = request.headers.get("x-forwarded-for")?.split(",")[0]?.trim() ?? "?";
if (await withAuth((c) => tooManyAttempts(c, `kid-link:${ip}`, 10, 15))) return fail("tooMany", 429);
- const name = await redeemKidDeviceLink(body.data.token, isSecure(instance.origin));
+ const name = await redeemKidDeviceLink(body.data.token, isSecure(instance.origin), body.data.kind);
return name ? json({ household: name }) : fail("invitation", 410);
}
diff --git a/app/api/fotos/[id]/[photoId]/route.ts b/app/api/fotos/[id]/[photoId]/route.ts
index a1ebabc..2cd5f5c 100644
--- a/app/api/fotos/[id]/[photoId]/route.ts
+++ b/app/api/fotos/[id]/[photoId]/route.ts
@@ -1,4 +1,4 @@
-import { guardRead, isResponse } from "@/lib/auth/guard";
+import { isResponse, readerHousehold } from "@/lib/auth/guard";
import { fail } from "@/lib/auth/http";
import { withHousehold } from "@/lib/db";
import { readPhoto } from "@/lib/photos";
@@ -8,10 +8,10 @@ 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;
+ const household = await readerHousehold();
+ if (isResponse(household)) return household;
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) =>
+ const row = await withHousehold(household, 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);
diff --git a/app/api/fotos/[id]/route.ts b/app/api/fotos/[id]/route.ts
index cec7505..deecb5e 100644
--- a/app/api/fotos/[id]/route.ts
+++ b/app/api/fotos/[id]/route.ts
@@ -1,4 +1,4 @@
-import { guardRead, isResponse } from "@/lib/auth/guard";
+import { isResponse, readerHousehold } from "@/lib/auth/guard";
import { fail } from "@/lib/auth/http";
import { withHousehold } from "@/lib/db";
import { readPhoto } from "@/lib/photos";
@@ -9,10 +9,10 @@ export const dynamic = "force-dynamic";
// Adresse trägt die Prüfsumme (?v=…), also darf der Browser es lange behalten.
export async function GET(_: Request, { params }: { params: Promise<{ id: string }> }) {
const { id } = await params;
- const session = await guardRead();
- if (isResponse(session)) return session;
+ const household = await readerHousehold();
+ if (isResponse(household)) return household;
if (!/^[0-9a-f-]{36}$/.test(id)) return fail("invalid", 400);
- const row = await withHousehold(session.householdId, async (c) => (await c.query("select photo_path from dishes where id = $1", [id])).rows[0]);
+ const row = await withHousehold(household, async (c) => (await c.query("select photo_path from dishes where id = $1", [id])).rows[0]);
if (!row?.photo_path) return fail("notFound", 404);
const body = await readPhoto(row.photo_path).catch(() => null);
if (!body) return fail("notFound", 404);
diff --git a/app/api/household/kid-devices/route.ts b/app/api/household/kid-devices/route.ts
index a40bc6d..8bf5a4b 100644
--- a/app/api/household/kid-devices/route.ts
+++ b/app/api/household/kid-devices/route.ts
@@ -7,15 +7,16 @@ import { withAuth, withHousehold } from "@/lib/db";
export const dynamic = "force-dynamic";
-// Kindergeräte freischalten (Einmal-Link) und wieder entfernen — nur Admins.
+// Kindergeräte und Küchendisplays freischalten (Einmal-Link) und wieder entfernen — nur Admins.
export async function POST(request: Request) {
const session = await guardWrite(request, ["admin"]);
if (isResponse(session)) return session;
- const body = z.object({ label: z.string().trim().min(1).max(60) }).safeParse(await readJson(request));
+ const body = z.object({ label: z.string().trim().min(1).max(60), kind: z.enum(["kids", "kitchen"]).default("kids") }).safeParse(await readJson(request));
if (!body.success) return fail("invalid", 400);
const instance = (await withAuth(loadInstance))!;
- const token = await withHousehold(session.householdId, (c) => createKidDeviceLink(c, session.householdId, session.memberId, body.data.label));
- return json({ url: `${instance.origin}/kindergeraet/${token}`, hours: LINK_HOURS }, 201);
+ const token = await withHousehold(session.householdId, (c) => createKidDeviceLink(c, session.householdId, session.memberId, body.data.label, body.data.kind));
+ const path = body.data.kind === "kitchen" ? "kuechendisplay" : "kindergeraet";
+ return json({ url: `${instance.origin}/${path}/${token}`, hours: LINK_HOURS }, 201);
}
export async function DELETE(request: Request) {
diff --git a/app/kueche/page.tsx b/app/kueche/page.tsx
new file mode 100644
index 0000000..8e589e5
--- /dev/null
+++ b/app/kueche/page.tsx
@@ -0,0 +1,99 @@
+import { ChefHat } from "lucide-react";
+import Link from "next/link";
+import { redirect } from "next/navigation";
+import { getTranslations } from "next-intl/server";
+import { DishPhoto } from "@/components/dishes/dish-tile";
+import { AutoRefresh } from "@/components/kitchen/auto-refresh";
+import { currentKitchenDisplay } from "@/lib/auth/kids";
+import { getSession } from "@/lib/auth/session";
+import { withHousehold } from "@/lib/db";
+import { kitchenOverview } from "@/lib/kitchen";
+
+export const dynamic = "force-dynamic";
+
+// Küchendisplay (26.11.28): oben, was als Nächstes gekocht wird, darunter alle
+// Rezepte. Ein Tipp öffnet die Präsentation. Ansehen ja, ändern nein.
+export default async function KitchenPage() {
+ const device = await currentKitchenDisplay();
+ if (!device) redirect((await getSession()) ? "/" : "/anmelden");
+ const t = await getTranslations("kitchen");
+ const { next, dishes } = await withHousehold(device.householdId, kitchenOverview);
+ const [today, ...later] = next;
+
+ return (
+
+
+
+
+ {today ? (
+
+
+ {t("next")}
+
+
+
+
+
+
+
{today.title}
+
+ {today.cookName ? t("portionsCook", { n: today.portions, name: today.cookName }) : t("portions", { n: today.portions })}
+
+
+
+ {t("present")}
+
+
+
+ {later.length ? (
+
+ {later.map((s) => (
+ -
+
+ {s.title}
+
+
+ ))}
+
+ ) : null}
+
+ ) : (
+ {t("nothingPlanned")}
+ )}
+
+
+
+ {t("all")}
+
+ {dishes.length ? (
+
+ {dishes.map((d) => (
+ -
+
+
+
+
+ {d.title}
+
+
+ ))}
+
+ ) : (
+ {t("noDishes")}
+ )}
+
+
+ );
+}
diff --git a/app/kuechendisplay/[token]/page.tsx b/app/kuechendisplay/[token]/page.tsx
new file mode 100644
index 0000000..9cf0937
--- /dev/null
+++ b/app/kuechendisplay/[token]/page.tsx
@@ -0,0 +1,22 @@
+import { getTranslations } from "next-intl/server";
+import { AuthShell } from "@/components/auth/auth-shell";
+import { UnlockDevice } from "@/components/kids/unlock-device";
+import { kidDeviceLinkValid } from "@/lib/auth/kids";
+
+export const dynamic = "force-dynamic";
+// Der Link ist ein Geheimnis: nie als Referrer weitergeben.
+export const metadata = { referrer: "no-referrer" as const };
+
+// Küchendisplay freischalten: Wer den Einmal-Link auf dem Tablet oder Echo Show
+// öffnet und bestätigt, bekommt den Keks lunch_kueche — Rezepte ansehen, nichts ändern.
+export default async function KitchenDisplayUnlockPage({ params }: { params: Promise<{ token: string }> }) {
+ const { token } = await params;
+ const t = await getTranslations("kitchen");
+ const link = token.length <= 100 ? await kidDeviceLinkValid(token, "kitchen") : null;
+ if (!link) return ;
+ return (
+
+
+
+ );
+}
diff --git a/app/praesentieren/[id]/page.tsx b/app/praesentieren/[id]/page.tsx
new file mode 100644
index 0000000..5726aa4
--- /dev/null
+++ b/app/praesentieren/[id]/page.tsx
@@ -0,0 +1,36 @@
+import { notFound, redirect } from "next/navigation";
+import { getLocale } from "next-intl/server";
+import { Presentation } from "@/components/cooking/presentation";
+import { withHousehold } from "@/lib/db";
+import { getDish } from "@/lib/dishes";
+import { presenter } from "@/lib/kitchen";
+
+export const dynamic = "force-dynamic";
+
+// Ein Rezept präsentieren — aus jedem Gericht (angemeldet) und auf dem
+// Küchendisplay. ?portionen=… kommt vom Plan; sonst so viele, wie der Haushalt Köpfe hat.
+export default async function PresentPage({ params, searchParams }: { params: Promise<{ id: string }>; searchParams: Promise<{ portionen?: string }> }) {
+ const { id } = await params;
+ if (!/^[0-9a-f-]{36}$/.test(id)) notFound();
+ const who = await presenter();
+ if (!who) redirect("/anmelden");
+ const locale = await getLocale();
+ const { dish, people } = await withHousehold(who.householdId, async (c) => ({
+ dish: await getDish(c, id, locale),
+ people: (await c.query("select count(*)::int as n from members where role <> 'guest'")).rows[0].n as number,
+ }));
+ if (!dish) notFound();
+ const asked = Number((await searchParams).portionen);
+ const portions = Number.isInteger(asked) && asked >= 1 && asked <= 30 ? asked : Math.min(8, Math.max(2, people));
+ return (
+
+ );
+}
diff --git a/components/cooking/cooking-mode.tsx b/components/cooking/cooking-mode.tsx
index 479e2eb..c8a9450 100644
--- a/components/cooking/cooking-mode.tsx
+++ b/components/cooking/cooking-mode.tsx
@@ -1,37 +1,13 @@
"use client";
-import { Check, ChevronLeft, ChevronRight, Pause, Play, Sun, Timer as TimerIcon } from "lucide-react";
+import { Check, ChevronLeft, ChevronRight, Sun } from "lucide-react";
import { useRouter } from "next/navigation";
-import { useLocale, useTranslations } from "next-intl";
+import { useTranslations } from "next-intl";
import { useEffect, useRef, useState } from "react";
import { Button } from "@/components/ui/button";
import { ErrorNotice } from "@/components/ui/notice";
-import { labelFor } from "@/lib/ingredient-name";
-import type { Section } from "@/lib/recipe-style";
-import { timerFromText } from "@/lib/timer";
-import { formatQuantity, type BaseUnit } from "@/lib/units";
import { cn } from "@/lib/utils";
-
-type Ingredient = { ingredientId: string; name: string; forms: { one: string; other: string } | null; qtyPerPortion: number; unit: BaseUnit; note: string | null };
-type Step = { section: Section; text: string; timerSeconds: number | null; ingredientIds: string[]; timerFrom?: string };
-type Running = { step: number; endsAt: number | null; left: number; done: boolean };
-
-const mmss = (s: number) => `${Math.floor(s / 60)}:${String(Math.max(0, Math.round(s % 60))).padStart(2, "0")}`;
-
-function beep() {
- try {
- const ctx = new AudioContext();
- for (const [i, f] of [880, 660, 880].entries()) {
- const o = ctx.createOscillator();
- const g = ctx.createGain();
- o.frequency.value = f;
- o.connect(g).connect(ctx.destination);
- g.gain.setValueAtTime(0.2, ctx.currentTime + i * 0.35);
- o.start(ctx.currentTime + i * 0.35);
- o.stop(ctx.currentTime + i * 0.35 + 0.25);
- }
- } catch {}
-}
+import { AlarmNotice, TimerButton, TimerChips, useAmount, useStepTimers, useWakeLock, withTextTimer, type Ingredient, type Step } from "./kit";
// Kochmodus (Konzept, „Kochen“): erst Mise en place als Checkliste in der
// Portionszahl des Slots, dann Schritt für Schritt in großer Schrift mit Timer.
@@ -54,54 +30,16 @@ export function CookingMode({
}) {
const t = useTranslations("cooking");
const ts = useTranslations("dishes.sections");
- const locale = useLocale();
const router = useRouter();
const [index, setIndex] = useState(-1); // -1 = Mise en place
const [have, setHave] = useState>(new Set());
- const [timers, setTimers] = useState([]);
- const [awake, setAwake] = useState(false);
- const [alarm, setAlarm] = useState(null);
const [error, setError] = useState(false);
const [busy, setBusy] = useState(false);
const touch = useRef(null);
- // Display an lassen, solange der Kochmodus offen ist.
- useEffect(() => {
- let lock: WakeLockSentinel | null = null;
- const request = async () => {
- try {
- lock = (await navigator.wakeLock?.request("screen")) ?? null;
- setAwake(!!lock);
- } catch {
- setAwake(false);
- }
- };
- void request();
- const again = () => document.visibilityState === "visible" && void request();
- document.addEventListener("visibilitychange", again);
- return () => {
- document.removeEventListener("visibilitychange", again);
- void lock?.release().catch(() => undefined);
- };
- }, []);
-
- // Timer laufen weiter, auch beim Blättern; gerechnet wird gegen die Uhr, nicht gegen Intervalle.
- useEffect(() => {
- const tick = setInterval(() => {
- setTimers((list) =>
- list.map((r) => {
- if (r.done || r.endsAt === null) return r;
- const left = (r.endsAt - Date.now()) / 1000;
- if (left > 0) return { ...r, left };
- if ("vibrate" in navigator) navigator.vibrate?.([300, 150, 300]);
- beep();
- setAlarm(t("alarm", { n: r.step + 1 }));
- return { ...r, left: 0, done: true, endsAt: null };
- }),
- );
- }, 500);
- return () => clearInterval(tick);
- }, [t]);
+ const awake = useWakeLock();
+ const { timers, alarm, toggle: toggleTimer, running } = useStepTimers();
+ const { amount, label } = useAmount(portions);
const go = (by: number) => setIndex((i) => Math.min(steps.length - 1, Math.max(-1, i + by)));
@@ -115,16 +53,6 @@ export function CookingMode({
return () => window.removeEventListener("keydown", key);
});
- function toggleTimer(step: number, seconds: number) {
- setAlarm(null);
- setTimers((list) => {
- const r = list.find((x) => x.step === step);
- if (!r || r.done) return [...list.filter((x) => x.step !== step), { step, endsAt: Date.now() + seconds * 1000, left: seconds, done: false }];
- if (r.endsAt === null) return list.map((x) => (x.step === step ? { ...x, endsAt: Date.now() + x.left * 1000 } : x)); // weiter
- return list.map((x) => (x.step === step ? { ...x, endsAt: null } : x)); // Pause
- });
- }
-
async function finish() {
setBusy(true);
const res = await fetch(`/api/slots/${slotId}/cooked`, { method: "POST" }).catch(() => null);
@@ -135,14 +63,7 @@ export function CookingMode({
} else setError(true);
}
- const amount = (i: Ingredient) => {
- const f = formatQuantity(i.qtyPerPortion * portions, i.unit, locale);
- return `${f.amount}${f.unit ? ` ${f.unit}` : ""}`;
- };
- const raw = index >= 0 ? steps[index] : null;
- // Kein hinterlegter Timer? Dann die Zeit aus dem Text („30 Minuten köcheln“).
- const step = raw ? { ...raw, timerSeconds: raw.timerSeconds ?? timerFromText(raw.text) } : null;
- const running = timers.filter((r) => !r.done || r.left === 0);
+ const step = index >= 0 && steps[index] ? withTextTimer(steps[index]) : null;
return (
) : null}
-
- {alarm}
-
-
- {running.length ? (
-
- {running.map((r) => (
- -
-
-
- ))}
-
- ) : null}
+
+
= 0 && "hidden landscape:flex")}>
@@ -209,7 +116,7 @@ export function CookingMode({
{checked ? : null}
- {amount(i)} {labelFor(i, i.qtyPerPortion * portions)}
+ {amount(i)} {label(i)}
{i.note ? , {i.note} : null}
@@ -232,7 +139,7 @@ export function CookingMode({
.filter((i): i is Ingredient => !!i)
.map((i) => (
- {amount(i)} {labelFor(i, i.qtyPerPortion * portions)}
+ {amount(i)} {label(i)}
))}
@@ -269,17 +176,3 @@ export function CookingMode({
);
}
-
-function TimerButton({ running, seconds, onToggle }: { running: Running | undefined; seconds: number; onToggle: () => void }) {
- const t = useTranslations("cooking");
- const active = running && !running.done && running.endsAt !== null;
- const paused = running && !running.done && running.endsAt === null;
- const left = running && !running.done ? running.left : seconds;
- return (
-
- );
-}
diff --git a/components/cooking/kit.tsx b/components/cooking/kit.tsx
new file mode 100644
index 0000000..ac794dc
--- /dev/null
+++ b/components/cooking/kit.tsx
@@ -0,0 +1,148 @@
+"use client";
+
+import { Pause, Play, Timer as TimerIcon } from "lucide-react";
+import { useLocale, useTranslations } from "next-intl";
+import { useEffect, useState } from "react";
+import { Button } from "@/components/ui/button";
+import { labelFor } from "@/lib/ingredient-name";
+import type { Section } from "@/lib/recipe-style";
+import { timerFromText } from "@/lib/timer";
+import { formatQuantity, type BaseUnit } from "@/lib/units";
+import { cn } from "@/lib/utils";
+
+// Gemeinsames von Kochmodus und Präsentation (26.11.28): Display an lassen,
+// Timer gegen die Uhr, Mengen in der Portionszahl.
+
+export type Ingredient = { ingredientId: string; name: string; forms: { one: string; other: string } | null; qtyPerPortion: number; unit: BaseUnit; note: string | null };
+export type Step = { section: Section; text: string; timerSeconds: number | null; ingredientIds: string[]; timerFrom?: string };
+export type Running = { step: number; endsAt: number | null; left: number; done: boolean };
+
+export const mmss = (s: number) => `${Math.floor(s / 60)}:${String(Math.max(0, Math.round(s % 60))).padStart(2, "0")}`;
+
+function beep() {
+ try {
+ const ctx = new AudioContext();
+ for (const [i, f] of [880, 660, 880].entries()) {
+ const o = ctx.createOscillator();
+ const g = ctx.createGain();
+ o.frequency.value = f;
+ o.connect(g).connect(ctx.destination);
+ g.gain.setValueAtTime(0.2, ctx.currentTime + i * 0.35);
+ o.start(ctx.currentTime + i * 0.35);
+ o.stop(ctx.currentTime + i * 0.35 + 0.25);
+ }
+ } catch {}
+}
+
+/** Display an lassen, solange die Ansicht offen ist (Screen Wake Lock). */
+export function useWakeLock(): boolean {
+ const [awake, setAwake] = useState(false);
+ useEffect(() => {
+ let lock: WakeLockSentinel | null = null;
+ const request = async () => {
+ try {
+ lock = (await navigator.wakeLock?.request("screen")) ?? null;
+ setAwake(!!lock);
+ } catch {
+ setAwake(false);
+ }
+ };
+ void request();
+ const again = () => document.visibilityState === "visible" && void request();
+ document.addEventListener("visibilitychange", again);
+ return () => {
+ document.removeEventListener("visibilitychange", again);
+ void lock?.release().catch(() => undefined);
+ };
+ }, []);
+ return awake;
+}
+
+/** Timer je Schritt; laufen weiter beim Blättern, gerechnet gegen die Uhr, nicht gegen Intervalle. */
+export function useStepTimers() {
+ const t = useTranslations("cooking");
+ const [timers, setTimers] = useState([]);
+ const [alarm, setAlarm] = useState(null);
+ useEffect(() => {
+ const tick = setInterval(() => {
+ setTimers((list) =>
+ list.map((r) => {
+ if (r.done || r.endsAt === null) return r;
+ const left = (r.endsAt - Date.now()) / 1000;
+ if (left > 0) return { ...r, left };
+ if ("vibrate" in navigator) navigator.vibrate?.([300, 150, 300]);
+ beep();
+ setAlarm(t("alarm", { n: r.step + 1 }));
+ return { ...r, left: 0, done: true, endsAt: null };
+ }),
+ );
+ }, 500);
+ return () => clearInterval(tick);
+ }, [t]);
+
+ function toggle(step: number, seconds: number) {
+ setAlarm(null);
+ setTimers((list) => {
+ const r = list.find((x) => x.step === step);
+ if (!r || r.done) return [...list.filter((x) => x.step !== step), { step, endsAt: Date.now() + seconds * 1000, left: seconds, done: false }];
+ if (r.endsAt === null) return list.map((x) => (x.step === step ? { ...x, endsAt: Date.now() + x.left * 1000 } : x)); // weiter
+ return list.map((x) => (x.step === step ? { ...x, endsAt: null } : x)); // Pause
+ });
+ }
+
+ return { timers, alarm, toggle, running: timers.filter((r) => !r.done || r.left === 0) };
+}
+
+/** Kein hinterlegter Timer? Dann die Zeit aus dem Text („30 Minuten köcheln“). */
+export const withTextTimer = (s: Step): Step => ({ ...s, timerSeconds: s.timerSeconds ?? timerFromText(s.text) });
+
+/** „250 g“ in der Portionszahl, und der passende Name (Einzahl/Mehrzahl). */
+export function useAmount(portions: number) {
+ const locale = useLocale();
+ return {
+ amount: (i: Ingredient) => {
+ const f = formatQuantity(i.qtyPerPortion * portions, i.unit, locale);
+ return `${f.amount}${f.unit ? ` ${f.unit}` : ""}`;
+ },
+ label: (i: Ingredient) => labelFor(i, i.qtyPerPortion * portions),
+ };
+}
+
+export function AlarmNotice({ alarm }: { alarm: string | null }) {
+ return (
+
+ {alarm}
+
+ );
+}
+
+export function TimerChips({ running, onPick, className }: { running: Running[]; onPick: (step: number) => void; className?: string }) {
+ const t = useTranslations("cooking");
+ if (!running.length) return null;
+ return (
+
+ {running.map((r) => (
+ -
+
+
+ ))}
+
+ );
+}
+
+export function TimerButton({ running, seconds, onToggle, className }: { running: Running | undefined; seconds: number; onToggle: () => void; className?: string }) {
+ const t = useTranslations("cooking");
+ const active = running && !running.done && running.endsAt !== null;
+ const paused = running && !running.done && running.endsAt === null;
+ const left = running && !running.done ? running.left : seconds;
+ return (
+
+ );
+}
diff --git a/components/cooking/presentation.tsx b/components/cooking/presentation.tsx
new file mode 100644
index 0000000..97b6436
--- /dev/null
+++ b/components/cooking/presentation.tsx
@@ -0,0 +1,194 @@
+"use client";
+
+import { ChevronLeft, ChevronRight, Minus, Plus, Sun, X } from "lucide-react";
+import Link from "next/link";
+import { useTranslations } from "next-intl";
+import { useEffect, useRef, useState } from "react";
+import { DishPhoto } from "@/components/dishes/dish-tile";
+import { Button } from "@/components/ui/button";
+import { cn } from "@/lib/utils";
+import { AlarmNotice, TimerButton, TimerChips, useAmount, useStepTimers, useWakeLock, withTextTimer, type Ingredient, type Step } from "./kit";
+
+// Präsentationsmodus (Kai 7.11.2026, 26.11.28): ein Rezept zum Ablesen aus
+// Abstand — am Handy hochkant, auf Tablet oder Echo Show quer. Erst die Zutaten
+// in der Portionszahl, dann Schritt für Schritt in sehr großer Schrift. Blättern
+// durch Tippen (linkes Drittel zurück, sonst weiter), Wischen, Pfeiltasten oder
+// die großen Knöpfe unten. Ändert nichts: keine API, nur Ansehen und Timer.
+export function Presentation({
+ dishId,
+ title,
+ photo,
+ portions: initialPortions,
+ ingredients,
+ steps,
+ closeHref,
+}: {
+ dishId: string;
+ title: string;
+ photo: string | null;
+ portions: number;
+ ingredients: Ingredient[];
+ steps: Step[];
+ closeHref: string;
+}) {
+ const t = useTranslations("present");
+ const tc = useTranslations("cooking");
+ const ts = useTranslations("dishes.sections");
+ const [index, setIndex] = useState(-1); // -1 = Zutaten
+ const [portions, setPortions] = useState(initialPortions);
+ const awake = useWakeLock();
+ const { timers, alarm, toggle, running } = useStepTimers();
+ const { amount, label } = useAmount(portions);
+ const touch = useRef<{ x: number; y: number } | null>(null);
+ const swiped = useRef(false);
+
+ const last = steps.length - 1;
+ const go = (by: number) => setIndex((i) => Math.min(last, Math.max(-1, i + by)));
+
+ useEffect(() => {
+ const key = (e: KeyboardEvent) => {
+ if (e.key === "ArrowRight" || e.key === "PageDown") go(1);
+ if (e.key === "ArrowLeft" || e.key === "PageUp") go(-1);
+ };
+ window.addEventListener("keydown", key);
+ return () => window.removeEventListener("keydown", key);
+ });
+
+ const step = index >= 0 && steps[index] ? withTextTimer(steps[index]) : null;
+ const forStep = step
+ ? step.ingredientIds.map((id) => ingredients.find((i) => i.ingredientId === id)).filter((i): i is Ingredient => !!i)
+ : [];
+
+ return (
+
+
+
+
+
+ {title}
+ {awake ? (
+
+
+ {tc("awake")}
+
+ ) : null}
+
+
+
+
+
+ {/* Die ganze Fläche blättert: linkes Drittel zurück, der Rest weiter. Knöpfe darin bleiben Knöpfe. */}
+ {
+ const p = e.touches[0];
+ touch.current = p ? { x: p.clientX, y: p.clientY } : null;
+ swiped.current = false;
+ }}
+ onTouchEnd={(e) => {
+ const start = touch.current;
+ const end = e.changedTouches[0];
+ touch.current = null;
+ if (!start || !end) return;
+ const dx = end.clientX - start.x;
+ if (Math.abs(dx) < 60 || Math.abs(dx) < Math.abs(end.clientY - start.y)) return;
+ swiped.current = true;
+ go(dx < 0 ? 1 : -1);
+ }}
+ onClick={(e) => {
+ if (swiped.current) return void (swiped.current = false);
+ if ((e.target as HTMLElement).closest("button, a, input")) return;
+ const box = e.currentTarget.getBoundingClientRect();
+ go(e.clientX - box.left < box.width / 3 ? -1 : 1);
+ }}
+ >
+ {step ? (
+
+
+
+ {ts(step.section)} · {tc("step", { n: index + 1, of: steps.length })}
+
+
{step.text}
+ {step.timerSeconds ? (
+
r.step === index)}
+ seconds={step.timerSeconds}
+ onToggle={() => toggle(index, step.timerSeconds!)}
+ className="h-20 px-8 text-4xl"
+ />
+ ) : null}
+ {step.timerSeconds && step.timerFrom ? {tc("timerFromProduct", { product: step.timerFrom })}
: null}
+
+ {forStep.length ? (
+
+ {forStep.map((i) => (
+ -
+ {amount(i)} {label(i)}
+
+ ))}
+
+ ) : null}
+
+ ) : (
+
+
+ {/* Ohne Foto kein Platzhalter: hochkant gehört der Platz den Zutaten. */}
+ {photo ? (
+
+
+
+ ) : null}
+
+
+
+ {t("portionsN", { n: portions })}
+
+
+
+
+
+
+ {t("ingredients")}
+
+
+ {ingredients.map((i) => (
+ -
+ {amount(i)} {label(i)}
+ {i.note ? , {i.note} : null}
+
+ ))}
+
+
+
+ )}
+
+
+
+
+ );
+}
diff --git a/components/kids/unlock-device.tsx b/components/kids/unlock-device.tsx
index 0d02254..5c0deb6 100644
--- a/components/kids/unlock-device.tsx
+++ b/components/kids/unlock-device.tsx
@@ -6,7 +6,7 @@ import { useState } from "react";
import { Button } from "@/components/ui/button";
import { ErrorNotice } from "@/components/ui/notice";
-export function UnlockDevice({ token }: { token: string }) {
+export function UnlockDevice({ token, kind = "kids" }: { token: string; kind?: "kids" | "kitchen" }) {
const t = useTranslations("kids");
const router = useRouter();
const [busy, setBusy] = useState(false);
@@ -23,10 +23,10 @@ export function UnlockDevice({ token }: { token: string }) {
const res = await fetch("/api/auth/kids/device", {
method: "POST",
headers: { "content-type": "application/json" },
- body: JSON.stringify({ token }),
+ body: JSON.stringify({ token, kind }),
});
setBusy(false);
- if (res.ok) router.replace("/kinder");
+ if (res.ok) router.replace(kind === "kitchen" ? "/kueche" : "/kinder");
else setError(true);
}}
>
diff --git a/components/kitchen/auto-refresh.tsx b/components/kitchen/auto-refresh.tsx
new file mode 100644
index 0000000..8999c2c
--- /dev/null
+++ b/components/kitchen/auto-refresh.tsx
@@ -0,0 +1,20 @@
+"use client";
+
+import { useRouter } from "next/navigation";
+import { useEffect } from "react";
+
+// Das Küchendisplay hängt tagelang an der Wand: alle paar Minuten neu laden,
+// damit „Als Nächstes“ dem Plan folgt — nur, solange es sichtbar ist.
+export function AutoRefresh({ minutes = 5 }: { minutes?: number }) {
+ const router = useRouter();
+ useEffect(() => {
+ const id = setInterval(() => document.visibilityState === "visible" && router.refresh(), minutes * 60_000);
+ const back = () => document.visibilityState === "visible" && router.refresh();
+ document.addEventListener("visibilitychange", back);
+ return () => {
+ clearInterval(id);
+ document.removeEventListener("visibilitychange", back);
+ };
+ }, [router, minutes]);
+ return null;
+}
diff --git a/components/more/kids-admin.tsx b/components/more/kids-admin.tsx
index 5784a0f..9c98925 100644
--- a/components/more/kids-admin.tsx
+++ b/components/more/kids-admin.tsx
@@ -252,9 +252,9 @@ export function KidsAdmin({ kids }: { kids: Child[] }) {
);
}
-/** Kindergeräte: freischalten per Einmal-Link, entfernen (nur Admin). */
-export function KidDevices({ devices }: { devices: Device[] }) {
- const t = useTranslations("more.kids");
+/** Kindergeräte oder Küchendisplays: freischalten per Einmal-Link, entfernen (nur Admin). */
+export function KidDevices({ devices, kind = "kids" }: { devices: Device[]; kind?: "kids" | "kitchen" }) {
+ const t = useTranslations(kind === "kitchen" ? "more.kitchen" : "more.kids");
const router = useRouter();
const [label, setLabel] = useState("");
const [created, setCreated] = useState<{ url: string; days: number } | null>(
@@ -299,7 +299,7 @@ export function KidDevices({ devices }: { devices: Device[] }) {
className="flex flex-col gap-3"
onSubmit={async (e) => {
e.preventDefault();
- const r = await send("POST", "/api/household/kid-devices", { label });
+ const r = await send("POST", "/api/household/kid-devices", { label, kind });
if (r.ok) {
setCreated({ url: r.data.url, days: 1 });
setLabel("");
@@ -308,9 +308,9 @@ export function KidDevices({ devices }: { devices: Device[] }) {
}}
>
-
+
{
+ const context = await browser.newContext({ ...test.info().project.use, storageState: undefined, ...extra });
+ return context.newPage();
+}
+
+/** Auf die Bühne tippen, bei einem Anteil der Breite (0 = links, 1 = rechts), knapp unter ihrer Oberkante. */
+async function tap(page: Page, fraction: number) {
+ const stage = page.getByTestId("present-stage");
+ const box = (await stage.boundingBox())!;
+ await stage.click({ position: { x: Math.round(box.width * fraction) + 1, y: 12 } });
+}
+
+const stepLabel = (page: Page) => page.getByRole("heading", { level: 2, name: /Schritt \d+ von \d+/ });
+
+async function swipe(page: Page, from: number, to: number) {
+ await page.getByTestId("present-stage").evaluate(
+ (el, { a, b }) => {
+ const y = el.getBoundingClientRect().top + 100;
+ const touch = (x: number) => new Touch({ identifier: 1, target: el, clientX: x, clientY: y });
+ el.dispatchEvent(new TouchEvent("touchstart", { bubbles: true, touches: [touch(a)], changedTouches: [touch(a)] }));
+ el.dispatchEvent(new TouchEvent("touchend", { bubbles: true, touches: [], changedTouches: [touch(b)] }));
+ },
+ { a: from, b: to },
+ );
+}
+
+test("an admin unlocks a kitchen display with a one-time link", async ({ page, browser }) => {
+ await page.goto("/mehr");
+ await page.fill("#device-label-kitchen", "Echo Show");
+ await page.locator("#kueche").getByRole("button", { name: "Link zum Freischalten erstellen" }).click();
+ const url = await page.locator("#kueche").getByRole("textbox", { name: "Link" }).inputValue();
+ expect(url).toContain("/kuechendisplay/");
+
+ // Ein Kindergerät-Link ist er nicht.
+ const kid = await freshPage(browser);
+ await kid.goto(url.replace("/kuechendisplay/", "/kindergeraet/"));
+ await expect(kid.getByRole("heading", { level: 1 })).toHaveText("Link abgelaufen");
+
+ display = await freshPage(browser, ECHO_SHOW);
+ await display.goto(url);
+ await expect(display.getByRole("heading", { level: 1 })).toHaveText("„Echo Show“ als Küchendisplay freischalten");
+ await display.getByRole("button", { name: "Dieses Gerät freischalten" }).click();
+ await expect(display).toHaveURL(/\/kueche$/);
+ await expect(display.getByRole("heading", { level: 1 })).toHaveText("Familie Böhm");
+ await expect(display.getByRole("heading", { name: "Alle Rezepte" })).toBeVisible();
+});
+
+test("the kitchen display can look but not change anything", async () => {
+ for (const path of ["/", "/gerichte", "/plan", "/einkauf", "/mehr"]) {
+ await display.goto(path);
+ await expect(display).toHaveURL(/\/kueche$/);
+ }
+ await display.goto("/kinder");
+ await expect(display.getByRole("heading", { level: 1 })).toHaveText("Kein Kindergerät");
+ const status = await display.evaluate(async () =>
+ Promise.all(
+ [
+ ["/api/household/kid-devices", { label: "Noch eins", kind: "kitchen" }],
+ ["/api/rounds", { slotsCount: 3, defaultPortions: 4, shoppingDate: null }],
+ ].map(async ([url, body]) => (await fetch(url as string, { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify(body) })).status),
+ ),
+ );
+ expect(status).toEqual([401, 401]);
+});
+
+test("a recipe is presented in landscape: tap right for next, left for back, swipe and keys", async () => {
+ await display.goto("/kueche");
+ await display.getByRole("region", { name: "Alle Rezepte" }).getByRole("link", { name: "Spaghetti Bolognese" }).click();
+ await expect(display.getByRole("heading", { level: 1 })).toHaveText("Spaghetti Bolognese");
+ await expect(display.getByRole("heading", { name: "Zutaten" })).toBeVisible();
+
+ await tap(display, 0.8);
+ await expect(stepLabel(display)).toContainText("Schritt 1 von");
+ await display.keyboard.press("ArrowRight");
+ await expect(stepLabel(display)).toContainText("Schritt 2 von");
+ await tap(display, 0.05);
+ await expect(stepLabel(display)).toContainText("Schritt 1 von");
+ await swipe(display, 800, 200);
+ await expect(stepLabel(display)).toContainText("Schritt 2 von");
+ await swipe(display, 200, 800);
+ await expect(stepLabel(display)).toContainText("Schritt 1 von");
+ await display.getByRole("button", { name: "Zurück" }).click();
+ await expect(display.getByRole("heading", { name: "Zutaten" })).toBeVisible();
+
+ // Quer: Zutaten und Text nebeneinander, nichts ragt hinaus.
+ const overflow = await display.evaluate(() => document.documentElement.scrollWidth - window.innerWidth);
+ expect(overflow).toBeLessThanOrEqual(0);
+
+ await display.getByRole("link", { name: "Präsentation schließen" }).click();
+ await expect(display).toHaveURL(/\/kueche$/);
+});
+
+test("from any dish page, signed in: present with portions", async ({ page }) => {
+ await page.goto("/gerichte");
+ await page.getByRole("link", { name: /Spaghetti Bolognese/ }).first().click();
+ await page.getByRole("link", { name: "Präsentieren" }).click();
+ await expect(page).toHaveURL(/\/praesentieren\/.+portionen=\d+/);
+ const portions = page.getByRole("group", { name: "Portionen" });
+ const before = Number((await portions.locator("p").innerText()).match(/\d+/)![0]);
+ await portions.getByRole("button", { name: "Eine Portion mehr" }).click();
+ await expect(portions.locator("p")).toHaveText(`${before + 1} Portionen`);
+ await page.getByRole("button", { name: "Los geht's" }).click();
+ await expect(stepLabel(page)).toContainText("Schritt 1 von");
+ await page.getByRole("link", { name: "Präsentation schließen" }).click();
+ await expect(page.getByRole("heading", { level: 1 })).toHaveText("Spaghetti Bolognese");
+});
+
+test("removing the display ends it", async ({ page }) => {
+ await page.goto("/mehr");
+ await page.getByRole("button", { name: "Echo Show entfernen" }).click();
+ await expect(page.getByRole("button", { name: "Echo Show entfernen" })).toHaveCount(0);
+ await display.goto("/kueche");
+ await expect(display).toHaveURL(/\/anmelden$/);
+});
diff --git a/e2e/rundgang.spec.ts b/e2e/rundgang.spec.ts
index 7749583..42c9f70 100644
--- a/e2e/rundgang.spec.ts
+++ b/e2e/rundgang.spec.ts
@@ -118,3 +118,26 @@ test("the bottom bar never covers the last element", async ({ page }) => {
})
.toBe(true);
});
+
+test("signed in: a dish presented", async ({ page }) => {
+ await page.goto("/gerichte");
+ const href = await page.getByRole("link", { name: /Spaghetti Bolognese/ }).first().getAttribute("href");
+ await check(page, href!.replace("/gerichte/", "/praesentieren/"), "Spaghetti Bolognese");
+});
+
+test("kitchen display: overview", async ({ page, browser }) => {
+ await page.goto("/mehr");
+ const created = await page.evaluate(async () => {
+ const res = await fetch("/api/household/kid-devices", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ label: "Rundgang", kind: "kitchen" }) });
+ return (await res.json()) as { url: string };
+ });
+ const context = await browser.newContext({ ...test.info().project.use, storageState: undefined });
+ const display = await context.newPage();
+ await display.goto(new URL(created.url).pathname);
+ await display.getByRole("button", { name: "Dieses Gerät freischalten" }).click();
+ await expect(display).toHaveURL(/\/kueche$/);
+ await check(display, "/kueche", "Familie Böhm");
+ await context.close();
+ await page.reload();
+ await page.getByRole("button", { name: "Rundgang entfernen" }).click();
+});
diff --git a/lib/auth/guard.ts b/lib/auth/guard.ts
index 2bb5ab7..3e559f7 100644
--- a/lib/auth/guard.ts
+++ b/lib/auth/guard.ts
@@ -1,6 +1,7 @@
import "server-only";
import { withAuth } from "@/lib/db";
import { fail, sameOrigin } from "./http";
+import { currentKitchenDisplay } from "./kids";
import { getSession, type Session } from "./session";
import { loadInstance } from "./webauthn";
@@ -25,4 +26,11 @@ export async function guardRead(): Promise
{
return (await getSession()) ?? fail("signedOut", 401);
}
+/** Für Fotos: die Sitzung oder ein Küchendisplay — nur der Haushalt, nie eine Rolle. */
+export async function readerHousehold(): Promise {
+ const session = await getSession();
+ if (session) return session.householdId;
+ return (await currentKitchenDisplay())?.householdId ?? fail("signedOut", 401);
+}
+
export const isResponse = (x: unknown): x is Response => x instanceof Response;
diff --git a/lib/auth/kids.ts b/lib/auth/kids.ts
index 8244470..29ee4cb 100644
--- a/lib/auth/kids.ts
+++ b/lib/auth/kids.ts
@@ -9,52 +9,60 @@ import { hashToken, randomToken } from "./tokens";
// mit diesem Keks gibt es die Anmeldung mit Bild und PIN (/kinder).
export const KIDS_COOKIE = "lunch_kids";
+// Küchendisplay (26.11.28): dieselbe Freischaltung, eigener Keks, nur Ansehen.
+export const KITCHEN_COOKIE = "lunch_kueche";
+
+export type DeviceKind = "kids" | "kitchen";
+const COOKIE: Record = { kids: KIDS_COOKIE, kitchen: KITCHEN_COOKIE };
const COOKIE_DAYS = 400; // Höchstwert der Browser
export const LINK_HOURS = 24;
export type KidDevice = { id: string; householdId: string; householdName: string; label: string };
/** Das freigeschaltete Gerät zum Keks, oder null. */
-export async function currentKidDevice(): Promise {
- const token = (await cookies()).get(KIDS_COOKIE)?.value;
- if (!token) return null;
+export async function currentDevice(kind: DeviceKind): Promise {
+ const token = (await cookies()).get(COOKIE[kind])?.value;
+ if (!token || token.length > 100) return null;
return withAuth(async (c) => {
const { rows } = await c.query(
`select d.id, d.household_id as "householdId", h.name as "householdName", d.label
from kid_devices d join households h on h.id = d.household_id
- where d.token_hash = $1`,
- [hashToken(token)],
+ where d.token_hash = $1 and d.kind = $2`,
+ [hashToken(token), kind],
);
return rows[0] ?? null;
});
}
+export const currentKidDevice = () => currentDevice("kids");
+export const currentKitchenDisplay = () => currentDevice("kitchen");
+
/** Neuer Einmal-Link für ein Kindergerät (in einer withHousehold-Transaktion). */
-export async function createKidDeviceLink(client: PoolClient, householdId: string, memberId: string, label: string): Promise {
+export async function createKidDeviceLink(client: PoolClient, householdId: string, memberId: string, label: string, kind: DeviceKind = "kids"): Promise {
const token = randomToken();
await client.query(
- `insert into kid_devices (household_id, label, link_hash, link_expires_at, created_by)
- values ($1, $2, $3, now() + make_interval(hours => $4), $5)`,
- [householdId, label.trim(), hashToken(token), LINK_HOURS, memberId],
+ `insert into kid_devices (household_id, label, link_hash, link_expires_at, created_by, kind)
+ values ($1, $2, $3, now() + make_interval(hours => $4), $5, $6)`,
+ [householdId, label.trim(), hashToken(token), LINK_HOURS, memberId, kind],
);
return token;
}
/** Link einlösen: setzt den Keks des Geräts. Gibt den Haushaltsnamen zurück oder null. */
-export async function redeemKidDeviceLink(linkToken: string, secure: boolean): Promise {
+export async function redeemKidDeviceLink(linkToken: string, secure: boolean, kind: DeviceKind = "kids"): Promise {
const deviceToken = randomToken();
const name = await withAuth(async (c) => {
const { rows } = await c.query(
`update kid_devices d set token_hash = $2, link_hash = null, link_expires_at = null, last_used_at = now()
from households h
- where d.link_hash = $1 and d.link_expires_at > now() and h.id = d.household_id
+ where d.link_hash = $1 and d.link_expires_at > now() and d.kind = $3 and h.id = d.household_id
returning h.name`,
- [hashToken(linkToken), hashToken(deviceToken)],
+ [hashToken(linkToken), hashToken(deviceToken), kind],
);
return (rows[0]?.name as string | undefined) ?? null;
});
if (!name) return null;
- (await cookies()).set(KIDS_COOKIE, deviceToken, {
+ (await cookies()).set(COOKIE[kind], deviceToken, {
httpOnly: true,
secure,
sameSite: "lax",
@@ -65,12 +73,12 @@ export async function redeemKidDeviceLink(linkToken: string, secure: boolean): P
}
/** Gibt es einen offenen Link zu diesem Token? (Für die Seite vor dem Bestätigen.) */
-export async function kidDeviceLinkValid(linkToken: string): Promise<{ label: string; householdName: string } | null> {
+export async function kidDeviceLinkValid(linkToken: string, kind: DeviceKind = "kids"): Promise<{ label: string; householdName: string } | null> {
return withAuth(async (c) => {
const { rows } = await c.query(
`select d.label, h.name as "householdName" from kid_devices d join households h on h.id = d.household_id
- where d.link_hash = $1 and d.link_expires_at > now()`,
- [hashToken(linkToken)],
+ where d.link_hash = $1 and d.link_expires_at > now() and d.kind = $2`,
+ [hashToken(linkToken), kind],
);
return rows[0] ?? null;
});
diff --git a/lib/auth/session.ts b/lib/auth/session.ts
index c45616e..790a393 100644
--- a/lib/auth/session.ts
+++ b/lib/auth/session.ts
@@ -5,7 +5,7 @@ import { cookies } from "next/headers";
import { redirect } from "next/navigation";
import { withAuth } from "@/lib/db";
import { LOCALE_COOKIE, isLocale } from "@/lib/locale";
-import { KIDS_COOKIE } from "./kids";
+import { KIDS_COOKIE, KITCHEN_COOKIE } from "./kids";
import { hashToken, randomToken } from "./tokens";
// Sitzungen: ein Zufallsgeheimnis im Keks (HttpOnly), in der Datenbank nur
@@ -92,10 +92,13 @@ export async function getSession(): Promise {
});
}
-/** Für geschützte Seiten: ohne Sitzung zur Anmeldung — auf einem Kindergerät zur Bildauswahl. */
+/** Für geschützte Seiten: ohne Sitzung zur Anmeldung — auf einem Kindergerät zur Bildauswahl, auf dem Küchendisplay zu den Rezepten. */
export async function requireSession(): Promise {
const session = await getSession();
- if (!session) redirect((await cookies()).has(KIDS_COOKIE) ? "/kinder" : "/anmelden");
+ if (!session) {
+ const jar = await cookies();
+ redirect(jar.has(KIDS_COOKIE) ? "/kinder" : jar.has(KITCHEN_COOKIE) ? "/kueche" : "/anmelden");
+ }
return session;
}
diff --git a/lib/kitchen.ts b/lib/kitchen.ts
new file mode 100644
index 0000000..6427e07
--- /dev/null
+++ b/lib/kitchen.ts
@@ -0,0 +1,35 @@
+import "server-only";
+import type { PoolClient } from "pg";
+import { getSession } from "./auth/session";
+import { currentKitchenDisplay } from "./auth/kids";
+import { listDishes, type DishSummary } from "./dishes";
+import { currentRound } from "./rounds";
+
+// Küchendisplay und Präsentation (26.11.28): wer darf ansehen, und was steht an.
+
+/** Wer ein Rezept präsentieren darf: eine Sitzung (nicht Gast) oder ein Küchendisplay. */
+export async function presenter(): Promise<{ householdId: string; display: boolean } | null> {
+ const session = await getSession();
+ if (session) return session.role === "guest" ? null : { householdId: session.householdId, display: false };
+ const device = await currentKitchenDisplay();
+ return device ? { householdId: device.householdId, display: true } : null;
+}
+
+export type PlannedDish = { slotId: string; dishId: string; title: string; photo: string | null; portions: number; cookName: string | null };
+
+/** Die noch nicht gekochten Gerichte der laufenden Runde, in Reihenfolge; das erste ist „Heute“. */
+export async function upcoming(client: PoolClient): Promise {
+ const round = await currentRound(client);
+ if (!round || round.status === "open") return [];
+ const { rows } = await client.query(
+ `select s.id as "slotId", d.id as "dishId", d.title, d.photo_path as photo, s.portions, m.display_name as "cookName"
+ from slots s join dishes d on d.id = s.dish_id left join members m on m.id = s.cook_member_id
+ where s.round_id = $1 and s.cooked_at is null order by s.position`,
+ [round.id],
+ );
+ return rows;
+}
+
+export async function kitchenOverview(client: PoolClient): Promise<{ next: PlannedDish[]; dishes: DishSummary[] }> {
+ return { next: await upcoming(client), dishes: await listDishes(client) };
+}
diff --git a/messages/de.json b/messages/de.json
index 04c32bd..0f92724 100644
--- a/messages/de.json
+++ b/messages/de.json
@@ -222,6 +222,17 @@
"big": "Für Größere",
"small": "Für Kleine"
}
+ },
+ "kitchen": {
+ "title": "Küchendisplay",
+ "devicesHint": "Ein Tablet oder Echo Show in der Küche freischalten: Link erstellen und auf dem Gerät öffnen. Es zeigt Rezepte und Plan groß an und kann nichts ändern.",
+ "deviceLabel": "Name des Displays",
+ "deviceLabelPlaceholder": "z. B. Echo Show Küche",
+ "unlockDevice": "Link zum Freischalten erstellen",
+ "deviceActive": "freigeschaltet",
+ "devicePending": "Link offen, noch nicht freigeschaltet",
+ "removeDevice": "{label} entfernen",
+ "remove": "Entfernen"
}
},
"nav": {
@@ -297,7 +308,8 @@
"pieces": "{n, plural, one {Stück} other {Stück}}",
"stepTimerProduct": "{n} Min. laut Packung ({product})",
"photoAdd": "Foto dazu ({n} von {max})",
- "photoFull": "5 Fotos sind das Maximum"
+ "photoFull": "5 Fotos sind das Maximum",
+ "present": "Präsentieren"
},
"form": {
"newTitle": "Neues Gericht",
@@ -884,5 +896,29 @@
"title": "Du darfst mitbestimmen!",
"text": "Tipp auf ein Gericht, das du essen möchtest. Deine Münzen zeigen, wie viele Wünsche du noch hast."
}
+ },
+ "present": {
+ "close": "Präsentation schließen",
+ "portions": "Portionen",
+ "fewer": "Eine Portion weniger",
+ "more": "Eine Portion mehr",
+ "portionsN": "{n, plural, one {1 Portion} other {# Portionen}}",
+ "ingredients": "Zutaten",
+ "steps": "Blättern"
+ },
+ "kitchen": {
+ "eyebrow": "Küchendisplay · {label}",
+ "next": "Als Nächstes",
+ "portions": "{n, plural, one {1 Portion} other {# Portionen}}",
+ "portionsCook": "{n, plural, one {1 Portion} other {# Portionen}} · kocht {name}",
+ "present": "Rezept zeigen",
+ "later": "Danach im Plan",
+ "nothingPlanned": "Gerade ist nichts geplant. Alle Rezepte stehen unten.",
+ "all": "Alle Rezepte",
+ "noDishes": "Noch keine Gerichte.",
+ "unlockTitle": "„{label}“ als Küchendisplay freischalten",
+ "unlockText": "Danach zeigt dieses Gerät die Rezepte und den Plan von {household} — groß, zum Ablesen beim Kochen. Ändern kann man hier nichts.",
+ "linkExpiredTitle": "Link abgelaufen",
+ "linkExpiredText": "Dieser Link gilt nicht mehr. Ein Admin kann unter „Mehr“ › „Küchendisplay“ einen neuen erstellen."
}
}
diff --git a/messages/en.json b/messages/en.json
index f560a14..3db2872 100644
--- a/messages/en.json
+++ b/messages/en.json
@@ -222,6 +222,17 @@
"big": "For older kids",
"small": "For little ones"
}
+ },
+ "kitchen": {
+ "title": "Kitchen display",
+ "devicesHint": "Unlock a tablet or Echo Show in the kitchen: create a link and open it on the device. It shows recipes and the plan in large type and cannot change anything.",
+ "deviceLabel": "Name of the display",
+ "deviceLabelPlaceholder": "e.g. Kitchen Echo Show",
+ "unlockDevice": "Create unlock link",
+ "deviceActive": "unlocked",
+ "devicePending": "Link open, not yet unlocked",
+ "removeDevice": "Remove {label}",
+ "remove": "Remove"
}
},
"nav": {
@@ -297,7 +308,8 @@
"pieces": "{n, plural, one {piece} other {pieces}}",
"stepTimerProduct": "{n} min per pack ({product})",
"photoAdd": "Add photo ({n} of {max})",
- "photoFull": "5 photos is the maximum"
+ "photoFull": "5 photos is the maximum",
+ "present": "Present"
},
"form": {
"newTitle": "New dish",
@@ -884,5 +896,29 @@
"title": "You get a say!",
"text": "Tap a dish you'd like to eat. Your coins show how many wishes you have left."
}
+ },
+ "present": {
+ "close": "Close presentation",
+ "portions": "Portions",
+ "fewer": "One portion less",
+ "more": "One portion more",
+ "portionsN": "{n, plural, one {1 portion} other {# portions}}",
+ "ingredients": "Ingredients",
+ "steps": "Page through"
+ },
+ "kitchen": {
+ "eyebrow": "Kitchen display · {label}",
+ "next": "Up next",
+ "portions": "{n, plural, one {1 portion} other {# portions}}",
+ "portionsCook": "{n, plural, one {1 portion} other {# portions}} · {name} cooks",
+ "present": "Show recipe",
+ "later": "Later in the plan",
+ "nothingPlanned": "Nothing is planned right now. All recipes are below.",
+ "all": "All recipes",
+ "noDishes": "No dishes yet.",
+ "unlockTitle": "Unlock “{label}” as kitchen display",
+ "unlockText": "This device will then show the recipes and plan of {household} — large, for reading while cooking. Nothing can be changed here.",
+ "linkExpiredTitle": "Link expired",
+ "linkExpiredText": "This link is no longer valid. An admin can create a new one under “More” › “Kitchen display”."
}
}
diff --git a/messages/es.json b/messages/es.json
index 25b7406..cec1033 100644
--- a/messages/es.json
+++ b/messages/es.json
@@ -222,6 +222,17 @@
"big": "Para mayores",
"small": "Para peques"
}
+ },
+ "kitchen": {
+ "title": "Kitchen display",
+ "devicesHint": "Unlock a tablet or Echo Show in the kitchen: create a link and open it on the device. It shows recipes and the plan in large type and cannot change anything.",
+ "deviceLabel": "Name of the display",
+ "deviceLabelPlaceholder": "e.g. Kitchen Echo Show",
+ "unlockDevice": "Create unlock link",
+ "deviceActive": "unlocked",
+ "devicePending": "Link open, not yet unlocked",
+ "removeDevice": "Remove {label}",
+ "remove": "Remove"
}
},
"nav": {
@@ -297,7 +308,8 @@
"pieces": "{n, plural, one {piece} other {pieces}}",
"stepTimerProduct": "{n} min según el paquete ({product})",
"photoAdd": "Añadir foto ({n} de {max})",
- "photoFull": "5 fotos es el máximo"
+ "photoFull": "5 fotos es el máximo",
+ "present": "Present"
},
"form": {
"newTitle": "New dish",
@@ -884,5 +896,29 @@
"title": "¡Tú también decides!",
"text": "Toca un plato que quieras comer. Tus monedas muestran cuántos deseos te quedan."
}
+ },
+ "present": {
+ "close": "Close presentation",
+ "portions": "Portions",
+ "fewer": "One portion less",
+ "more": "One portion more",
+ "portionsN": "{n, plural, one {1 portion} other {# portions}}",
+ "ingredients": "Ingredients",
+ "steps": "Page through"
+ },
+ "kitchen": {
+ "eyebrow": "Kitchen display · {label}",
+ "next": "Up next",
+ "portions": "{n, plural, one {1 portion} other {# portions}}",
+ "portionsCook": "{n, plural, one {1 portion} other {# portions}} · {name} cooks",
+ "present": "Show recipe",
+ "later": "Later in the plan",
+ "nothingPlanned": "Nothing is planned right now. All recipes are below.",
+ "all": "All recipes",
+ "noDishes": "No dishes yet.",
+ "unlockTitle": "Unlock “{label}” as kitchen display",
+ "unlockText": "This device will then show the recipes and plan of {household} — large, for reading while cooking. Nothing can be changed here.",
+ "linkExpiredTitle": "Link expired",
+ "linkExpiredText": "This link is no longer valid. An admin can create a new one under “More” › “Kitchen display”."
}
}
diff --git a/messages/fr.json b/messages/fr.json
index b53cd5e..18a4788 100644
--- a/messages/fr.json
+++ b/messages/fr.json
@@ -222,6 +222,17 @@
"big": "Pour les grands",
"small": "Pour les petits"
}
+ },
+ "kitchen": {
+ "title": "Kitchen display",
+ "devicesHint": "Unlock a tablet or Echo Show in the kitchen: create a link and open it on the device. It shows recipes and the plan in large type and cannot change anything.",
+ "deviceLabel": "Name of the display",
+ "deviceLabelPlaceholder": "e.g. Kitchen Echo Show",
+ "unlockDevice": "Create unlock link",
+ "deviceActive": "unlocked",
+ "devicePending": "Link open, not yet unlocked",
+ "removeDevice": "Remove {label}",
+ "remove": "Remove"
}
},
"nav": {
@@ -297,7 +308,8 @@
"pieces": "{n, plural, one {piece} other {pieces}}",
"stepTimerProduct": "{n} min selon le paquet ({product})",
"photoAdd": "Ajouter une photo ({n} sur {max})",
- "photoFull": "5 photos au maximum"
+ "photoFull": "5 photos au maximum",
+ "present": "Present"
},
"form": {
"newTitle": "New dish",
@@ -884,5 +896,29 @@
"title": "Tu as ton mot à dire !",
"text": "Touche un plat que tu veux manger. Tes pièces montrent combien de souhaits il te reste."
}
+ },
+ "present": {
+ "close": "Close presentation",
+ "portions": "Portions",
+ "fewer": "One portion less",
+ "more": "One portion more",
+ "portionsN": "{n, plural, one {1 portion} other {# portions}}",
+ "ingredients": "Ingredients",
+ "steps": "Page through"
+ },
+ "kitchen": {
+ "eyebrow": "Kitchen display · {label}",
+ "next": "Up next",
+ "portions": "{n, plural, one {1 portion} other {# portions}}",
+ "portionsCook": "{n, plural, one {1 portion} other {# portions}} · {name} cooks",
+ "present": "Show recipe",
+ "later": "Later in the plan",
+ "nothingPlanned": "Nothing is planned right now. All recipes are below.",
+ "all": "All recipes",
+ "noDishes": "No dishes yet.",
+ "unlockTitle": "Unlock “{label}” as kitchen display",
+ "unlockText": "This device will then show the recipes and plan of {household} — large, for reading while cooking. Nothing can be changed here.",
+ "linkExpiredTitle": "Link expired",
+ "linkExpiredText": "This link is no longer valid. An admin can create a new one under “More” › “Kitchen display”."
}
}
diff --git a/olares/Chart.yaml b/olares/Chart.yaml
index 5cc49d6..00951b1 100644
--- a/olares/Chart.yaml
+++ b/olares/Chart.yaml
@@ -2,5 +2,5 @@ apiVersion: v2
name: lunch
description: Was gibt's? — die Familie entscheidet gemeinsam, was es gibt; aus dem Plan entsteht die Einkaufsliste
type: application
-version: 26.11.27 # YY.M. wie im AImighty-Markt — bei jeder Chart-Änderung erhöhen
-appVersion: "26.11.27" # MUSS gleich version sein: der Linter prüft es, und der Image-Tag hängt daran
+version: 26.11.28 # YY.M. wie im AImighty-Markt — bei jeder Chart-Änderung erhöhen
+appVersion: "26.11.28" # MUSS gleich version sein: der Linter prüft es, und der Image-Tag hängt daran
diff --git a/olares/OlaresManifest.yaml b/olares/OlaresManifest.yaml
index 5078931..8136c52 100644
--- a/olares/OlaresManifest.yaml
+++ b/olares/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.27
+ version: 26.11.28
categories:
- Applications
@@ -61,7 +61,7 @@ permission:
appData: true
spec:
- versionName: '26.11.27'
+ versionName: '26.11.28'
featuredImage: https://git.aimighty.olares.de/aimighty/bilder/raw/branch/main/lunch/icon.png
promoteImage:
diff --git a/olares/markt/26.11.28.md b/olares/markt/26.11.28.md
new file mode 100644
index 0000000..0c0f024
--- /dev/null
+++ b/olares/markt/26.11.28.md
@@ -0,0 +1,5 @@
+# Recipes on the kitchen display
+v26.11.28: Every recipe can now be presented: large type for reading from a distance, upright on the phone and side by side in landscape on a tablet or Echo Show. First the ingredients in the chosen number of portions, then step by step with the amounts for each step and timers. Tap the right of the screen for the next step and the left to go back, or swipe; the display stays on. An admin can unlock a kitchen display with a one-time link under "More": it shows what is up next in the plan and all recipes, and cannot change anything.
+
+## Deutsch
+v26.11.28: Jedes Rezept lässt sich jetzt präsentieren: große Schrift zum Ablesen aus Abstand, am Handy hochkant, auf Tablet oder Echo Show quer nebeneinander. Erst die Zutaten in der gewählten Portionszahl, dann Schritt für Schritt mit den Mengen für jeden Schritt und Timern. Rechts tippen blättert weiter, links zurück, Wischen geht auch; das Display bleibt an. Unter „Mehr“ schaltet ein Admin per Einmal-Link ein Küchendisplay frei: Es zeigt, was im Plan als Nächstes kommt, und alle Rezepte — und kann nichts ändern.
diff --git a/playwright.config.ts b/playwright.config.ts
index ab491bc..5819e00 100644
--- a/playwright.config.ts
+++ b/playwright.config.ts
@@ -63,10 +63,16 @@ export default defineConfig({
dependencies: ["einkauf"],
use: { ...iphone, storageState: "e2e/.auth/kai.json" },
},
+ {
+ name: "kueche",
+ testMatch: /kueche\.spec\.ts/,
+ dependencies: ["kochen"],
+ use: { ...iphone, storageState: "e2e/.auth/kai.json" },
+ },
{
name: "pwa",
testMatch: /pwa\.spec\.ts/,
- dependencies: ["kochen"],
+ dependencies: ["kueche"],
use: { ...iphone, storageState: "e2e/.auth/kai.json" },
},
{
diff --git a/tests/kitchen.test.ts b/tests/kitchen.test.ts
new file mode 100644
index 0000000..3248add
--- /dev/null
+++ b/tests/kitchen.test.ts
@@ -0,0 +1,59 @@
+import { randomUUID } from "node:crypto";
+import pg from "pg";
+import { afterAll, beforeAll, describe, expect, it, vi } from "vitest";
+import { seedHousehold } from "./fixture";
+
+vi.mock("server-only", () => ({}));
+vi.mock("next/headers", () => ({ cookies: async () => ({ get: () => undefined, has: () => false }) }));
+
+// lib/kitchen.ts: Was zeigt das Küchendisplay unter „Als Nächstes“? Die noch
+// nicht gekochten Gerichte der laufenden Runde in Reihenfolge — nichts, solange
+// die Runde noch gewünscht wird.
+const url = process.env.TEST_DATABASE_URL;
+
+describe.skipIf(!url)("kitchen display", () => {
+ const client = new pg.Client({ connectionString: url });
+ const h = randomUUID();
+ let roundId = "";
+ let kitchen: typeof import("@/lib/kitchen");
+ let db: typeof import("@/lib/db");
+ const as = (fn: (c: pg.PoolClient) => Promise) => db.withHousehold(h, fn);
+
+ beforeAll(async () => {
+ process.env.DATABASE_URL = url;
+ await client.connect();
+ const ingredient = (await client.query("select id from ingredients limit 1")).rows[0].id;
+ await seedHousehold(client, h, ingredient);
+ kitchen = await import("@/lib/kitchen");
+ db = await import("@/lib/db");
+ await as(async (c) => {
+ await c.query("update rounds set status = 'done'");
+ roundId = (await c.query("insert into rounds (household_id, slots_count, default_portions, status) values ($1, 3, 4, 'open') returning id", [h])).rows[0].id;
+ for (const [i, t] of ["Pizza", "Curry", "Suppe"].entries()) {
+ const d = (await c.query("insert into dishes (household_id, title) values ($1, $2) returning id", [h, t])).rows[0].id;
+ await c.query("insert into slots (household_id, round_id, position, dish_id, portions) values ($1, $2, $3, $4, $5)", [h, roundId, i + 1, d, 3 + i]);
+ }
+ });
+ });
+
+ afterAll(async () => {
+ await client.end();
+ await db.pool.end();
+ });
+
+ it("shows nothing while the round is still being wished", async () => {
+ expect(await as(kitchen.upcoming)).toEqual([]);
+ });
+
+ it("lists the uncooked dishes of a planned round in order, with their portions", async () => {
+ await as((c) => c.query("update rounds set status = 'shopping' where id = $1", [roundId]));
+ expect((await as(kitchen.upcoming)).map((d) => [d.title, d.portions])).toEqual([["Pizza", 3], ["Curry", 4], ["Suppe", 5]]);
+ await as((c) => c.query("update slots set cooked_at = now() where position = 1 and round_id = $1", [roundId]));
+ expect((await as(kitchen.upcoming)).map((d) => d.title)).toEqual(["Curry", "Suppe"]);
+ });
+
+ it("the overview carries every dish of the pool", async () => {
+ const { dishes } = await as(kitchen.kitchenOverview);
+ expect(dishes.map((d) => d.title)).toEqual(expect.arrayContaining(["Curry", "Pizza", "Suppe"]));
+ });
+});