diff --git a/CLAUDE.md b/CLAUDE.md index cfb1770..dedb75c 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -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 diff --git a/OlaresManifest.yaml b/OlaresManifest.yaml index 3ba72f7..5078931 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.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: diff --git a/app/(app)/mehr/page.tsx b/app/(app)/mehr/page.tsx index 936e8c4..7044f57 100644 --- a/app/(app)/mehr/page.tsx +++ b/app/(app)/mehr/page.tsx @@ -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 ( -
+

{title}

{children}
@@ -83,7 +83,7 @@ export default async function MorePage() { ) : null} {session.role === "admin" ? ( -
+
) : null} diff --git a/app/(app)/page.tsx b/app/(app)/page.tsx index 314db73..d45e3e5 100644 --- a/app/(app)/page.tsx +++ b/app/(app)/page.tsx @@ -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() {

{t("greeting", { name: session.displayName })}

+ {!guide.seenIntro && checklist === "none" ? : null} + {checklist !== "none" ? : null} + {checklist !== "show" ? : null} +
{after.toRate.map((r) => ( diff --git a/app/api/onboarding/route.ts b/app/api/onboarding/route.ts new file mode 100644 index 0000000..9df83a1 --- /dev/null +++ b/app/api/onboarding/route.ts @@ -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 }); +} diff --git a/components/today/intro-cards.tsx b/components/today/intro-cards.tsx new file mode 100644 index 0000000..e8bfc6f --- /dev/null +++ b/components/today/intro-cards.tsx @@ -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 ( +
+

{t("eyebrow", { n: i + 1, of: cards.length })}

+ +

+ {t(`${simple ? "kid" : card.key}.title`)} +

+

{t(`${simple ? "kid" : card.key}.text`)}

+
+ {last ? ( + + ) : ( + <> + + + + )} +
+
+ ); +} diff --git a/components/today/round-stepper.tsx b/components/today/round-stepper.tsx new file mode 100644 index 0000000..ad86014 --- /dev/null +++ b/components/today/round-stepper.tsx @@ -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 ( +
+

+ {t("title")} +

+ {simple ? null : ( +
    + {STAGES.map((s, i) => ( +
  1. + + + {t(`names.${s}`)} + {i === at ? ({t("current")}) : null} + +
  2. + ))} +
+ )} +
+

+ {t("now")} + {t(`next.${next.key}`, next.values ?? {})} +

+ {next.href ? ( + + {t(`cta.${next.key}`)} + + ) : null} +
+
+ ); +} diff --git a/components/today/setup-checklist.tsx b/components/today/setup-checklist.tsx new file mode 100644 index 0000000..fbb0fcd --- /dev/null +++ b/components/today/setup-checklist.tsx @@ -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 = { 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 ( +
+

+ {t("finishedTitle")} +

+

{t("finishedText")}

+ +
+ ); + } + + const current = steps.find((s) => !s.done)!; + const done = steps.filter((s) => s.done).length; + return ( +
+
+

+ {t("title")} +

+ {t("progress", { n: done, of: steps.length })} +
+
+

{t(`${current.key}.title`)}

+

+ {t(`${current.key}.text`, { n: current.n ?? 0, of: current.of ?? 0 })} +

+ + {t(`${current.key}.cta`)} + + {current.key === "dishes" ? ( + + {t("dishes.moreLink")} + + ) : null} + {current.key === "family" ? ( + + ) : null} +
+
    + {steps.map((s, i) => ( +
  1. + + {s.done ? : i + 1} + + + {s.done ? t("doneSr") : s === current ? t("nowSr") : t("laterSr")} + {t(`${s.key}.short`)} + {s.key === "dishes" && !s.done ? ` · ${s.n} / ${s.of}` : ""} + {s.skipped ? ` · ${t("skipped")}` : ""} + + {!s.done && s !== current ? ( + + + + ) : null} +
  2. + ))} +
+ +
+ ); +} diff --git a/db/migrations/0017_onboarding.sql b/db/migrations/0017_onboarding.sql new file mode 100644 index 0000000..23586d7 --- /dev/null +++ b/db/migrations/0017_onboarding.sql @@ -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; diff --git a/e2e/ablauf.spec.ts b/e2e/ablauf.spec.ts index cbabde2..dbf811d 100644 --- a/e2e/ablauf.spec.ts +++ b/e2e/ablauf.spec.ts @@ -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"); diff --git a/e2e/gerichte.spec.ts b/e2e/gerichte.spec.ts index bdaa7fa..dff849f 100644 --- a/e2e/gerichte.spec.ts +++ b/e2e/gerichte.spec.ts @@ -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 }) => { diff --git a/e2e/kinder.spec.ts b/e2e/kinder.spec.ts index 2a7f478..aaa5aef 100644 --- a/e2e/kinder.spec.ts +++ b/e2e/kinder.spec.ts @@ -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"]) { diff --git a/e2e/kochen.spec.ts b/e2e/kochen.spec.ts index d3bfff7..9d16ac4 100644 --- a/e2e/kochen.spec.ts +++ b/e2e/kochen.spec.ts @@ -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(); diff --git a/e2e/plan.spec.ts b/e2e/plan.spec.ts index 2098223..0374b06 100644 --- a/e2e/plan.spec.ts +++ b/e2e/plan.spec.ts @@ -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(); diff --git a/e2e/wuenschen.spec.ts b/e2e/wuenschen.spec.ts index 1daea4a..26b6381 100644 --- a/e2e/wuenschen.spec.ts +++ b/e2e/wuenschen.spec.ts @@ -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 diff --git a/lib/onboarding.ts b/lib/onboarding.ts new file mode 100644 index 0000000..7086de9 --- /dev/null +++ b/lib/onboarding.ts @@ -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 }; + +/** 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" }; + } +} diff --git a/messages/de.json b/messages/de.json index 53c96b8..04c32bd 100644 --- a/messages/de.json +++ b/messages/de.json @@ -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." + } } } diff --git a/messages/en.json b/messages/en.json index 5705e9a..f560a14 100644 --- a/messages/en.json +++ b/messages/en.json @@ -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." + } } } diff --git a/messages/es.json b/messages/es.json index 85513de..25b7406 100644 --- a/messages/es.json +++ b/messages/es.json @@ -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." + } } } diff --git a/messages/fr.json b/messages/fr.json index 50afbc3..b53cd5e 100644 --- a/messages/fr.json +++ b/messages/fr.json @@ -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." + } } } diff --git a/olares/Chart.yaml b/olares/Chart.yaml index f9159ba..5cc49d6 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.26 # YY.M. 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. 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 diff --git a/olares/OlaresManifest.yaml b/olares/OlaresManifest.yaml index 3ba72f7..5078931 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.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: diff --git a/olares/markt/26.11.27.md b/olares/markt/26.11.27.md new file mode 100644 index 0000000..d4a81b3 --- /dev/null +++ b/olares/markt/26.11.27.md @@ -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“. diff --git a/tests/onboarding.test.ts b/tests/onboarding.test.ts new file mode 100644 index 0000000..b420e75 --- /dev/null +++ b/tests/onboarding.test.ts @@ -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 }); + }); +});