Compare commits

...
1 Commits
Author SHA1 Message Date
kai c4ba00807b Guide new households and every round: getting started, where are we (26.11.27) (#28)
release / which version (push) Successful in 2s
release / olares chart · sanity (push) Successful in 4s
release / app (push) Successful in 1m5s
release / tag and release (push) Successful in 2s
2026-11-07 09:25:03 +00:00
24 changed files with 859 additions and 15 deletions

No files matched your search

+10 -1
View File
@@ -7,7 +7,7 @@
> **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.26 — alle neun Arbeitspakete aus `docs/PROJEKTSTART.md` sind gebaut:
> **Status:** 26.11.27 — 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
@@ -385,6 +385,15 @@ Vorlagen ersetzt. `tests/seed.test.ts` prüft die Dateien. Ein Haushalt
(Anzahl × Packung), nur wenn die Packung zur Einheit der Zutat passt), Status `done`,
**Foto gelöscht**. Migration 0016 (`store_name`, `error`, `attempts`, `match_source`).
## Führung (seit 26.11.27)
- `lib/onboarding.ts` (rein, getestet): `setupSteps` (Gerichte ≥ 5 → Laden → Familie →
erste Runde, alles aus den Daten), `checklistState`, `roundStage` und `nextAction`
(nächster Schritt je Rolle). „Heute“ zeigt „Los geht's“ nur Admins; sonst „Wo stehen wir?“.
- Gemerkt wird nur, was nicht aus den Daten folgt: `households.onboarding` (Familie
übersprungen, ausgeblendet, „Fertig“ gesehen) und `members.seen_intro` (Migration 0017).
- Tests auf „Heute“ greifen Inhaltskarten über `main article h2`, nicht die erste h2.
## Rollen
- `admin`, `member`, `teen` (seit 26.11.19), `child`, `guest`. Wer was darf, steht nur
+2 -2
View File
@@ -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.26
version: 26.11.27
categories:
- Applications
@@ -61,7 +61,7 @@ permission:
appData: true
spec:
versionName: '26.11.26'
versionName: '26.11.27'
featuredImage: https://git.aimighty.olares.de/aimighty/bilder/raw/branch/main/lunch/icon.png
promoteImage:
+3 -3
View File
@@ -13,9 +13,9 @@ import { withHousehold } from "@/lib/db";
import { isLocale } from "@/lib/locale";
// Abschnitte ohne Kasten: ein Etikett in Versalien, getrennt durch eine feine Linie.
function Section({ title, children }: { title: string; children: React.ReactNode }) {
function Section({ title, id, children }: { title: string; id?: string; children: React.ReactNode }) {
return (
<section className="flex flex-col gap-3 border-t border-border pt-5">
<section id={id} className="flex scroll-mt-4 flex-col gap-3 border-t border-border pt-5">
<h2 className="eyebrow">{title}</h2>
{children}
</section>
@@ -83,7 +83,7 @@ export default async function MorePage() {
) : null}
{session.role === "admin" ? (
<Section title={t("invitePerson")}>
<Section title={t("invitePerson")} id="einladen">
<InvitePerson />
</Section>
) : null}
+44 -1
View File
@@ -1,4 +1,8 @@
import { can, COOKS, PLANNERS } from "@/lib/auth/roles";
import { can, COOKS, PLANNERS, SHOPPERS } from "@/lib/auth/roles";
import { checklistState, nextAction, roundStage, setupSteps } from "@/lib/onboarding";
import { IntroCards } from "@/components/today/intro-cards";
import { RoundStepper } from "@/components/today/round-stepper";
import { SetupChecklist } from "@/components/today/setup-checklist";
import { ChefHat, CookingPot, Crown, Heart } from "lucide-react";
import { RateCard } from "@/components/cooking/rate-card";
import { InstallHint } from "@/components/install-hint";
@@ -41,6 +45,41 @@ export default async function TodayPage() {
});
const adult = can(PLANNERS, session.role);
const cook = can(COOKS, session.role);
// Führung: „Los geht's“ (Admins), „So funktioniert Lunch“ (einmal je Person), „Wo stehen wir?“ (alle).
const guide = await withHousehold(session.householdId, async (c) => {
const q = async (sql: string, p: unknown[] = []) => (await c.query(sql, p)).rows[0];
const facts = {
poolDishes: (await q("select count(*)::int as n from dishes where archived_at is null and not is_trial")).n as number,
hasStore: !!(await q("select 1 as x from stores where is_default")),
people: (await q("select count(*)::int as n from members where role <> 'guest'")).n as number,
openInvites: (await q("select count(*)::int as n from invitations where used_at is null and expires_at > now() and member_id is null")).n as number,
rounds: (await q("select count(*)::int as n from rounds")).n as number,
};
const ob = ((await q("select onboarding from households")).onboarding ?? {}) as { skipped?: string[]; hidden?: boolean; finishedSeen?: boolean };
const seenIntro = (await q("select seen_intro from members where id = $1", [session.memberId]))?.seen_intro !== false;
return { facts: { ...facts, skipped: ob.skipped ?? [] }, ob, seenIntro };
});
const steps = setupSteps(guide.facts);
const checklist = session.role === "admin" ? checklistState(steps, { hidden: !!guide.ob.hidden, finishedSeen: !!guide.ob.finishedSeen }) : "none";
const slotList = "slots" in data && data.slots ? data.slots : [];
const nextSlot = slotList.find((s) => !s.cookedAt);
// In der offenen Runde zählen die Slots des Vorschlags (Planen läuft), danach die freigegebenen.
const slotsInRound =
data.round?.status === "open"
? await withHousehold(session.householdId, async (c) => (await c.query("select count(*)::int as n from slots where round_id = $1", [data.round!.id])).rows[0].n as number)
: slotList.length;
const stageNow = roundStage({
status: data.round?.status ?? null,
slots: slotsInRound,
cooked: slotList.filter((s) => s.cookedAt).length,
toRate: after.toRate.length,
});
const next = nextAction(
stageNow,
{ planner: adult, shopper: can(SHOPPERS, session.role), cook, child: session.role === "child" },
{ tokensLeft: "budget" in data && data.budget ? data.budget.tokensLeft : 0, nextSlotId: nextSlot?.id ?? null, nextTitle: nextSlot?.title ?? null },
);
const day = data.round?.shoppingDate
? new Intl.DateTimeFormat(locale, { weekday: "long" }).format(new Date(`${data.round.shoppingDate}T12:00:00`))
: null;
@@ -52,6 +91,10 @@ export default async function TodayPage() {
<h1 className="text-4xl leading-tight">{t("greeting", { name: session.displayName })}</h1>
</header>
<InstallHint dismissible />
{!guide.seenIntro && checklist === "none" ? <IntroCards simple={session.role === "child"} /> : null}
{checklist !== "none" ? <SetupChecklist steps={steps} finished={checklist === "finished"} /> : null}
{checklist !== "show" ? <RoundStepper stage={stageNow} next={next} simple={session.role === "child"} /> : null}
<div id="bewerten" className="contents" />
{after.toRate.map((r) => (
<RateCard key={r.slotId} item={r} />
+27
View File
@@ -0,0 +1,27 @@
import { z } from "zod";
import { guardWrite, isResponse } from "@/lib/auth/guard";
import { fail, json, readJson } from "@/lib/auth/http";
import { withHousehold } from "@/lib/db";
export const dynamic = "force-dynamic";
// „Los geht's“: Familie überspringen, Liste ausblenden, „Fertig“ gesehen (nur Admins);
// „So funktioniert Lunch“ gesehen (jede Person für sich).
export async function POST(request: Request) {
const body = z.object({ action: z.enum(["skipFamily", "hide", "finished", "introSeen"]) }).safeParse(await readJson(request));
if (!body.success) return fail("invalid", 400);
const intro = body.data.action === "introSeen";
const session = await guardWrite(request, intro ? ["admin", "member", "teen", "child"] : ["admin"]);
if (isResponse(session)) return session;
await withHousehold(session.householdId, (c) => {
if (intro) return c.query("update members set seen_intro = true where id = $1", [session.memberId]);
const patch =
body.data.action === "skipFamily"
? `jsonb_set(onboarding, '{skipped}', coalesce(onboarding->'skipped', '[]'::jsonb) || '["family"]'::jsonb)`
: body.data.action === "hide"
? `onboarding || '{"hidden": true}'::jsonb`
: `onboarding || '{"finishedSeen": true}'::jsonb`;
return c.query(`update households set onboarding = ${patch} where id = $1`, [session.householdId]);
});
return json({ ok: true });
}
+56
View File
@@ -0,0 +1,56 @@
"use client";
import { CalendarDays, ChefHat, Coins } from "lucide-react";
import { useRouter } from "next/navigation";
import { useTranslations } from "next-intl";
import { useState } from "react";
import { Button } from "@/components/ui/button";
const CARDS = [
{ key: "wish", icon: Coins },
{ key: "plan", icon: CalendarDays },
{ key: "cook", icon: ChefHat },
] as const;
// „So funktioniert Lunch“: einmal für jede neue Person (Kinder: nur die erste Karte).
export function IntroCards({ simple = false }: { simple?: boolean }) {
const t = useTranslations("intro");
const router = useRouter();
const cards = simple ? CARDS.slice(0, 1) : CARDS;
const [i, setI] = useState(0);
const card = cards[i]!;
const Icon = card.icon;
const last = i === cards.length - 1;
async function done() {
await fetch("/api/onboarding", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ action: "introSeen" }) }).catch(() => null);
router.refresh();
}
return (
<section aria-labelledby="intro-title" aria-roledescription={t("roledesc")} className="flex flex-col gap-3 rounded-2xl bg-secondary p-5">
<p className="eyebrow">{t("eyebrow", { n: i + 1, of: cards.length })}</p>
<Icon aria-hidden className="size-10 text-accent" strokeWidth={1.5} />
<h2 id="intro-title" className="text-2xl leading-snug">
{t(`${simple ? "kid" : card.key}.title`)}
</h2>
<p>{t(`${simple ? "kid" : card.key}.text`)}</p>
<div className="flex gap-2">
{last ? (
<Button type="button" size="lg" className="flex-1" onClick={done}>
{t("done")}
</Button>
) : (
<>
<Button type="button" variant="ghost" onClick={done}>
{t("skip")}
</Button>
<Button type="button" size="lg" className="flex-1" onClick={() => setI(i + 1)}>
{t("next")}
</Button>
</>
)}
</div>
</section>
);
}
+49
View File
@@ -0,0 +1,49 @@
import Link from "next/link";
import { getTranslations } from "next-intl/server";
import { buttonVariants } from "@/components/ui/button";
import { STAGES, type NextAction, type Stage } from "@/lib/onboarding";
import { cn } from "@/lib/utils";
// „Wo stehen wir?“ (alle): die fünf Schritte einer Runde, der aktuelle markiert (Wort
// und Form, nicht nur Farbe), darunter der nächste Schritt für diese Person.
export async function RoundStepper({ stage, next, simple = false }: { stage: Stage | null; next: NextAction; simple?: boolean }) {
const t = await getTranslations("stage");
const at = stage ? STAGES.indexOf(stage) : -1;
return (
<section aria-labelledby="stage-title" className="flex flex-col gap-3">
<h2 id="stage-title" className="eyebrow">
{t("title")}
</h2>
{simple ? null : (
<ol className="grid grid-cols-5 gap-1" aria-label={t("steps")}>
{STAGES.map((s, i) => (
<li key={s} aria-current={i === at ? "step" : undefined} className="flex flex-col items-center gap-1 text-center">
<span
aria-hidden
className={cn(
"h-1.5 w-full rounded-full",
i < at ? "bg-accent/50" : i === at ? "bg-accent" : "bg-border",
)}
/>
<span className={cn("text-xs", i === at ? "font-semibold text-foreground" : "text-muted-foreground")}>
{t(`names.${s}`)}
{i === at ? <span className="sr-only"> ({t("current")})</span> : null}
</span>
</li>
))}
</ol>
)}
<div className="flex flex-wrap items-center justify-between gap-3 rounded-2xl border border-border p-4">
<p>
<span className="font-semibold">{t("now")} </span>
{t(`next.${next.key}`, next.values ?? {})}
</p>
{next.href ? (
<Link href={next.href} className={cn(buttonVariants({ variant: "outline" }))}>
{t(`cta.${next.key}`)}
</Link>
) : null}
</div>
</section>
);
}
+105
View File
@@ -0,0 +1,105 @@
"use client";
import { Check, ChevronRight } from "lucide-react";
import Link from "next/link";
import { useRouter } from "next/navigation";
import { useTranslations } from "next-intl";
import { useState } from "react";
import { Button, buttonVariants } from "@/components/ui/button";
import type { SetupStep } from "@/lib/onboarding";
import { cn } from "@/lib/utils";
const HREF: Record<SetupStep["key"], string> = { dishes: "/gerichte/vorlagen", store: "/einkauf", family: "/mehr#einladen", round: "/runde/neu" };
async function send(action: string) {
await fetch("/api/onboarding", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ action }) }).catch(() => null);
}
// „Los geht's“ (Admins): vier Schritte bis zum ersten Erfolg, aus den Daten abgehakt.
// Der erste offene ist groß, mit genau einem Knopf.
export function SetupChecklist({ steps, finished }: { steps: SetupStep[]; finished: boolean }) {
const t = useTranslations("setup");
const router = useRouter();
const [busy, setBusy] = useState(false);
const act = async (action: string) => {
setBusy(true);
await send(action);
setBusy(false);
router.refresh();
};
if (finished) {
return (
<section aria-labelledby="setup-title" className="flex flex-col gap-3 rounded-2xl bg-secondary p-5">
<h2 id="setup-title" className="text-2xl leading-snug">
{t("finishedTitle")}
</h2>
<p>{t("finishedText")}</p>
<Button type="button" variant="outline" disabled={busy} onClick={() => act("finished")}>
{t("finishedOk")}
</Button>
</section>
);
}
const current = steps.find((s) => !s.done)!;
const done = steps.filter((s) => s.done).length;
return (
<section aria-labelledby="setup-title" className="flex flex-col gap-4 rounded-2xl bg-secondary p-5">
<div className="flex items-baseline justify-between gap-3">
<h2 id="setup-title" className="eyebrow">
{t("title")}
</h2>
<span className="text-sm text-muted-foreground">{t("progress", { n: done, of: steps.length })}</span>
</div>
<div className="flex flex-col gap-2">
<p className="text-2xl leading-snug">{t(`${current.key}.title`)}</p>
<p className="text-muted-foreground">
{t(`${current.key}.text`, { n: current.n ?? 0, of: current.of ?? 0 })}
</p>
<Link href={HREF[current.key]} className={cn(buttonVariants({ size: "lg" }), "mt-1")}>
{t(`${current.key}.cta`)}
</Link>
{current.key === "dishes" ? (
<Link href="/gerichte/hinzufuegen" className={cn(buttonVariants({ variant: "outline" }))}>
{t("dishes.moreLink")}
</Link>
) : null}
{current.key === "family" ? (
<Button type="button" variant="ghost" className="self-start" disabled={busy} onClick={() => act("skipFamily")}>
{t("family.skip")}
</Button>
) : null}
</div>
<ol className="flex flex-col divide-y divide-border border-t border-border">
{steps.map((s, i) => (
<li key={s.key} className="flex min-h-11 items-center gap-3 py-2">
<span
aria-hidden
className={cn(
"flex size-7 shrink-0 items-center justify-center rounded-full border-2 text-sm font-semibold",
s.done ? "border-accent bg-accent text-background" : s === current ? "border-accent text-accent" : "border-border text-muted-foreground",
)}
>
{s.done ? <Check className="size-4" /> : i + 1}
</span>
<span className={cn("flex-1", s.done && "text-muted-foreground line-through")}>
<span className="sr-only">{s.done ? t("doneSr") : s === current ? t("nowSr") : t("laterSr")} </span>
{t(`${s.key}.short`)}
{s.key === "dishes" && !s.done ? ` · ${s.n} / ${s.of}` : ""}
{s.skipped ? ` · ${t("skipped")}` : ""}
</span>
{!s.done && s !== current ? (
<Link href={HREF[s.key]} aria-label={t(`${s.key}.short`)} className="flex size-11 items-center justify-center text-muted-foreground">
<ChevronRight aria-hidden className="size-5" />
</Link>
) : null}
</li>
))}
</ol>
<Button type="button" variant="ghost" className="self-start text-sm" disabled={busy} onClick={() => act("hide")}>
{t("hide")}
</Button>
</section>
);
}
+6
View File
@@ -0,0 +1,6 @@
-- Führung (Kai, 7.11.2026): „Los geht's“ merkt sich nur, was sich nicht aus den
-- Daten ergibt — Familie übersprungen, Liste ausgeblendet, „Fertig“ gesehen.
-- „So funktioniert Lunch“ sieht jede Person einmal; wer schon da ist, hat es nicht nötig.
alter table households add column onboarding jsonb not null default '{}';
alter table members add column seen_intro boolean not null default false;
update members set seen_intro = true;
+14
View File
@@ -40,6 +40,11 @@ test("setup with the code and a passkey opens Today", async () => {
await kai.page.getByRole("button", { name: "Passkey anlegen und loslegen" }).click();
await expect(kai.page).toHaveURL(/\/$/);
await expect(kai.page.getByRole("heading", { level: 1 })).toHaveText("Hallo Kai");
// „Los geht's“: was zuerst zu tun ist, mit genau einem Knopf.
const setup = kai.page.locator("section", { has: kai.page.getByRole("heading", { name: "Los geht's" }) });
await expect(setup).toContainText("0 von 4");
await expect(setup).toContainText("Füll den Pool mit fünf Gerichten");
await expect(setup.getByRole("link", { name: "Klassiker übernehmen" })).toHaveAttribute("href", "/gerichte/vorlagen");
expect(existsSync(path.join(DATA, "lunch-einrichten.txt"))).toBe(false);
});
@@ -62,6 +67,15 @@ test("an admin invites a member by a single-use link", async ({ browser }) => {
await expect(maike.page.locator("#name")).toHaveValue("Maike");
await maike.page.getByRole("button", { name: "Passkey anlegen" }).click();
await expect(maike.page).toHaveURL(/\/$/);
// Neue Person: einmal „So funktioniert Lunch“, danach „Wo stehen wir?“.
await expect(maike.page.getByText("So funktioniert Lunch · 1 von 3")).toBeVisible();
await maike.page.getByRole("button", { name: "Weiter" }).click();
await maike.page.getByRole("button", { name: "Weiter" }).click();
await maike.page.getByRole("button", { name: "Los geht's" }).click();
await expect(maike.page.getByText(/So funktioniert Lunch/)).toHaveCount(0);
await maike.page.reload();
await expect(maike.page.getByText(/So funktioniert Lunch/)).toHaveCount(0);
await expect(maike.page.getByText("Eine neue Runde eröffnen.")).toBeVisible(); // Mitglieder dürfen eröffnen
await maike.page.goto("/mehr");
await expect(maike.page.locator("#invite-name")).toHaveCount(0);
await expect(maike.page.locator("main")).toContainText("Kai");
+3
View File
@@ -22,6 +22,9 @@ test("adopting three classics fills the pool", async ({ page }) => {
await expect(page.locator("main li")).toHaveCount(3);
await page.goto("/gerichte/vorlagen");
await expect(page.getByRole("button", { name: /Linseneintopf/ })).toBeDisabled();
// „Los geht's“ zählt mit.
await page.goto("/");
await expect(page.getByText("Erste Gerichte · 3 / 5")).toBeVisible();
});
test("a dish scales its ingredients with the portions", async ({ page }) => {
+4
View File
@@ -118,6 +118,10 @@ test("a teen joins with an own passkey and wishes, but does not plan", async ({
await lena.goto(link);
await lena.getByRole("button", { name: "Passkey anlegen" }).click();
await expect(lena.getByRole("heading", { level: 1 })).toHaveText("Hallo Lena");
await lena.getByRole("button", { name: "Überspringen" }).click();
// „Wo stehen wir?“: die Runde ist beim Wünschen, und Lena hat noch Jetons.
await expect(lena.locator('[aria-current="step"]')).toContainText("Wünschen");
await expect(lena.getByText("Du hast noch 2 Wünsche.")).toBeVisible();
const nav = lena.getByRole("navigation", { name: "Navigation" });
await expect(nav.getByRole("link")).toHaveText(["Heute", "Wünschen", "Einkauf", "Gerichte", "Mehr"]);
for (const path of ["/plan", "/runde/neu"]) {
+1 -1
View File
@@ -7,7 +7,7 @@ test.describe.configure({ mode: "serial" });
test("cooking mode: mise en place, steps by key, timer from the step text, done", async ({ page }) => {
await page.clock.install();
await page.goto("/");
await expect(page.getByRole("heading", { level: 2 }).first()).toHaveText("Spaghetti Bolognese");
await expect(page.locator("main article h2").first()).toHaveText("Spaghetti Bolognese");
await page.getByRole("link", { name: "Kochen" }).click();
await expect(page.getByRole("heading", { level: 1 })).toHaveText("Spaghetti Bolognese");
await expect(page.getByText(/Alles bereit\? · \d+ Portionen/)).toBeVisible();
+1 -1
View File
@@ -99,7 +99,7 @@ test("approving shows the plan on Today and closes wishing", async ({ page }) =>
await expect(page.getByRole("button", { name: "Plan freigeben" })).toHaveCount(0);
await page.goto("/");
await expect(page.getByText("Als Nächstes")).toBeVisible();
await expect(page.getByRole("heading", { level: 2 }).first()).toHaveText(first);
await expect(page.locator("main article h2").first()).toHaveText(first);
await expect(page.locator("section", { hasText: "Der Plan" }).locator("li")).toHaveCount(3);
await page.goto("/wuenschen");
await expect(page.getByText("Die Wünsche für diese Runde sind abgeschlossen.")).toBeVisible();
+2 -2
View File
@@ -12,7 +12,7 @@ test("Today offers to open a round, and the round opens", async ({ page }) => {
await page.getByRole("button", { name: "Warme Mahlzeiten: weniger" }).click();
await expect(page.locator("#slots")).toHaveText("4");
await page.getByRole("button", { name: "Runde eröffnen" }).click();
await expect(page.getByRole("heading", { level: 2 }).first()).toHaveText("Du hast noch 2 Wünsche für den Einkauf am Samstag.");
await expect(page.locator("main article h2").first()).toHaveText("Du hast noch 2 Wünsche für den Einkauf am Samstag.");
});
test("each tap spends a token, and the server says when they are gone", async ({ page }) => {
@@ -71,7 +71,7 @@ test("taking a wish back frees a token for the joker", async ({ page }) => {
test("Today shows the family's wishes", async ({ page }) => {
await page.goto("/");
await expect(page.getByRole("heading", { level: 2 }).first()).toHaveText("Deine Wünsche für Samstag sind abgegeben.");
await expect(page.locator("main article h2").first()).toHaveText("Deine Wünsche für Samstag sind abgegeben.");
const list = page.locator("section", { hasText: "Wünsche der Familie" });
await expect(list.getByText("Spaghetti Bolognese")).toBeVisible();
await expect(list.locator("li")).toHaveCount(3); // dazu der Gegenvorschlag zum Veto
+81
View File
@@ -0,0 +1,81 @@
// Führung durch die App (Kai, 7.11.2026: „Man weiß nicht, was man zuerst machen muss“).
// Rein, ohne Datenbank: Die Seite „Heute“ sammelt die Fakten, hier wird entschieden.
// 1. „Los geht's“ (Admins): Gerichte → Laden → Familie → erste Runde, aus den Daten abgehakt.
// 2. „Wo stehen wir?“ (alle): Wünschen → Planen → Einkaufen → Kochen → Bewerten.
export const POOL_GOAL = 5;
export type SetupFacts = {
poolDishes: number;
hasStore: boolean;
people: number; // ohne Gäste, mit mir
openInvites: number;
rounds: number; // je eröffnete Runden
skipped: string[]; // households.onboarding.skipped
};
export type SetupKey = "dishes" | "store" | "family" | "round";
export type SetupStep = { key: SetupKey; done: boolean; skipped?: boolean; n?: number; of?: number };
export function setupSteps(f: SetupFacts): SetupStep[] {
const familySkipped = f.skipped.includes("family");
return [
{ key: "dishes", done: f.poolDishes >= POOL_GOAL, n: Math.min(f.poolDishes, POOL_GOAL), of: POOL_GOAL },
{ key: "store", done: f.hasStore },
{ key: "family", done: f.people >= 2 || f.openInvites > 0 || familySkipped, skipped: familySkipped && f.people < 2 && f.openInvites === 0 },
{ key: "round", done: f.rounds > 0 },
];
}
/** Liste zeigen, einmal „Fertig“ zeigen, oder gar nicht (ausgeblendet oder schon bestätigt). */
export function checklistState(steps: SetupStep[], flags: { hidden: boolean; finishedSeen: boolean }): "show" | "finished" | "none" {
if (flags.hidden) return "none";
if (steps.every((s) => s.done)) return flags.finishedSeen ? "none" : "finished";
return "show";
}
export const STAGES = ["wish", "plan", "shop", "cook", "rate"] as const;
export type Stage = (typeof STAGES)[number];
export type RoundFacts = {
status: "open" | "planned" | "shopping" | "done" | null; // null: keine laufende Runde
slots: number;
cooked: number;
toRate: number; // offene Bewertungen dieser Person
};
/** Wo die Runde steht. Offene Bewertungen gehen vor; ohne Runde und ohne Bewertung: null. */
export function roundStage(f: RoundFacts): Stage | null {
if (f.toRate > 0 && (f.status === null || f.status === "done" || f.cooked > 0)) return "rate";
if (f.status === null || f.status === "done") return null;
if (f.status === "open") return f.slots > 0 ? "plan" : "wish";
if (f.cooked > 0 && f.cooked < f.slots) return "cook";
if (f.status === "shopping" && f.cooked === 0) return "shop";
return f.status === "planned" ? "shop" : "cook";
}
export type NextAction = { key: string; href: string | null; values?: Record<string, string | number> };
/** Der nächste Schritt *für diese Person*, je nach Rolle. */
export function nextAction(
stage: Stage | null,
who: { planner: boolean; shopper: boolean; cook: boolean; child: boolean },
extra: { tokensLeft: number; nextSlotId: string | null; nextTitle: string | null },
): NextAction {
switch (stage) {
case null:
return who.planner ? { key: "openRound", href: "/runde/neu" } : { key: "waitRound", href: null };
case "wish":
if (extra.tokensLeft > 0) return { key: "wish", href: "/wuenschen", values: { n: extra.tokensLeft } };
return who.planner ? { key: "makePlan", href: "/plan" } : { key: "wishedWait", href: null };
case "plan":
return who.planner ? { key: "approvePlan", href: "/plan" } : { key: "planComing", href: null };
case "shop":
return who.shopper ? { key: "shop", href: "/einkauf" } : { key: "shopping", href: null };
case "cook":
if (who.cook && extra.nextSlotId) return { key: "cook", href: `/kochen/${extra.nextSlotId}`, values: { title: extra.nextTitle ?? "" } };
return { key: "cookingSoon", href: null, values: { title: extra.nextTitle ?? "" } };
case "rate":
return { key: "rate", href: "#bewerten" };
}
}
+97
View File
@@ -787,5 +787,102 @@
"saveError": "Das hat nicht geklappt.",
"doneText": "Die Preise sind im Preisgedächtnis, die Zuordnungen gelernt. Das Foto ist gelöscht.",
"link": "Bon fotografieren"
},
"setup": {
"title": "Los geht's",
"progress": "{n} von {of}",
"doneSr": "erledigt:",
"nowSr": "jetzt:",
"laterSr": "später:",
"skipped": "übersprungen",
"hide": "Liste ausblenden",
"finishedTitle": "Fertig – Lunch läuft",
"finishedText": "Gerichte, Laden, Familie und die erste Runde stehen. Ab jetzt zeigt dir „Wo stehen wir?“, was dran ist.",
"finishedOk": "Alles klar",
"dishes": {
"short": "Erste Gerichte",
"title": "Füll den Pool mit fünf Gerichten",
"text": "Damit es etwas zu wünschen gibt. Am schnellsten: Klassiker mit einem Tipp übernehmen. Gerade sind es {n} von {of}.",
"cta": "Klassiker übernehmen",
"moreLink": "Eigene: Link, Kochbuchfoto, einsprechen"
},
"store": {
"short": "Hauptladen",
"title": "Wo kauft ihr meistens ein?",
"text": "Die Einkaufsliste sortiert sich dann nach den Gängen dieses Ladens.",
"cta": "Laden wählen"
},
"family": {
"short": "Familie",
"title": "Hol die Familie dazu",
"text": "Erwachsene und Jugendliche per Link aufs eigene Handy, Kinder mit Bild und PIN auf einem Tablet.",
"cta": "Einladen",
"skip": "Ich nutze Lunch erst mal allein"
},
"round": {
"short": "Erste Runde",
"title": "Eröffne die erste Runde",
"text": "Einkaufstag und Anzahl Mahlzeiten wählen — dann wünschen alle, und du machst daraus den Plan.",
"cta": "Runde eröffnen"
}
},
"stage": {
"title": "Wo stehen wir?",
"steps": "Schritte der Runde",
"current": "aktueller Schritt",
"now": "Jetzt:",
"names": {
"wish": "Wünschen",
"plan": "Planen",
"shop": "Einkaufen",
"cook": "Kochen",
"rate": "Bewerten"
},
"next": {
"openRound": "Eine neue Runde eröffnen.",
"waitRound": "Die nächste Runde ist noch nicht eröffnet.",
"wish": "Du hast noch {n, plural, one {# Wunsch} other {# Wünsche}}.",
"makePlan": "Alle Wünsche da? Dann mach den Plan.",
"wishedWait": "Deine Wünsche sind abgegeben — der Plan kommt.",
"approvePlan": "Plan prüfen und freigeben.",
"planComing": "Der Plan wird gerade gemacht.",
"shop": "Einkaufen nach der Liste.",
"shopping": "Es wird eingekauft.",
"cook": "Als Nächstes: {title}.",
"cookingSoon": "Als Nächstes gibt's {title}.",
"rate": "Sag, wie es geschmeckt hat."
},
"cta": {
"openRound": "Runde eröffnen",
"wish": "Wünschen",
"makePlan": "Zum Plan",
"approvePlan": "Zum Plan",
"shop": "Zur Liste",
"cook": "Kochen",
"rate": "Bewerten"
}
},
"intro": {
"roledesc": "Einführung",
"eyebrow": "So funktioniert Lunch · {n} von {of}",
"next": "Weiter",
"skip": "Überspringen",
"done": "Los geht's",
"wish": {
"title": "Du wünschst dir, was es gibt",
"text": "Je Runde hast du Jetons: ein Tipp auf ein Gericht ist ein Wunsch. Mit einem Veto lehnst du etwas ab – aber nur mit einem Gegenvorschlag."
},
"plan": {
"title": "Daraus wird der Plan",
"text": "Aus allen Wünschen macht die App einen Vorschlag, die Planerin rückt ihn zurecht und gibt ihn frei. Dann steht die Einkaufsliste."
},
"cook": {
"title": "Einkaufen, kochen, bewerten",
"text": "Die Liste ist nach Gängen sortiert und auf allen Handys gleich. Im Kochmodus gibt's Schritte mit Timern, danach Daumen hoch oder runter."
},
"kid": {
"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."
}
}
}
+97
View File
@@ -787,5 +787,102 @@
"saveError": "That didn't work.",
"doneText": "Prices are in the price memory and the matches are learned. The photo is deleted.",
"link": "Photograph receipt"
},
"setup": {
"title": "Getting started",
"progress": "{n} of {of}",
"doneSr": "done:",
"nowSr": "now:",
"laterSr": "later:",
"skipped": "skipped",
"hide": "Hide list",
"finishedTitle": "Done – Lunch is running",
"finishedText": "Dishes, store, family and the first round are set. From now on, “Where are we?” shows what's next.",
"finishedOk": "Got it",
"dishes": {
"short": "First dishes",
"title": "Fill the pool with five dishes",
"text": "So there is something to wish for. Quickest: adopt classics with one tap. Right now: {n} of {of}.",
"cta": "Adopt classics",
"moreLink": "Your own: link, cookbook photo, speak it"
},
"store": {
"short": "Main store",
"title": "Where do you usually shop?",
"text": "The shopping list then follows that store's aisles.",
"cta": "Choose store"
},
"family": {
"short": "Family",
"title": "Bring the family in",
"text": "Adults and teens via a link on their own phone, children with picture and PIN on a tablet.",
"cta": "Invite",
"skip": "I'll use Lunch on my own for now"
},
"round": {
"short": "First round",
"title": "Open the first round",
"text": "Choose shopping day and number of meals — then everyone wishes and you turn it into the plan.",
"cta": "Open round"
}
},
"stage": {
"title": "Where are we?",
"steps": "Steps of the round",
"current": "current step",
"now": "Now:",
"names": {
"wish": "Wish",
"plan": "Plan",
"shop": "Shop",
"cook": "Cook",
"rate": "Rate"
},
"next": {
"openRound": "Open a new round.",
"waitRound": "The next round isn't open yet.",
"wish": "You have {n, plural, one {# wish} other {# wishes}} left.",
"makePlan": "All wishes in? Then make the plan.",
"wishedWait": "Your wishes are in — the plan is coming.",
"approvePlan": "Check and approve the plan.",
"planComing": "The plan is being made.",
"shop": "Shop from the list.",
"shopping": "Shopping is underway.",
"cook": "Next up: {title}.",
"cookingSoon": "Next up: {title}.",
"rate": "Say how it tasted."
},
"cta": {
"openRound": "Open round",
"wish": "Wish",
"makePlan": "To the plan",
"approvePlan": "To the plan",
"shop": "To the list",
"cook": "Cook",
"rate": "Rate"
}
},
"intro": {
"roledesc": "Introduction",
"eyebrow": "How Lunch works · {n} of {of}",
"next": "Next",
"skip": "Skip",
"done": "Let's go",
"wish": {
"title": "You wish for what's for dinner",
"text": "Each round you get tokens: a tap on a dish is a wish. A veto turns something down – but only with a counter-suggestion."
},
"plan": {
"title": "Wishes become the plan",
"text": "The app turns all wishes into a suggestion, the planner adjusts and approves it. Then the shopping list is ready."
},
"cook": {
"title": "Shop, cook, rate",
"text": "The list follows the aisles and is the same on every phone. Cooking mode has steps with timers, then thumbs up or down."
},
"kid": {
"title": "You get a say!",
"text": "Tap a dish you'd like to eat. Your coins show how many wishes you have left."
}
}
}
+97
View File
@@ -787,5 +787,102 @@
"saveError": "No ha funcionado.",
"doneText": "Los precios están guardados y las asignaciones aprendidas. La foto se ha borrado.",
"link": "Fotografiar ticket"
},
"setup": {
"title": "Primeros pasos",
"progress": "{n} de {of}",
"doneSr": "hecho:",
"nowSr": "ahora:",
"laterSr": "después:",
"skipped": "omitido",
"hide": "Ocultar lista",
"finishedTitle": "Listo – Lunch está en marcha",
"finishedText": "Platos, tienda, familia y la primera ronda están listos. Desde ahora, «¿Dónde estamos?» muestra lo siguiente.",
"finishedOk": "Entendido",
"dishes": {
"short": "Primeros platos",
"title": "Llena el pool con cinco platos",
"text": "Para que haya algo que desear. Lo más rápido: adoptar clásicos con un toque. Ahora mismo: {n} de {of}.",
"cta": "Adoptar clásicos",
"moreLink": "Los tuyos: enlace, foto, dictar"
},
"store": {
"short": "Tienda principal",
"title": "¿Dónde compráis normalmente?",
"text": "La lista seguirá los pasillos de esa tienda.",
"cta": "Elegir tienda"
},
"family": {
"short": "Familia",
"title": "Trae a la familia",
"text": "Adultos y adolescentes con un enlace en su móvil, niños con imagen y PIN en una tablet.",
"cta": "Invitar",
"skip": "De momento uso Lunch solo"
},
"round": {
"short": "Primera ronda",
"title": "Abre la primera ronda",
"text": "Elige día de compra y número de comidas — todos desean y tú haces el plan.",
"cta": "Abrir ronda"
}
},
"stage": {
"title": "¿Dónde estamos?",
"steps": "Pasos de la ronda",
"current": "paso actual",
"now": "Ahora:",
"names": {
"wish": "Desear",
"plan": "Planificar",
"shop": "Comprar",
"cook": "Cocinar",
"rate": "Valorar"
},
"next": {
"openRound": "Abrir una nueva ronda.",
"waitRound": "La próxima ronda aún no está abierta.",
"wish": "Te quedan {n, plural, one {# deseo} other {# deseos}}.",
"makePlan": "¿Están todos los deseos? Haz el plan.",
"wishedWait": "Tus deseos están hechos — llega el plan.",
"approvePlan": "Revisar y aprobar el plan.",
"planComing": "Se está haciendo el plan.",
"shop": "Comprar con la lista.",
"shopping": "Se está comprando.",
"cook": "Lo siguiente: {title}.",
"cookingSoon": "Lo siguiente: {title}.",
"rate": "Di qué tal estaba."
},
"cta": {
"openRound": "Abrir ronda",
"wish": "Desear",
"makePlan": "Al plan",
"approvePlan": "Al plan",
"shop": "A la lista",
"cook": "Cocinar",
"rate": "Valorar"
}
},
"intro": {
"roledesc": "Introducción",
"eyebrow": "Así funciona Lunch · {n} de {of}",
"next": "Siguiente",
"skip": "Omitir",
"done": "Vamos",
"wish": {
"title": "Tú deseas lo que se come",
"text": "En cada ronda tienes fichas: un toque en un plato es un deseo. Un veto rechaza algo – pero solo con una contrapropuesta."
},
"plan": {
"title": "Los deseos se vuelven plan",
"text": "La app hace una propuesta con todos los deseos, quien planifica la ajusta y la aprueba. Y la lista de la compra está lista."
},
"cook": {
"title": "Comprar, cocinar, valorar",
"text": "La lista sigue los pasillos y es igual en todos los móviles. El modo cocina tiene pasos con temporizadores; luego pulgar arriba o abajo."
},
"kid": {
"title": "¡Tú también decides!",
"text": "Toca un plato que quieras comer. Tus monedas muestran cuántos deseos te quedan."
}
}
}
+97
View File
@@ -787,5 +787,102 @@
"saveError": "Ça n'a pas marché.",
"doneText": "Les prix sont mémorisés et les associations apprises. La photo est supprimée.",
"link": "Photographier le ticket"
},
"setup": {
"title": "C'est parti",
"progress": "{n} sur {of}",
"doneSr": "fait :",
"nowSr": "maintenant :",
"laterSr": "plus tard :",
"skipped": "ignoré",
"hide": "Masquer la liste",
"finishedTitle": "Terminé – Lunch tourne",
"finishedText": "Plats, magasin, famille et première tournée sont prêts. Désormais, « Où en est-on ? » montre la suite.",
"finishedOk": "Compris",
"dishes": {
"short": "Premiers plats",
"title": "Remplis le pool avec cinq plats",
"text": "Pour qu'il y ait de quoi souhaiter. Le plus rapide : reprendre des classiques d'un geste. Pour l'instant : {n} sur {of}.",
"cta": "Reprendre des classiques",
"moreLink": "Les tiens : lien, photo, dicter"
},
"store": {
"short": "Magasin principal",
"title": "Où faites-vous vos courses ?",
"text": "La liste suit alors les rayons de ce magasin.",
"cta": "Choisir le magasin"
},
"family": {
"short": "Famille",
"title": "Fais venir la famille",
"text": "Adultes et ados par lien sur leur téléphone, enfants avec image et PIN sur une tablette.",
"cta": "Inviter",
"skip": "J'utilise Lunch seul pour l'instant"
},
"round": {
"short": "Première tournée",
"title": "Ouvre la première tournée",
"text": "Choisis le jour des courses et le nombre de repas — chacun souhaite, puis tu en fais le plan.",
"cta": "Ouvrir la tournée"
}
},
"stage": {
"title": "Où en est-on ?",
"steps": "Étapes de la tournée",
"current": "étape actuelle",
"now": "Maintenant :",
"names": {
"wish": "Souhaiter",
"plan": "Planifier",
"shop": "Courses",
"cook": "Cuisiner",
"rate": "Noter"
},
"next": {
"openRound": "Ouvrir une nouvelle tournée.",
"waitRound": "La prochaine tournée n'est pas encore ouverte.",
"wish": "Il te reste {n, plural, one {# souhait} other {# souhaits}}.",
"makePlan": "Tous les souhaits sont là ? Fais le plan.",
"wishedWait": "Tes souhaits sont faits — le plan arrive.",
"approvePlan": "Vérifier et valider le plan.",
"planComing": "Le plan est en préparation.",
"shop": "Faire les courses avec la liste.",
"shopping": "Les courses sont en cours.",
"cook": "Ensuite : {title}.",
"cookingSoon": "Ensuite : {title}.",
"rate": "Dis comment c'était."
},
"cta": {
"openRound": "Ouvrir",
"wish": "Souhaiter",
"makePlan": "Au plan",
"approvePlan": "Au plan",
"shop": "À la liste",
"cook": "Cuisiner",
"rate": "Noter"
}
},
"intro": {
"roledesc": "Introduction",
"eyebrow": "Comment marche Lunch · {n} sur {of}",
"next": "Suivant",
"skip": "Passer",
"done": "C'est parti",
"wish": {
"title": "Tu souhaites ce qu'on mange",
"text": "À chaque tournée tu as des jetons : un geste sur un plat est un souhait. Un veto refuse un plat – mais seulement avec une contre-proposition."
},
"plan": {
"title": "Les souhaits deviennent le plan",
"text": "L'app fait une proposition à partir des souhaits, la personne qui planifie l'ajuste et la valide. La liste de courses est prête."
},
"cook": {
"title": "Courses, cuisine, avis",
"text": "La liste suit les rayons et est la même sur tous les téléphones. Le mode cuisine a des étapes avec minuteurs, puis pouce en haut ou en bas."
},
"kid": {
"title": "Tu as ton mot à dire !",
"text": "Touche un plat que tu veux manger. Tes pièces montrent combien de souhaits il te reste."
}
}
}
+2 -2
View File
@@ -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.26 # YY.M.<n> wie im AImighty-Markt — bei jeder Chart-Änderung erhöhen
appVersion: "26.11.26" # MUSS gleich version sein: der Linter prüft es, und der Image-Tag hängt daran
version: 26.11.27 # YY.M.<n> 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
+2 -2
View File
@@ -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.26
version: 26.11.27
categories:
- Applications
@@ -61,7 +61,7 @@ permission:
appData: true
spec:
versionName: '26.11.26'
versionName: '26.11.27'
featuredImage: https://git.aimighty.olares.de/aimighty/bilder/raw/branch/main/lunch/icon.png
promoteImage:
+5
View File
@@ -0,0 +1,5 @@
# Getting started, step by step
v26.11.27: Lunch now shows what to do next. After setup, "Getting started" on Today walks the admin through four steps — five dishes in the pool (classics with one tap), main store, family, first round — and ticks them off by itself; the current step is large with a single button. Every round then shows "Where are we?": wish → plan → shop → cook → rate, with the next step for each person. New members see three short cards on how Lunch works once.
## Deutsch
v26.11.27: Lunch zeigt jetzt, was als Nächstes zu tun ist. Nach der Einrichtung führt „Los geht's“ auf Heute in vier Schritten — fünf Gerichte im Pool (Klassiker mit einem Tipp), Hauptladen, Familie, erste Runde — und hakt sie von selbst ab; der aktuelle Schritt ist groß und hat genau einen Knopf. Danach zeigt jede Runde „Wo stehen wir?“: Wünschen → Planen → Einkaufen → Kochen → Bewerten, mit dem nächsten Schritt für jede Person. Neue Mitglieder sehen einmal drei kurze Karten „So funktioniert Lunch“.
+54
View File
@@ -0,0 +1,54 @@
import { describe, expect, it } from "vitest";
import { checklistState, nextAction, roundStage, setupSteps } from "@/lib/onboarding";
const fresh = { poolDishes: 0, hasStore: false, people: 1, openInvites: 0, rounds: 0, skipped: [] };
describe("getting started", () => {
it("ticks steps off from the data, in Kai's order", () => {
expect(setupSteps(fresh).map((s) => [s.key, s.done])).toEqual([
["dishes", false],
["store", false],
["family", false],
["round", false],
]);
const s = setupSteps({ ...fresh, poolDishes: 3, hasStore: true, openInvites: 1 });
expect(s[0]).toMatchObject({ done: false, n: 3, of: 5 });
expect(s[1]!.done && s[2]!.done).toBe(true);
expect(setupSteps({ ...fresh, skipped: ["family"] })[2]).toMatchObject({ done: true, skipped: true });
});
it("shows the list, then 'finished' once, then nothing", () => {
const all = setupSteps({ poolDishes: 7, hasStore: true, people: 3, openInvites: 0, rounds: 1, skipped: [] });
expect(checklistState(setupSteps(fresh), { hidden: false, finishedSeen: false })).toBe("show");
expect(checklistState(all, { hidden: false, finishedSeen: false })).toBe("finished");
expect(checklistState(all, { hidden: false, finishedSeen: true })).toBe("none");
expect(checklistState(setupSteps(fresh), { hidden: true, finishedSeen: false })).toBe("none");
});
});
describe("where the round stands", () => {
const r = (status: "open" | "planned" | "shopping" | "done" | null, slots = 0, cooked = 0, toRate = 0) => roundStage({ status, slots, cooked, toRate });
it("follows the round from wishing to rating", () => {
expect(r(null)).toBeNull();
expect(r("open")).toBe("wish");
expect(r("open", 4)).toBe("plan");
expect(r("planned", 4)).toBe("shop");
expect(r("shopping", 4)).toBe("shop");
expect(r("shopping", 4, 1)).toBe("cook");
expect(r("shopping", 4, 1, 1)).toBe("rate");
expect(r(null, 0, 0, 2)).toBe("rate");
});
it("says what is next for each person", () => {
const adult = { planner: true, shopper: true, cook: true, child: false };
const child = { planner: false, shopper: false, cook: false, child: true };
const extra = { tokensLeft: 2, nextSlotId: "s1", nextTitle: "Curry" };
expect(nextAction(null, adult, extra)).toMatchObject({ key: "openRound", href: "/runde/neu" });
expect(nextAction(null, child, extra)).toMatchObject({ key: "waitRound", href: null });
expect(nextAction("wish", child, extra)).toMatchObject({ key: "wish", values: { n: 2 } });
expect(nextAction("wish", adult, { ...extra, tokensLeft: 0 })).toMatchObject({ key: "makePlan" });
expect(nextAction("plan", child, extra)).toMatchObject({ key: "planComing", href: null });
expect(nextAction("cook", adult, extra)).toMatchObject({ key: "cook", href: "/kochen/s1", values: { title: "Curry" } });
expect(nextAction("shop", child, extra)).toMatchObject({ key: "shopping", href: null });
});
});