Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e0db3252d5 | ||
|
|
44edd5c86b |
No files matched your search
@@ -7,12 +7,13 @@
|
||||
> **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.20 — alle neun Arbeitspakete aus `docs/PROJEKTSTART.md` sind gebaut:
|
||||
> **Status:** 26.11.22 — 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). Offen sind V2b (Kassenbons)
|
||||
> Rolle „Jugendlich“ (26.11.19), Rezepte in einer Form (26.11.20),
|
||||
> Produkte je Gericht (26.11.21), Veto mit Gegenvorschlag (26.11.22). Offen sind V2b (Kassenbons)
|
||||
> und der Magic Link.
|
||||
> **Letzte Aktualisierung:** 7. November 2026
|
||||
|
||||
@@ -336,6 +337,23 @@ Vorlagen ersetzt. `tests/seed.test.ts` prüft die Dateien. Ein Haushalt
|
||||
durch `fromStyleReply`: **jede Zahl im neuen Text muss in der Quelle stehen**, sonst
|
||||
gilt die Regel. Ergebnis ist ein Entwurf; ein Mensch speichert.
|
||||
|
||||
## Produkte je Gericht (seit 26.11.21)
|
||||
|
||||
- An `dish_ingredients`: `product` (Name), `product_pack` (Basiseinheit),
|
||||
`product_cook_minutes` (Migration 0012) — je Gericht, nicht je Haushalt (Kai).
|
||||
Die Kochzeit ersetzt den Timer eines Kochschritts, der die Zutat nennt
|
||||
(`withProductTimers` in `lib/dishes.ts`, `timerFrom`). Einkaufsliste:
|
||||
`productLabel` in `lib/shopping.ts`, Packung des Produkts statt der Standardgrößen.
|
||||
|
||||
## Veto mit Gegenvorschlag (seit 26.11.22, Maike)
|
||||
|
||||
- Ein Veto braucht `alternativeDishId`: ein Gericht aus dem Pool (nicht „Ausprobieren“),
|
||||
das in der Runde noch niemand nennt (`lib/wishes.ts`, `alternatives`). Der Ersatz ist
|
||||
ein Wunsch mit `wishes.veto_id` (Migration 0013), kostet keinen Jeton; Veto und Ersatz
|
||||
gehen nur zusammen weg.
|
||||
- **Tests:** Scheitert `beforeAll`, zählt vitest die Tests als übersprungen, nicht als
|
||||
rot — nach jedem Lauf mit Datenbank muss „skipped“ 0 sein.
|
||||
|
||||
## Rollen
|
||||
|
||||
- `admin`, `member`, `teen` (seit 26.11.19), `child`, `guest`. Wer was darf, steht nur
|
||||
|
||||
+2
-2
@@ -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.20
|
||||
version: 26.11.22
|
||||
categories:
|
||||
- Applications
|
||||
|
||||
@@ -61,7 +61,7 @@ permission:
|
||||
appData: true
|
||||
|
||||
spec:
|
||||
versionName: '26.11.20'
|
||||
versionName: '26.11.22'
|
||||
|
||||
featuredImage: https://git.aimighty.olares.de/aimighty/bilder/raw/branch/main/lunch/icon.png
|
||||
promoteImage:
|
||||
|
||||
@@ -39,6 +39,7 @@ export default async function EditDishPage({ params }: { params: Promise<{ id: s
|
||||
ingredient: { id: i.ingredientId, name: i.name, unit: i.unit },
|
||||
qty: i.qtyPerPortion * PORTIONS,
|
||||
note: i.note,
|
||||
product: i.product,
|
||||
})),
|
||||
steps: dish.steps.map((s) => ({ text: s.text, section: s.section, timerMinutes: s.timerSeconds ? Math.round(s.timerSeconds / 60) : null })),
|
||||
}}
|
||||
|
||||
@@ -8,7 +8,7 @@ export const dynamic = "force-dynamic";
|
||||
|
||||
|
||||
const dishId = z.string().uuid();
|
||||
const add = z.object({ dishId, note: z.string().max(120).nullable().optional(), wantsToCook: z.boolean().optional(), veto: z.boolean().optional() });
|
||||
const add = z.object({ dishId, note: z.string().max(120).nullable().optional(), wantsToCook: z.boolean().optional(), veto: z.boolean().optional(), alternativeDishId: z.string().uuid().optional() });
|
||||
const change = z.object({ dishId, note: z.string().max(120).nullable(), wantsToCook: z.boolean() });
|
||||
|
||||
export async function POST(request: Request) {
|
||||
|
||||
@@ -13,7 +13,7 @@ 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[] };
|
||||
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")}`;
|
||||
@@ -244,6 +244,7 @@ export function CookingMode({
|
||||
onToggle={() => toggleTimer(index, step.timerSeconds!)}
|
||||
/>
|
||||
) : null}
|
||||
{step.timerSeconds && step.timerFrom ? <p className="text-sm text-muted-foreground">{t("timerFromProduct", { product: step.timerFrom })}</p> : null}
|
||||
</section>
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { ArrowDown, ArrowUp, Plus, Sparkles, X, Wand2 } from "lucide-react";
|
||||
import { ArrowDown, ArrowUp, Plus, Sparkles, X, Package, Wand2 } from "lucide-react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useTranslations } from "next-intl";
|
||||
import { useEffect, useId, useRef, useState } from "react";
|
||||
@@ -14,7 +14,8 @@ import { cn } from "@/lib/utils";
|
||||
import { SECTIONS, type Section } from "@/lib/recipe-style";
|
||||
|
||||
type Picked = { id: string; name: string; unit: BaseUnit };
|
||||
type Row = { key: number; ingredient: Picked | null; qty: string; unit: string; note: string };
|
||||
// Produkt (optional): Name, Packung in der Einheit der Zeile, Kochzeit laut Packung.
|
||||
type Row = { key: number; ingredient: Picked | null; qty: string; unit: string; note: string; product: string; pack: string; cook: string; open: boolean };
|
||||
type StepRow = { key: number; text: string; timer: string; section: Section | "" };
|
||||
|
||||
export type DishFormValue = {
|
||||
@@ -26,7 +27,13 @@ export type DishFormValue = {
|
||||
effortMinutes: number | null;
|
||||
isTrial: boolean;
|
||||
// Beim Import kann die Menge fehlen (passt nicht zur Zutat) — dann trägt die Person sie ein.
|
||||
ingredients: { ingredient: Picked; qty: number | null; unit?: string | null; note: string | null }[];
|
||||
ingredients: {
|
||||
ingredient: Picked;
|
||||
qty: number | null;
|
||||
unit?: string | null;
|
||||
note: string | null;
|
||||
product?: { name: string; pack: number | null; cookMinutes: number | null } | null;
|
||||
}[];
|
||||
steps: { text: string; timerMinutes: number | null; section?: Section | null }[];
|
||||
sourceUrl?: string | null;
|
||||
imageUrl?: string | null;
|
||||
@@ -69,8 +76,12 @@ export function DishForm({ initial }: { initial?: DishFormValue }) {
|
||||
qty: i.qty !== null ? formatQty(i.qty) : "",
|
||||
unit: i.unit && UNITS_FOR[i.ingredient.unit].includes(i.unit) ? i.unit : i.ingredient.unit,
|
||||
note: i.note ?? "",
|
||||
product: i.product?.name ?? "",
|
||||
pack: i.product?.pack ? formatQty(i.product.pack) : "",
|
||||
cook: i.product?.cookMinutes ? String(i.product.cookMinutes) : "",
|
||||
open: !!i.product,
|
||||
}))
|
||||
: [{ key: next(), ingredient: null, qty: "", unit: "g", note: "" }],
|
||||
: [{ key: next(), ingredient: null, qty: "", unit: "g", note: "", product: "", pack: "", cook: "", open: false }],
|
||||
);
|
||||
const [steps, setSteps] = useState<StepRow[]>(
|
||||
initial?.steps.length
|
||||
@@ -131,7 +142,19 @@ export function DishForm({ initial }: { initial?: DishFormValue }) {
|
||||
}
|
||||
const ingredients = rows
|
||||
.filter((r) => r.ingredient && r.qty.trim())
|
||||
.map((r) => ({ ingredientId: r.ingredient!.id, qty: parseNumber(r.qty) ?? -1, unit: r.unit, note: r.note.trim() || null }));
|
||||
.map((r) => ({
|
||||
ingredientId: r.ingredient!.id,
|
||||
qty: parseNumber(r.qty) ?? -1,
|
||||
unit: r.unit,
|
||||
note: r.note.trim() || null,
|
||||
product: r.product.trim()
|
||||
? {
|
||||
name: r.product.trim(),
|
||||
pack: r.pack.trim() ? (parseNumber(r.pack) ?? null) : null,
|
||||
cookMinutes: r.cook.trim() ? Math.round(parseNumber(r.cook) ?? 0) || null : null,
|
||||
}
|
||||
: null,
|
||||
}));
|
||||
if (!title.trim() || !n || n < 1 || ingredients.some((i) => !(i.qty > 0))) {
|
||||
setError("invalid");
|
||||
return;
|
||||
@@ -294,10 +317,45 @@ export function DishForm({ initial }: { initial?: DishFormValue }) {
|
||||
maxLength={120}
|
||||
onChange={(e) => update(row.key, { note: e.target.value })}
|
||||
/>
|
||||
{row.open ? (
|
||||
<fieldset className="flex flex-col gap-2 rounded-xl border border-border p-3">
|
||||
<legend className="px-1 text-sm font-medium">{t("form.product")}</legend>
|
||||
<Label htmlFor={`product-${row.key}`} className="sr-only">
|
||||
{t("form.productName", { name: row.ingredient?.name ?? "" })}
|
||||
</Label>
|
||||
<Input
|
||||
id={`product-${row.key}`}
|
||||
placeholder={t("form.productPlaceholder")}
|
||||
maxLength={80}
|
||||
value={row.product}
|
||||
onChange={(e) => update(row.key, { product: e.target.value })}
|
||||
/>
|
||||
<div className="grid grid-cols-2 gap-2">
|
||||
<div className="flex flex-col gap-1">
|
||||
<Label htmlFor={`pack-${row.key}`} className="text-sm">
|
||||
{t("form.productPack", { unit: t(`form.units.${row.unit}`) })}
|
||||
</Label>
|
||||
<Input id={`pack-${row.key}`} inputMode="decimal" value={row.pack} onChange={(e) => update(row.key, { pack: e.target.value })} />
|
||||
</div>
|
||||
<div className="flex flex-col gap-1">
|
||||
<Label htmlFor={`cook-${row.key}`} className="text-sm">
|
||||
{t("form.productCook")}
|
||||
</Label>
|
||||
<Input id={`cook-${row.key}`} inputMode="numeric" value={row.cook} onChange={(e) => update(row.key, { cook: e.target.value })} />
|
||||
</div>
|
||||
</div>
|
||||
<p className="text-xs text-muted-foreground">{t("form.productHint")}</p>
|
||||
</fieldset>
|
||||
) : (
|
||||
<Button type="button" variant="ghost" className="self-start" disabled={!row.ingredient} onClick={() => update(row.key, { open: true })}>
|
||||
<Package aria-hidden />
|
||||
{t("form.addProduct")}
|
||||
</Button>
|
||||
)}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
<Button type="button" variant="outline" onClick={() => setRows((rs) => [...rs, { key: next(), ingredient: null, qty: "", unit: "g", note: "" }])}>
|
||||
<Button type="button" variant="outline" onClick={() => setRows((rs) => [...rs, { key: next(), ingredient: null, qty: "", unit: "g", note: "", product: "", pack: "", cook: "", open: false }])}>
|
||||
<Plus aria-hidden />
|
||||
{t("form.ingredients")}
|
||||
</Button>
|
||||
|
||||
@@ -16,8 +16,9 @@ type Ingredient = {
|
||||
unit: BaseUnit;
|
||||
note: string | null;
|
||||
isStaple: boolean;
|
||||
product?: { name: string } | null;
|
||||
};
|
||||
type Step = { section: Section; text: string; timerSeconds: number | null; ingredientIds: string[] };
|
||||
type Step = { section: Section; text: string; timerSeconds: number | null; ingredientIds: string[]; timerFrom?: string };
|
||||
|
||||
// Zutaten in der gewählten Portionszahl, darunter die Schritte. Die Mengen
|
||||
// rechnet lib/units.ts — gespeichert ist immer „pro Portion“.
|
||||
@@ -63,6 +64,7 @@ export function PortionScaler({ ingredients, steps, initialPortions }: { ingredi
|
||||
<span className="flex-1">
|
||||
{labelFor(i, scale(i.qtyPerPortion, portions))}
|
||||
{i.note ? <span className="text-muted-foreground">, {i.note}</span> : null}
|
||||
{i.product ? <span className="block text-sm text-muted-foreground">{i.product.name}</span> : null}
|
||||
</span>
|
||||
{i.isStaple ? <span className="text-xs text-muted-foreground">{t("staple")}</span> : null}
|
||||
</li>
|
||||
@@ -99,7 +101,9 @@ export function PortionScaler({ ingredients, steps, initialPortions }: { ingredi
|
||||
{s.timerSeconds ? (
|
||||
<p className="flex items-center gap-1 text-sm text-accent">
|
||||
<Timer aria-hidden className="size-4" />
|
||||
{t("stepTimer", { n: Math.round(s.timerSeconds / 60) })}
|
||||
{s.timerFrom
|
||||
? t("stepTimerProduct", { n: Math.round(s.timerSeconds / 60), product: s.timerFrom })
|
||||
: t("stepTimer", { n: Math.round(s.timerSeconds / 60) })}
|
||||
</p>
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
@@ -21,7 +21,15 @@ export type Tile = {
|
||||
lastCooked: string | null;
|
||||
createdAt: string;
|
||||
};
|
||||
export type Entry = { dishId: string; memberId: string; memberName: string; note: string | null; wantsToCook: boolean; isVeto: boolean };
|
||||
export type Entry = {
|
||||
dishId: string;
|
||||
memberId: string;
|
||||
memberName: string;
|
||||
note: string | null;
|
||||
wantsToCook: boolean;
|
||||
isVeto: boolean;
|
||||
viaVeto?: boolean;
|
||||
};
|
||||
type Budget = { tokens: number; tokensLeft: number; vetos: number; vetosLeft: number };
|
||||
|
||||
const FILTERS = ["all", "popular", "quick", "longAgo", "new"] as const;
|
||||
@@ -87,7 +95,7 @@ export function WishBoard({
|
||||
const data = await res.json().catch(() => ({}));
|
||||
setBusy(null);
|
||||
if (!res.ok) {
|
||||
setError(["noTokens", "noVetos", "noRound", "noTrial", "dish"].includes(data.error) ? data.error : "unknown");
|
||||
setError(["noTokens", "noVetos", "noRound", "noTrial", "dish", "alternative"].includes(data.error) ? data.error : "unknown");
|
||||
return null;
|
||||
}
|
||||
if (method === "POST" && "vibrate" in navigator) navigator.vibrate?.(15);
|
||||
@@ -224,6 +232,7 @@ export function WishBoard({
|
||||
own={mine(open.id)}
|
||||
budget={budget}
|
||||
canVeto={canVeto}
|
||||
alternatives={tiles.filter((x) => !x.isTrial && x.id !== open.id && !(byDish.get(x.id) ?? []).length)}
|
||||
busy={!!busy}
|
||||
onCall={async (method, body) => {
|
||||
const ok = await call(method, "/api/wishes", body, open.id);
|
||||
@@ -242,6 +251,7 @@ function WishOptions({
|
||||
own,
|
||||
budget,
|
||||
canVeto,
|
||||
alternatives,
|
||||
busy,
|
||||
onCall,
|
||||
onClose,
|
||||
@@ -250,6 +260,7 @@ function WishOptions({
|
||||
own: Entry | undefined;
|
||||
budget: Budget;
|
||||
canVeto: boolean;
|
||||
alternatives: Tile[];
|
||||
busy: boolean;
|
||||
onCall: (method: string, body: object) => Promise<void>;
|
||||
onClose: () => void;
|
||||
@@ -258,6 +269,39 @@ function WishOptions({
|
||||
const [note, setNote] = useState(own?.note ?? "");
|
||||
const [cook, setCook] = useState(own?.wantsToCook ?? false);
|
||||
const wished = own && !own.isVeto;
|
||||
// Veto nur mit Gegenvorschlag (Maike): erst ein anderes Gericht wählen, dann gilt das Veto.
|
||||
const [picking, setPicking] = useState(false);
|
||||
if (picking) {
|
||||
return (
|
||||
<div className="flex flex-col gap-4 p-5 pb-[calc(1.25rem+env(safe-area-inset-bottom))]">
|
||||
<h2 id="wish-options-title" className="text-2xl">
|
||||
{t("vetoInstead", { title: tile.title })}
|
||||
</h2>
|
||||
<p className="text-sm text-muted-foreground">{t("vetoInsteadHint")}</p>
|
||||
{alternatives.length ? (
|
||||
<ul className="flex max-h-[50vh] flex-col overflow-y-auto">
|
||||
{alternatives.map((a) => (
|
||||
<li key={a.id}>
|
||||
<button
|
||||
type="button"
|
||||
disabled={busy}
|
||||
className="flex min-h-11 w-full items-center rounded-xl px-2 text-left hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
|
||||
onClick={() => onCall("POST", { dishId: tile.id, veto: true, alternativeDishId: a.id })}
|
||||
>
|
||||
{a.title}
|
||||
</button>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
) : (
|
||||
<p className="rounded-2xl border border-border p-4 text-sm">{t("vetoNoAlternative")}</p>
|
||||
)}
|
||||
<Button type="button" variant="ghost" onClick={() => setPicking(false)}>
|
||||
{t("back")}
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<form
|
||||
method="dialog"
|
||||
@@ -293,12 +337,13 @@ function WishOptions({
|
||||
<Button type="submit" size="lg" disabled={busy || (!wished && budget.tokensLeft < 1)}>
|
||||
{wished ? t("saveWish") : t("wishWithToken")}
|
||||
</Button>
|
||||
{wished && own?.viaVeto ? <p className="text-sm text-muted-foreground">{t("viaVetoHint")}</p> : null}
|
||||
{wished ? (
|
||||
<Button type="button" variant="outline" disabled={busy} onClick={() => onCall("DELETE", { dishId: tile.id })}>
|
||||
{t("unwish")}
|
||||
</Button>
|
||||
) : canVeto && budget.vetos > 0 ? (
|
||||
<Button type="button" variant="outline" disabled={busy || budget.vetosLeft < 1} onClick={() => onCall("POST", { dishId: tile.id, veto: true })}>
|
||||
<Button type="button" variant="outline" disabled={busy || budget.vetosLeft < 1} onClick={() => setPicking(true)}>
|
||||
<ThumbsDown aria-hidden />
|
||||
{budget.vetosLeft < 1 ? t("noVetoLeft") : t("veto")}
|
||||
</Button>
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
-- Produkte je Gericht (Kai, 7.11.2026): an einer Zutat eines Gerichts das Produkt,
|
||||
-- das man wirklich nimmt („Barilla Spaghetti Nr. 5“), seine Packungsgröße (in der
|
||||
-- Basiseinheit der Zutat) und seine Kochzeit laut Packung. Die Kochzeit wird zum
|
||||
-- Timer des Schritts, der die Zutat kocht; Name und Packung gehen auf die Einkaufsliste.
|
||||
alter table dish_ingredients
|
||||
add column product text check (length(trim(product)) between 1 and 80),
|
||||
add column product_pack numeric(10, 3) check (product_pack > 0),
|
||||
add column product_cook_minutes integer check (product_cook_minutes between 1 and 240);
|
||||
@@ -0,0 +1,6 @@
|
||||
-- Veto nur mit Gegenvorschlag (Maike, 7.11.2026): Wer ein Veto einlegt, wählt ein
|
||||
-- anderes Gericht aus dem Pool. Dieser Ersatz ist ein Wunsch derselben Person, der
|
||||
-- keinen Jeton kostet; er hängt am Veto und verschwindet mit ihm.
|
||||
alter table wishes add column veto_id uuid references wishes (id) on delete cascade;
|
||||
alter table wishes add constraint wishes_veto_alternative check (not (is_veto and veto_id is not null));
|
||||
create index wishes_veto_idx on wishes (veto_id) where veto_id is not null;
|
||||
@@ -75,3 +75,20 @@ test("free text lands under Other and can be removed", async ({ page }) => {
|
||||
await page.getByRole("button", { name: "Klopapier entfernen" }).click();
|
||||
await expect(page.getByText("Klopapier")).toHaveCount(0);
|
||||
});
|
||||
|
||||
test("a product on a dish goes on the list and sets the cooking timer", async ({ page }) => {
|
||||
await page.goto("/gerichte");
|
||||
await page.getByRole("link", { name: /Spaghetti Bolognese/ }).click();
|
||||
await page.getByRole("link", { name: "Bearbeiten" }).click();
|
||||
await page.getByRole("button", { name: "Produkt hinterlegen" }).first().click();
|
||||
await page.getByLabel("Produkt für Spaghetti").fill("Barilla Spaghetti Nr. 5");
|
||||
await page.getByLabel("Packung in g").fill("500");
|
||||
await page.getByLabel("Kochzeit (Min.)").fill("9");
|
||||
await page.getByRole("button", { name: "Speichern" }).click();
|
||||
await expect(page.getByRole("heading", { level: 1 })).toHaveText("Spaghetti Bolognese");
|
||||
await expect(page.locator("main")).toContainText("Barilla Spaghetti Nr. 5");
|
||||
await expect(page.locator("ol li", { hasText: "Spaghetti in reichlich Salzwasser" })).toContainText("9 Min. laut Packung (Barilla Spaghetti Nr. 5)");
|
||||
|
||||
await page.goto("/einkauf");
|
||||
await expect(page.locator("main")).toContainText("Barilla Spaghetti Nr. 5");
|
||||
});
|
||||
@@ -35,7 +35,14 @@ test("a veto and a reason go through the options sheet", async ({ page }) => {
|
||||
const sheet = page.getByRole("dialog");
|
||||
await expect(sheet.getByRole("heading", { name: "Flammkuchen" })).toBeVisible();
|
||||
await sheet.getByRole("button", { name: "Veto einlegen" }).click();
|
||||
// Veto nur mit Gegenvorschlag aus dem Pool (Maike); er kostet keinen Jeton.
|
||||
await expect(sheet.getByRole("heading", { name: "Statt Flammkuchen vorschlagen" })).toBeVisible();
|
||||
await expect(sheet.getByRole("button", { name: "Spaghetti Bolognese" })).toHaveCount(0); // schon gewünscht
|
||||
await sheet.getByRole("button", { name: "Gemüsecurry mit Reis" }).click();
|
||||
await expect(sheet).toBeHidden();
|
||||
await expect(page.getByText("Veto: du")).toBeVisible();
|
||||
await expect(page.getByRole("button", { name: /^Wunsch zurücknehmen: Gemüsecurry mit Reis/ })).toBeVisible();
|
||||
await expect(page.getByText("0 Jetons frei")).toBeVisible();
|
||||
await expect(page.getByText("Veto vergeben")).toBeVisible();
|
||||
|
||||
await page.getByRole("button", { name: "Optionen für Spaghetti Bolognese" }).click();
|
||||
@@ -67,5 +74,5 @@ test("Today shows the family's wishes", async ({ page }) => {
|
||||
await expect(page.getByRole("heading", { level: 2 }).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(2);
|
||||
await expect(list.locator("li")).toHaveCount(3); // dazu der Gegenvorschlag zum Veto
|
||||
});
|
||||
+42
-7
@@ -31,6 +31,15 @@ export const dishInput = z.object({
|
||||
qty: z.number().positive().max(100000),
|
||||
unit: z.enum(INPUT_UNITS),
|
||||
note: z.string().trim().max(120).nullable().optional(),
|
||||
// Produkt, das man nimmt; Packung in der Einheit der Zeile, Kochzeit laut Packung.
|
||||
product: z
|
||||
.object({
|
||||
name: z.string().trim().min(1).max(80),
|
||||
pack: z.number().positive().max(100000).nullable().optional(),
|
||||
cookMinutes: z.number().int().min(1).max(240).nullable().optional(),
|
||||
})
|
||||
.nullable()
|
||||
.optional(),
|
||||
}),
|
||||
)
|
||||
.max(60),
|
||||
@@ -68,10 +77,15 @@ export type DishDetail = DishSummary & {
|
||||
unit: BaseUnit;
|
||||
note: string | null;
|
||||
isStaple: boolean;
|
||||
product: Product | null;
|
||||
}[];
|
||||
steps: { section: Section; text: string; timerSeconds: number | null; ingredientIds: string[] }[];
|
||||
// timerFrom: Name des Produkts, wenn der Timer von seiner Packung stammt.
|
||||
steps: { section: Section; text: string; timerSeconds: number | null; ingredientIds: string[]; timerFrom?: string }[];
|
||||
};
|
||||
|
||||
/** Produkt an einer Zutat des Gerichts; pack in der Basiseinheit der Zutat. */
|
||||
export type Product = { name: string; pack: number | null; cookMinutes: number | null };
|
||||
|
||||
/** Alle Namen einer Zutat (jede Sprache, Einzahl, Synonyme) — für die Zuordnung zu Schritten. */
|
||||
export function stepIngredient(e: IngredientEntry): StepIngredient {
|
||||
const forms = Object.values(e.forms ?? {}).flatMap((f) => (f ? [f.one, f.other] : []));
|
||||
@@ -93,7 +107,8 @@ export async function getDish(client: PoolClient, id: string, locale: string): P
|
||||
const entries = new Map((await allIngredients()).map((i) => [i.id, i]));
|
||||
const ingredients = (
|
||||
await client.query(
|
||||
"select ingredient_id, qty_per_portion, unit, note, is_staple from dish_ingredients where dish_id = $1 order by position",
|
||||
`select ingredient_id, qty_per_portion, unit, note, is_staple, product, product_pack::float as product_pack, product_cook_minutes
|
||||
from dish_ingredients where dish_id = $1 order by position`,
|
||||
[id],
|
||||
)
|
||||
).rows.map((r) => ({
|
||||
@@ -104,6 +119,7 @@ export async function getDish(client: PoolClient, id: string, locale: string): P
|
||||
unit: r.unit,
|
||||
note: r.note,
|
||||
isStaple: r.is_staple,
|
||||
product: r.product ? { name: r.product, pack: r.product_pack, cookMinutes: r.product_cook_minutes } : null,
|
||||
}));
|
||||
const rows = (
|
||||
await client.query("select section, text, timer_seconds, ingredient_ids from dish_steps where dish_id = $1 order by position", [id])
|
||||
@@ -123,7 +139,22 @@ export async function getDish(client: PoolClient, id: string, locale: string): P
|
||||
rows.map((r) => ({ text: r.text, timerSeconds: r.timer_seconds })),
|
||||
own,
|
||||
);
|
||||
return { ...dish, ingredients, steps };
|
||||
return { ...dish, ingredients, steps: withProductTimers(steps, ingredients) };
|
||||
}
|
||||
|
||||
/**
|
||||
* Kochzeit laut Packung: Ein Kochschritt, der eine Zutat mit Produkt-Kochzeit nennt,
|
||||
* bekommt diese Zeit als Timer („Barilla Nr. 5: 9 Min.“) — sie gilt vor der Zeit im Text.
|
||||
*/
|
||||
export function withProductTimers<S extends { section: Section; timerSeconds: number | null; ingredientIds: string[] }>(
|
||||
steps: S[],
|
||||
ingredients: { ingredientId: string; product: Product | null }[],
|
||||
): (S & { timerFrom?: string })[] {
|
||||
return steps.map((s) => {
|
||||
if (s.section !== "cook") return s;
|
||||
const hit = s.ingredientIds.map((id) => ingredients.find((i) => i.ingredientId === id)?.product).find((p) => p?.cookMinutes);
|
||||
return hit ? { ...s, timerSeconds: hit.cookMinutes! * 60, timerFrom: hit.name } : s;
|
||||
});
|
||||
}
|
||||
|
||||
export class InvalidAmount extends Error {}
|
||||
@@ -137,7 +168,9 @@ export async function saveDish(client: PoolClient, householdId: string, memberId
|
||||
if (!base) throw new InvalidAmount(i.ingredientId);
|
||||
const total = toBase(i.qty, i.unit as InputUnit, base);
|
||||
if (total === null) throw new InvalidAmount(i.ingredientId);
|
||||
return { ...i, base, perPortion: Math.round((total / input.portions) * 1000) / 1000, position };
|
||||
// Packung in der Einheit der Zeile → Basiseinheit („500 g“, „1 kg“ → 1000).
|
||||
const pack = i.product?.pack ? toBase(i.product.pack, i.unit as InputUnit, base) : null;
|
||||
return { ...i, base, perPortion: Math.round((total / input.portions) * 1000) / 1000, position, pack };
|
||||
});
|
||||
const values = [
|
||||
input.title,
|
||||
@@ -168,9 +201,11 @@ export async function saveDish(client: PoolClient, householdId: string, memberId
|
||||
}
|
||||
for (const r of rows) {
|
||||
await client.query(
|
||||
`insert into dish_ingredients (household_id, dish_id, ingredient_id, qty_per_portion, unit, note, position)
|
||||
values ($1, $2, $3, $4, $5, $6, $7)`,
|
||||
[householdId, dishId, r.ingredientId, r.perPortion, r.base, r.note ?? null, r.position],
|
||||
`insert into dish_ingredients (household_id, dish_id, ingredient_id, qty_per_portion, unit, note, position,
|
||||
product, product_pack, product_cook_minutes)
|
||||
values ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)`,
|
||||
[householdId, dishId, r.ingredientId, r.perPortion, r.base, r.note ?? null, r.position,
|
||||
r.product?.name ?? null, r.product ? r.pack : null, r.product?.cookMinutes ?? null],
|
||||
);
|
||||
}
|
||||
// Abschnitte: was das Formular sagt, sonst nach den Verben; Zutaten je Schritt aus dem Text.
|
||||
|
||||
@@ -28,11 +28,15 @@ export function classifyStep(text: string): Section {
|
||||
/** Zutaten, die ein Schritt beim Namen nennt (ganze Wörter, auch Wortanfang: „Zwiebel“ in „Zwiebeln“). */
|
||||
export function linkIngredients(text: string, list: StepIngredient[]): string[] {
|
||||
const t = text.toLocaleLowerCase("de");
|
||||
// Wörter des Schritts für zusammengesetzte Namen: „Hackfleisch“ trifft „Rinderhackfleisch“.
|
||||
const stepWords = t.match(/\p{L}{6,}/gu) ?? [];
|
||||
return list
|
||||
.filter((i) =>
|
||||
i.names.some((n) => {
|
||||
const name = n.toLocaleLowerCase("de").replace(/\s*\(.*\)\s*/g, "").trim();
|
||||
if (name.length < 3) return false;
|
||||
const last = name.split(/\s+/).at(-1)!;
|
||||
if (stepWords.some((w) => last !== w && last.endsWith(w.replace(/(e|en|n|s)$/, "")))) return true;
|
||||
// Der Wortstamm reicht („Kartoffeln“ trifft „Kartoffel“), aber nur am Wortanfang.
|
||||
const stem = name.length > 5 ? name.slice(0, -1) : name;
|
||||
return new RegExp(`(^|[^\\p{L}])${stem.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}`, "u").test(t);
|
||||
|
||||
+22
-3
@@ -39,6 +39,16 @@ export async function defaultAisles(client: PoolClient) {
|
||||
}
|
||||
|
||||
/** Liste an den Plan angleichen: Mengen nachführen, Neues dazu, Weggefallenes (nicht Abgehaktes) raus. */
|
||||
/** „Barilla Spaghetti Nr. 5“ statt „Spaghetti“; mehrere Produkte: „Spaghetti (Barilla Nr. 5 / De Cecco Nr. 12)“. */
|
||||
export function productLabel(name: string, products: Set<string> | undefined): string {
|
||||
const list = [...(products ?? [])];
|
||||
if (!list.length) return name;
|
||||
if (list.length > 1) return `${name} (${list.join(" / ")})`;
|
||||
// Nennt das Produkt die Zutat schon („Barilla Spaghetti Nr. 5“), reicht es; sonst „Spaghetti · Barilla Nr. 5“.
|
||||
const stem = name.toLocaleLowerCase("de").slice(0, Math.max(4, name.length - 2));
|
||||
return list[0]!.toLocaleLowerCase("de").includes(stem) ? list[0]! : `${name} · ${list[0]}`;
|
||||
}
|
||||
|
||||
export async function syncList(client: PoolClient, householdId: string, round: Round, locale: string): Promise<void> {
|
||||
await client.query("select pg_advisory_xact_lock(hashtext('shopping:' || $1))", [round.id]);
|
||||
const rows = (
|
||||
@@ -47,7 +57,8 @@ export async function syncList(client: PoolClient, householdId: string, round: R
|
||||
i.category, i.pack_sizes::float[] as packs,
|
||||
(i.pantry_default or exists (select 1 from pantry_staples p where p.ingredient_id = i.id)) as pantry,
|
||||
coalesce(i.names ->> $2, i.names ->> 'de', i.key) as name,
|
||||
coalesce(i.forms -> $2, i.forms -> 'en') as form
|
||||
coalesce(i.forms -> $2, i.forms -> 'en') as form,
|
||||
di.product, di.product_pack::float as product_pack
|
||||
from slots s join dishes d on d.id = s.dish_id
|
||||
join dish_ingredients di on di.dish_id = d.id
|
||||
join ingredients i on i.id = di.ingredient_id
|
||||
@@ -59,14 +70,22 @@ export async function syncList(client: PoolClient, householdId: string, round: R
|
||||
const bySlot = new Map<string, PlanSlotInput>();
|
||||
const packs = new Map<string, number[]>();
|
||||
const forms = new Map<string, { one: string; other: string }>();
|
||||
// Produkte je Zutat aus den Gerichten der Runde: Name auf die Liste, Packung statt der Standardgrößen.
|
||||
const products = new Map<string, Set<string>>();
|
||||
const productPacks = new Map<string, number[]>();
|
||||
for (const r of rows) {
|
||||
const slot: PlanSlotInput = bySlot.get(r.slot) ?? { dishTitle: r.title, portions: r.portions, ingredients: [] };
|
||||
slot.ingredients.push({ ingredientId: r.ingredient_id, name: r.name, unit: r.unit, qtyPerPortion: r.q, category: r.category, packs: r.packs, pantry: r.pantry });
|
||||
bySlot.set(r.slot, slot);
|
||||
packs.set(r.ingredient_id, r.packs ?? []);
|
||||
if (r.form) forms.set(r.ingredient_id, r.form);
|
||||
if (r.product) {
|
||||
products.set(r.ingredient_id, (products.get(r.ingredient_id) ?? new Set()).add(r.product));
|
||||
if (r.product_pack) productPacks.set(r.ingredient_id, [...(productPacks.get(r.ingredient_id) ?? []), r.product_pack]);
|
||||
}
|
||||
}
|
||||
const lines = withPacks(aggregate([...bySlot.values()], await defaultAisles(client)), (id) => packs.get(id) ?? []);
|
||||
const lines = withPacks(aggregate([...bySlot.values()], await defaultAisles(client)), (id) => productPacks.get(id) ?? packs.get(id) ?? []);
|
||||
const label = (l: (typeof lines)[number]) => productLabel(labelFor({ name: l.name, forms: forms.get(l.ingredientId) ?? null, unit: l.unit }, l.qty), products.get(l.ingredientId));
|
||||
for (const l of lines) {
|
||||
await client.query(
|
||||
`insert into shopping_items (household_id, round_id, ingredient_id, label, qty, needed, unit, pack_count, pack_size,
|
||||
@@ -77,7 +96,7 @@ export async function syncList(client: PoolClient, householdId: string, round: R
|
||||
pack_count = excluded.pack_count, pack_size = excluded.pack_size, dishes = excluded.dishes,
|
||||
aisle_position = excluded.aisle_position,
|
||||
pantry_state = case when excluded.pantry_state is null then null else coalesce(shopping_items.pantry_state, 'ask') end`,
|
||||
[householdId, round.id, l.ingredientId, labelFor({ name: l.name, forms: forms.get(l.ingredientId) ?? null, unit: l.unit }, l.qty), l.qty, l.needed, l.unit, l.pack?.count ?? null, l.pack?.size ?? null,
|
||||
[householdId, round.id, l.ingredientId, label(l), l.qty, l.needed, l.unit, l.pack?.count ?? null, l.pack?.size ?? null,
|
||||
l.dishes, l.aislePosition, l.pantry ? "ask" : null],
|
||||
);
|
||||
}
|
||||
|
||||
+49
-10
@@ -18,12 +18,14 @@ export type WishEntry = {
|
||||
note: string | null;
|
||||
wantsToCook: boolean;
|
||||
isVeto: boolean;
|
||||
/** Gegenvorschlag zu einem Veto: kostet keinen Jeton. */
|
||||
viaVeto: boolean;
|
||||
};
|
||||
|
||||
export async function budget(client: PoolClient, roundId: string, memberId: string): Promise<Budget> {
|
||||
const { rows } = await client.query(
|
||||
`select h.tokens_per_round as tokens, h.vetos_per_round as vetos,
|
||||
count(w.id) filter (where not w.is_veto)::int as wished,
|
||||
count(w.id) filter (where not w.is_veto and w.veto_id is null)::int as wished,
|
||||
count(w.id) filter (where w.is_veto)::int as vetoed
|
||||
from households h
|
||||
left join wishes w on w.round_id = $1 and w.member_id = $2
|
||||
@@ -37,7 +39,8 @@ export async function budget(client: PoolClient, roundId: string, memberId: stri
|
||||
export async function roundWishes(client: PoolClient, roundId: string): Promise<WishEntry[]> {
|
||||
const { rows } = await client.query(
|
||||
`select w.dish_id as "dishId", w.member_id as "memberId", m.display_name as "memberName", w.note,
|
||||
w.wants_to_cook as "wantsToCook", w.is_veto as "isVeto"
|
||||
w.wants_to_cook as "wantsToCook", w.is_veto as "isVeto",
|
||||
w.veto_id is not null as "viaVeto"
|
||||
from wishes w join members m on m.id = w.member_id
|
||||
where w.round_id = $1
|
||||
order by w.created_at`,
|
||||
@@ -54,12 +57,12 @@ export function favorites(entries: WishEntry[]): Set<string> {
|
||||
}
|
||||
|
||||
export class WishRefused extends Error {
|
||||
constructor(public reason: "noRound" | "noTokens" | "noVetos" | "dish" | "already") {
|
||||
constructor(public reason: "noRound" | "noTokens" | "noVetos" | "dish" | "already" | "alternative") {
|
||||
super(reason);
|
||||
}
|
||||
}
|
||||
|
||||
type WishOptions = { note?: string | null; wantsToCook?: boolean; veto?: boolean };
|
||||
type WishOptions = { note?: string | null; wantsToCook?: boolean; veto?: boolean; alternativeDishId?: string };
|
||||
|
||||
/** Wunsch oder Veto für ein Gericht der offenen Runde. Zählt unter Sperre je Person. */
|
||||
export async function addWish(client: PoolClient, householdId: string, memberId: string, dishId: string, opts: WishOptions = {}) {
|
||||
@@ -70,12 +73,45 @@ export async function addWish(client: PoolClient, householdId: string, memberId:
|
||||
if (!dish) throw new WishRefused("dish");
|
||||
const b = await budget(client, round.id, memberId);
|
||||
if (opts.veto ? b.vetosLeft < 1 : b.tokensLeft < 1) throw new WishRefused(opts.veto ? "noVetos" : "noTokens");
|
||||
const { rowCount } = await client.query(
|
||||
// Veto nur mit Gegenvorschlag: ein Gericht aus dem Pool, das in dieser Runde noch niemand nennt.
|
||||
if (opts.veto) {
|
||||
const alt = opts.alternativeDishId;
|
||||
const ok =
|
||||
alt &&
|
||||
alt !== dishId &&
|
||||
(
|
||||
await client.query(
|
||||
`select 1 from dishes d where d.id = $1 and d.archived_at is null and not d.is_trial
|
||||
and not exists (select 1 from wishes w where w.round_id = $2 and w.dish_id = d.id)`,
|
||||
[alt, round.id],
|
||||
)
|
||||
).rowCount;
|
||||
if (!ok) throw new WishRefused("alternative");
|
||||
}
|
||||
const { rows } = await client.query(
|
||||
`insert into wishes (household_id, round_id, member_id, dish_id, note, wants_to_cook, is_veto)
|
||||
values ($1, $2, $3, $4, $5, $6, $7) on conflict (round_id, member_id, dish_id) do nothing`,
|
||||
values ($1, $2, $3, $4, $5, $6, $7) on conflict (round_id, member_id, dish_id) do nothing returning id`,
|
||||
[householdId, round.id, memberId, dishId, opts.note?.trim() || null, !opts.veto && !!opts.wantsToCook, !!opts.veto],
|
||||
);
|
||||
if (!rowCount) throw new WishRefused("already");
|
||||
if (!rows[0]) throw new WishRefused("already");
|
||||
if (opts.veto) {
|
||||
await client.query(
|
||||
`insert into wishes (household_id, round_id, member_id, dish_id, veto_id) values ($1, $2, $3, $4, $5)`,
|
||||
[householdId, round.id, memberId, opts.alternativeDishId, rows[0].id],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/** Gerichte, die als Gegenvorschlag zu einem Veto taugen: Pool, in der Runde noch von niemandem genannt. */
|
||||
export async function alternatives(client: PoolClient, roundId: string): Promise<{ id: string; title: string }[]> {
|
||||
const { rows } = await client.query(
|
||||
`select d.id, d.title from dishes d
|
||||
where d.archived_at is null and not d.is_trial
|
||||
and not exists (select 1 from wishes w where w.round_id = $1 and w.dish_id = d.id)
|
||||
order by lower(d.title)`,
|
||||
[roundId],
|
||||
);
|
||||
return rows;
|
||||
}
|
||||
|
||||
/** Grund oder „Ich koche das“ an einem eigenen Wunsch ändern. */
|
||||
@@ -91,12 +127,15 @@ export async function updateWish(client: PoolClient, memberId: string, dishId: s
|
||||
|
||||
/** Eigenen Wunsch oder eigenes Veto zurücknehmen (nur solange die Runde offen ist). */
|
||||
export async function removeWish(client: PoolClient, memberId: string, dishId: string): Promise<boolean> {
|
||||
const { rowCount } = await client.query(
|
||||
const { rows } = await client.query(
|
||||
`delete from wishes where member_id = $1 and dish_id = $2
|
||||
and round_id = (select id from rounds where status = 'open' order by created_at desc limit 1)`,
|
||||
and round_id = (select id from rounds where status = 'open' order by created_at desc limit 1)
|
||||
returning veto_id`,
|
||||
[memberId, dishId],
|
||||
);
|
||||
return rowCount === 1;
|
||||
// Ein Veto nimmt seinen Gegenvorschlag mit (Fremdschlüssel); der Gegenvorschlag nimmt sein Veto mit.
|
||||
if (rows[0]?.veto_id) await client.query("delete from wishes where id = $1", [rows[0].veto_id]);
|
||||
return rows.length === 1;
|
||||
}
|
||||
|
||||
/** Joker „Etwas Neues“: ein zufälliges Gericht aus „Ausprobieren“, das ich noch nicht gewünscht habe. */
|
||||
|
||||
+20
-5
@@ -293,7 +293,8 @@
|
||||
"photoError": "Das Foto ließ sich nicht lesen. Nimm ein JPEG, PNG oder HEIC bis 15 MB.",
|
||||
"stepTimer": "{n} Min.",
|
||||
"source": "Quelle",
|
||||
"pieces": "{n, plural, one {Stück} other {Stück}}"
|
||||
"pieces": "{n, plural, one {Stück} other {Stück}}",
|
||||
"stepTimerProduct": "{n} Min. laut Packung ({product})"
|
||||
},
|
||||
"form": {
|
||||
"newTitle": "Neues Gericht",
|
||||
@@ -348,7 +349,14 @@
|
||||
"styledByAi": "Von der AI in die Lunch-Form gebracht. Zeiten und Temperaturen stammen aus dem Rezept — bitte kurz prüfen.",
|
||||
"styledByRules": "Nach Regeln in Abschnitte eingeordnet, Wortlaut unverändert. Mit eingerichteter AI werden die Schritte auch umformuliert.",
|
||||
"styleFailed": "Das hat nicht geklappt. Die Schritte sind unverändert.",
|
||||
"section": "Abschnitt von Schritt {n}"
|
||||
"section": "Abschnitt von Schritt {n}",
|
||||
"product": "Produkt",
|
||||
"productName": "Produkt für {name}",
|
||||
"productPlaceholder": "z. B. Barilla Spaghetti Nr. 5",
|
||||
"productPack": "Packung in {unit}",
|
||||
"productCook": "Kochzeit (Min.)",
|
||||
"productHint": "Die Kochzeit wird zum Timer im Schritt, der die Zutat kocht; Name und Packung stehen auf der Einkaufsliste.",
|
||||
"addProduct": "Produkt hinterlegen"
|
||||
},
|
||||
"addLinkText": "Wir lesen Zutaten und Schritte von der Rezeptseite.",
|
||||
"link": {
|
||||
@@ -456,11 +464,17 @@
|
||||
"noRound": "Gerade läuft keine Runde.",
|
||||
"noTrial": "Unter „Ausprobieren“ ist nichts Neues mehr.",
|
||||
"dish": "Dieses Gericht gibt es nicht mehr.",
|
||||
"unknown": "Das hat nicht geklappt. Bitte versuch es noch einmal."
|
||||
"unknown": "Das hat nicht geklappt. Bitte versuch es noch einmal.",
|
||||
"alternative": "Bitte wähl ein anderes Gericht aus dem Pool, das noch niemand gewünscht hat."
|
||||
},
|
||||
"wishAction": "Wünschen:",
|
||||
"unwishAction": "Wunsch zurücknehmen:",
|
||||
"vetoAction": "Veto ändern:"
|
||||
"vetoAction": "Veto ändern:",
|
||||
"vetoInstead": "Statt {title} vorschlagen",
|
||||
"vetoInsteadHint": "Ein Veto geht nur mit einem Gegenvorschlag aus dem Pool. Er zählt als dein Wunsch und kostet keinen Jeton.",
|
||||
"vetoNoAlternative": "Gerade ist kein Gericht aus dem Pool frei, das noch niemand gewünscht hat. Ohne Gegenvorschlag gibt es kein Veto.",
|
||||
"back": "Zurück",
|
||||
"viaVetoHint": "Dein Gegenvorschlag zu einem Veto. Nimmst du ihn zurück, endet auch das Veto."
|
||||
},
|
||||
"kids": {
|
||||
"title": "Wer bist du?",
|
||||
@@ -587,7 +601,8 @@
|
||||
"startTimer": "Timer starten",
|
||||
"error": "Das hat nicht geklappt. Bitte versuch es noch einmal.",
|
||||
"alreadyCooked": "Das ist schon gekocht. Guten Appetit!",
|
||||
"forStep": "Dafür"
|
||||
"forStep": "Dafür",
|
||||
"timerFromProduct": "Zeit laut Packung: {product}"
|
||||
},
|
||||
"rating": {
|
||||
"eyebrow": "Wie war's?",
|
||||
|
||||
+20
-5
@@ -293,7 +293,8 @@
|
||||
"photoError": "The photo couldn't be read. Use a JPEG, PNG or HEIC up to 15 MB.",
|
||||
"stepTimer": "{n} min",
|
||||
"source": "Source",
|
||||
"pieces": "{n, plural, one {piece} other {pieces}}"
|
||||
"pieces": "{n, plural, one {piece} other {pieces}}",
|
||||
"stepTimerProduct": "{n} min per pack ({product})"
|
||||
},
|
||||
"form": {
|
||||
"newTitle": "New dish",
|
||||
@@ -348,7 +349,14 @@
|
||||
"styledByAi": "Put into the Lunch form by the AI. Times and temperatures come from the recipe — please check briefly.",
|
||||
"styledByRules": "Sorted into sections by rules, wording unchanged. With an AI set up, the steps are rewritten too.",
|
||||
"styleFailed": "That didn't work. The steps are unchanged.",
|
||||
"section": "Section of step {n}"
|
||||
"section": "Section of step {n}",
|
||||
"product": "Product",
|
||||
"productName": "Product for {name}",
|
||||
"productPlaceholder": "e.g. Barilla Spaghetti No. 5",
|
||||
"productPack": "Pack in {unit}",
|
||||
"productCook": "Cooking time (min)",
|
||||
"productHint": "The cooking time becomes the timer of the step that cooks this ingredient; name and pack go on the shopping list.",
|
||||
"addProduct": "Add product"
|
||||
},
|
||||
"addLinkText": "We read ingredients and steps from the recipe page.",
|
||||
"link": {
|
||||
@@ -456,11 +464,17 @@
|
||||
"noRound": "No round is running right now.",
|
||||
"noTrial": "Nothing new left under “To try”.",
|
||||
"dish": "This dish no longer exists.",
|
||||
"unknown": "That did not work. Please try again."
|
||||
"unknown": "That did not work. Please try again.",
|
||||
"alternative": "Please pick another pool dish nobody has wished for yet."
|
||||
},
|
||||
"wishAction": "Wish:",
|
||||
"unwishAction": "Take back wish:",
|
||||
"vetoAction": "Change veto:"
|
||||
"vetoAction": "Change veto:",
|
||||
"vetoInstead": "Suggest instead of {title}",
|
||||
"vetoInsteadHint": "A veto needs a counter-suggestion from the pool. It counts as your wish and costs no token.",
|
||||
"vetoNoAlternative": "No pool dish is free right now that nobody has wished for. Without a counter-suggestion there is no veto.",
|
||||
"back": "Back",
|
||||
"viaVetoHint": "Your counter-suggestion to a veto. Taking it back ends the veto too."
|
||||
},
|
||||
"kids": {
|
||||
"title": "Who are you?",
|
||||
@@ -587,7 +601,8 @@
|
||||
"startTimer": "Start timer",
|
||||
"error": "That did not work. Please try again.",
|
||||
"alreadyCooked": "This has been cooked already. Enjoy!",
|
||||
"forStep": "You need"
|
||||
"forStep": "You need",
|
||||
"timerFromProduct": "Time per pack: {product}"
|
||||
},
|
||||
"rating": {
|
||||
"eyebrow": "How was it?",
|
||||
|
||||
+20
-5
@@ -293,7 +293,8 @@
|
||||
"photoError": "The photo couldn't be read. Use a JPEG, PNG or HEIC up to 15 MB.",
|
||||
"stepTimer": "{n} min",
|
||||
"source": "Source",
|
||||
"pieces": "{n, plural, one {piece} other {pieces}}"
|
||||
"pieces": "{n, plural, one {piece} other {pieces}}",
|
||||
"stepTimerProduct": "{n} min según el paquete ({product})"
|
||||
},
|
||||
"form": {
|
||||
"newTitle": "New dish",
|
||||
@@ -348,7 +349,14 @@
|
||||
"styledByAi": "Puesto en la forma de Lunch por la AI. Tiempos y temperaturas vienen de la receta — revísalo un momento.",
|
||||
"styledByRules": "Ordenado en secciones por reglas, texto sin cambios. Con una AI configurada, los pasos también se reformulan.",
|
||||
"styleFailed": "No ha funcionado. Los pasos no han cambiado.",
|
||||
"section": "Sección del paso {n}"
|
||||
"section": "Sección del paso {n}",
|
||||
"product": "Producto",
|
||||
"productName": "Producto para {name}",
|
||||
"productPlaceholder": "p. ej. Barilla Spaghetti n.º 5",
|
||||
"productPack": "Paquete en {unit}",
|
||||
"productCook": "Cocción (min)",
|
||||
"productHint": "El tiempo de cocción pasa a ser el temporizador del paso que cuece el ingrediente; nombre y paquete van a la lista de la compra.",
|
||||
"addProduct": "Indicar producto"
|
||||
},
|
||||
"addLinkText": "Leemos los ingredientes y los pasos de la página de la receta.",
|
||||
"link": {
|
||||
@@ -456,11 +464,17 @@
|
||||
"noRound": "No round is running right now.",
|
||||
"noTrial": "Nothing new left under “To try”.",
|
||||
"dish": "This dish no longer exists.",
|
||||
"unknown": "That did not work. Please try again."
|
||||
"unknown": "That did not work. Please try again.",
|
||||
"alternative": "Elige otro plato del pool que nadie haya deseado aún."
|
||||
},
|
||||
"wishAction": "Wish:",
|
||||
"unwishAction": "Take back wish:",
|
||||
"vetoAction": "Change veto:"
|
||||
"vetoAction": "Change veto:",
|
||||
"vetoInstead": "Proponer en lugar de {title}",
|
||||
"vetoInsteadHint": "Un veto solo vale con una contrapropuesta del pool. Cuenta como tu deseo y no cuesta ficha.",
|
||||
"vetoNoAlternative": "Ahora no hay ningún plato del pool libre. Sin contrapropuesta no hay veto.",
|
||||
"back": "Atrás",
|
||||
"viaVetoHint": "Tu contrapropuesta a un veto. Si la retiras, también termina el veto."
|
||||
},
|
||||
"kids": {
|
||||
"title": "Who are you?",
|
||||
@@ -587,7 +601,8 @@
|
||||
"startTimer": "Start timer",
|
||||
"error": "That did not work. Please try again.",
|
||||
"alreadyCooked": "This has been cooked already. Enjoy!",
|
||||
"forStep": "Necesitas"
|
||||
"forStep": "Necesitas",
|
||||
"timerFromProduct": "Tiempo según el paquete: {product}"
|
||||
},
|
||||
"rating": {
|
||||
"eyebrow": "How was it?",
|
||||
|
||||
+20
-5
@@ -293,7 +293,8 @@
|
||||
"photoError": "The photo couldn't be read. Use a JPEG, PNG or HEIC up to 15 MB.",
|
||||
"stepTimer": "{n} min",
|
||||
"source": "Source",
|
||||
"pieces": "{n, plural, one {piece} other {pieces}}"
|
||||
"pieces": "{n, plural, one {piece} other {pieces}}",
|
||||
"stepTimerProduct": "{n} min selon le paquet ({product})"
|
||||
},
|
||||
"form": {
|
||||
"newTitle": "New dish",
|
||||
@@ -348,7 +349,14 @@
|
||||
"styledByAi": "Mis en forme par l'AI. Durées et températures viennent de la recette — vérifie rapidement.",
|
||||
"styledByRules": "Classé en sections par règles, texte inchangé. Avec une AI configurée, les étapes sont aussi reformulées.",
|
||||
"styleFailed": "Ça n'a pas marché. Les étapes sont inchangées.",
|
||||
"section": "Section de l'étape {n}"
|
||||
"section": "Section de l'étape {n}",
|
||||
"product": "Produit",
|
||||
"productName": "Produit pour {name}",
|
||||
"productPlaceholder": "p. ex. Barilla Spaghetti n° 5",
|
||||
"productPack": "Paquet en {unit}",
|
||||
"productCook": "Cuisson (min)",
|
||||
"productHint": "Le temps de cuisson devient le minuteur de l'étape qui cuit l'ingrédient ; nom et paquet vont sur la liste de courses.",
|
||||
"addProduct": "Indiquer un produit"
|
||||
},
|
||||
"addLinkText": "Nous lisons les ingrédients et les étapes sur la page de la recette.",
|
||||
"link": {
|
||||
@@ -456,11 +464,17 @@
|
||||
"noRound": "No round is running right now.",
|
||||
"noTrial": "Nothing new left under “To try”.",
|
||||
"dish": "This dish no longer exists.",
|
||||
"unknown": "That did not work. Please try again."
|
||||
"unknown": "That did not work. Please try again.",
|
||||
"alternative": "Choisis un autre plat du pool que personne n'a encore souhaité."
|
||||
},
|
||||
"wishAction": "Wish:",
|
||||
"unwishAction": "Take back wish:",
|
||||
"vetoAction": "Change veto:"
|
||||
"vetoAction": "Change veto:",
|
||||
"vetoInstead": "Proposer à la place de {title}",
|
||||
"vetoInsteadHint": "Un veto n'est possible qu'avec une contre-proposition du pool. Elle compte comme ton souhait et ne coûte pas de jeton.",
|
||||
"vetoNoAlternative": "Aucun plat du pool n'est libre pour l'instant. Sans contre-proposition, pas de veto.",
|
||||
"back": "Retour",
|
||||
"viaVetoHint": "Ta contre-proposition à un veto. La retirer met aussi fin au veto."
|
||||
},
|
||||
"kids": {
|
||||
"title": "Who are you?",
|
||||
@@ -587,7 +601,8 @@
|
||||
"startTimer": "Start timer",
|
||||
"error": "That did not work. Please try again.",
|
||||
"alreadyCooked": "This has been cooked already. Enjoy!",
|
||||
"forStep": "Il te faut"
|
||||
"forStep": "Il te faut",
|
||||
"timerFromProduct": "Temps selon le paquet : {product}"
|
||||
},
|
||||
"rating": {
|
||||
"eyebrow": "How was it?",
|
||||
|
||||
+2
-2
@@ -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.20 # YY.M.<n> wie im AImighty-Markt — bei jeder Chart-Änderung erhöhen
|
||||
appVersion: "26.11.20" # MUSS gleich version sein: der Linter prüft es, und der Image-Tag hängt daran
|
||||
version: 26.11.22 # YY.M.<n> wie im AImighty-Markt — bei jeder Chart-Änderung erhöhen
|
||||
appVersion: "26.11.22" # MUSS gleich version sein: der Linter prüft es, und der Image-Tag hängt daran
|
||||
@@ -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.20
|
||||
version: 26.11.22
|
||||
categories:
|
||||
- Applications
|
||||
|
||||
@@ -61,7 +61,7 @@ permission:
|
||||
appData: true
|
||||
|
||||
spec:
|
||||
versionName: '26.11.20'
|
||||
versionName: '26.11.22'
|
||||
|
||||
featuredImage: https://git.aimighty.olares.de/aimighty/bilder/raw/branch/main/lunch/icon.png
|
||||
promoteImage:
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
# Your products in the recipe
|
||||
v26.11.21: Each ingredient of a dish can carry the product you actually use — "Barilla Spaghetti No. 5", pack size and cooking time per pack. The cooking time becomes the timer of the step that cooks it (shown as "per pack"), the dish page names the product, and the shopping list shows the product with its pack size instead of just "Spaghetti". Steps also find ingredients named by part of a compound word ("Hackfleisch" for "Rinderhackfleisch").
|
||||
|
||||
## Deutsch
|
||||
v26.11.21: Jede Zutat eines Gerichts kann das Produkt tragen, das ihr wirklich nehmt — „Barilla Spaghetti Nr. 5“, Packungsgröße und Kochzeit laut Packung. Die Kochzeit wird zum Timer des Schritts, der die Zutat kocht („laut Packung“), die Gerichtsseite nennt das Produkt, und die Einkaufsliste zeigt das Produkt mit seiner Packung statt nur „Spaghetti“. Schritte finden Zutaten jetzt auch über einen Teil eines zusammengesetzten Worts („Hackfleisch“ für „Rinderhackfleisch“).
|
||||
@@ -0,0 +1,5 @@
|
||||
# A veto brings a suggestion
|
||||
v26.11.22: A veto now only works together with a counter-suggestion: whoever vetoes a dish picks another one from the pool that nobody has wished for yet. The suggestion counts as their wish and costs no token; taking it back ends the veto too.
|
||||
|
||||
## Deutsch
|
||||
v26.11.22: Ein Veto gibt es jetzt nur mit Gegenvorschlag: Wer ein Gericht ablehnt, wählt ein anderes aus dem Pool, das in der Runde noch niemand gewünscht hat. Der Vorschlag zählt als eigener Wunsch und kostet keinen Jeton; wer ihn zurücknimmt, beendet auch das Veto.
|
||||
@@ -72,6 +72,28 @@ describe.skipIf(!url)("dishes", () => {
|
||||
expect(dish!.steps).toEqual([{ section: "cook", text: "Alles anbraten.", timerSeconds: 600, ingredientIds: [] }]);
|
||||
});
|
||||
|
||||
it("keeps the product of an ingredient; its cooking time becomes the timer of the step that cooks it", async () => {
|
||||
const id = await as(a, () =>
|
||||
lib.saveDish(
|
||||
client as never,
|
||||
a,
|
||||
member,
|
||||
input({
|
||||
ingredients: [
|
||||
{ ingredientId: ing.ground_beef!, qty: 0.5, unit: "kg", product: { name: "Bio-Rinderhack", pack: 0.4, cookMinutes: 8 } },
|
||||
{ ingredientId: ing.egg!, qty: 2, unit: "piece" },
|
||||
],
|
||||
steps: [{ text: "Hackfleisch anbraten.", timerMinutes: 10 }, { text: "Eier dazugeben." }],
|
||||
}),
|
||||
),
|
||||
);
|
||||
const dish = await as(a, () => lib.getDish(client as never, id, "de"));
|
||||
expect(dish!.ingredients[0]!.product).toEqual({ name: "Bio-Rinderhack", pack: 400, cookMinutes: 8 }); // 0,4 kg → 400 g
|
||||
expect(dish!.ingredients[1]!.product).toBeNull();
|
||||
expect(dish!.steps[0]).toMatchObject({ timerSeconds: 480, timerFrom: "Bio-Rinderhack" });
|
||||
expect(dish!.steps[1]!.timerSeconds).toBeNull();
|
||||
});
|
||||
|
||||
it("refuses an amount that does not fit the ingredient", async () => {
|
||||
await expect(
|
||||
as(a, () => lib.saveDish(client as never, a, member, input({ ingredients: [{ ingredientId: ing.egg!, qty: 200, unit: "g" }] }))),
|
||||
|
||||
+1
-1
@@ -45,7 +45,7 @@ describe.skipIf(!url)("plan", () => {
|
||||
await rounds.openRound(c, h, kai, { shoppingDate: "2026-11-14", slotsCount: 3, defaultPortions: 4 });
|
||||
await wishes.addWish(c, h, maike, d.Curry!, { wantsToCook: true });
|
||||
await wishes.addWish(c, h, kai, d.Curry!);
|
||||
await wishes.addWish(c, h, kai, d.Pizza!, { veto: true });
|
||||
await wishes.addWish(c, h, kai, d.Pizza!, { veto: true, alternativeDishId: d.Suppe! });
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
vi.mock("server-only", () => ({}));
|
||||
|
||||
describe("product on the shopping list", async () => {
|
||||
const { productLabel } = await import("@/lib/shopping");
|
||||
it("shows the product instead of the ingredient, or both when the product does not name it", () => {
|
||||
expect(productLabel("Spaghetti", undefined)).toBe("Spaghetti");
|
||||
expect(productLabel("Spaghetti", new Set(["Barilla Spaghetti Nr. 5"]))).toBe("Barilla Spaghetti Nr. 5");
|
||||
expect(productLabel("Spaghetti", new Set(["Barilla Nr. 5"]))).toBe("Spaghetti · Barilla Nr. 5");
|
||||
expect(productLabel("Spaghetti", new Set(["Barilla Nr. 5", "De Cecco Nr. 12"]))).toBe("Spaghetti (Barilla Nr. 5 / De Cecco Nr. 12)");
|
||||
});
|
||||
});
|
||||
@@ -20,6 +20,7 @@ describe("recipe style", () => {
|
||||
expect(linkIngredients("Die Zwiebel fein würfeln.", list)).toEqual(["zw"]);
|
||||
expect(linkIngredients("Spaghetti mit Parmesan bestreuen.", list)).toEqual(["sp", "pa"]);
|
||||
expect(linkIngredients("Alles mischen.", list)).toEqual([]);
|
||||
expect(linkIngredients("Hackfleisch krümelig anbraten.", [{ id: "rh", names: ["Rinderhackfleisch"] }])).toEqual(["rh"]);
|
||||
});
|
||||
|
||||
it("without a model: prep moves ahead, serve only at the end, timers from the text", () => {
|
||||
|
||||
+22
-2
@@ -55,9 +55,29 @@ describe.skipIf(!url)("wishes", () => {
|
||||
await expect(as((c) => wishes.addWish(c, h, kai, dishes[1]!))).rejects.toMatchObject({ reason: "noTokens" });
|
||||
});
|
||||
|
||||
it("a veto needs a free counter-suggestion from the pool, which costs no token", async () => {
|
||||
const veto = (alt?: string) => as((c) => wishes.addWish(c, h, kai, dishes[1]!, { veto: true, alternativeDishId: alt }));
|
||||
await expect(veto()).rejects.toMatchObject({ reason: "alternative" }); // ohne Gegenvorschlag
|
||||
await expect(veto(dishes[0])).rejects.toMatchObject({ reason: "alternative" }); // schon gewünscht
|
||||
await expect(veto(dishes[3])).rejects.toMatchObject({ reason: "alternative" }); // nur „Ausprobieren“
|
||||
await expect(veto(dishes[1])).rejects.toMatchObject({ reason: "alternative" }); // das Gericht selbst
|
||||
await veto(dishes[2]);
|
||||
expect(await budget(kai)).toMatchObject({ tokensLeft: 0, vetosLeft: 0 });
|
||||
const entries = await as(async (c) => wishes.roundWishes(c, (await rounds.currentRound(c))!.id));
|
||||
expect(entries.find((e) => e.dishId === dishes[2])).toMatchObject({ memberId: kai, isVeto: false, viaVeto: true });
|
||||
|
||||
// Den Gegenvorschlag zurücknehmen beendet auch das Veto — und umgekehrt.
|
||||
expect(await as((c) => wishes.removeWish(c, kai, dishes[2]!))).toBe(true);
|
||||
expect((await budget(kai)).vetosLeft).toBe(1);
|
||||
await veto(dishes[2]);
|
||||
expect(await as((c) => wishes.removeWish(c, kai, dishes[1]!))).toBe(true);
|
||||
const after = await as(async (c) => wishes.roundWishes(c, (await rounds.currentRound(c))!.id));
|
||||
expect(after.some((e) => e.dishId === dishes[2])).toBe(false);
|
||||
await veto(dishes[2]);
|
||||
});
|
||||
|
||||
it("allows one veto, and taking a wish back frees its token", async () => {
|
||||
await as((c) => wishes.addWish(c, h, kai, dishes[1]!, { veto: true }));
|
||||
await expect(as((c) => wishes.addWish(c, h, kai, dishes[2]!, { veto: true }))).rejects.toMatchObject({ reason: "noVetos" });
|
||||
await expect(as((c) => wishes.addWish(c, h, kai, bolognese, { veto: true, alternativeDishId: dishes[0] }))).rejects.toMatchObject({ reason: "noVetos" });
|
||||
expect(await as((c) => wishes.removeWish(c, kai, dishes[0]!))).toBe(true);
|
||||
expect((await budget(kai)).tokensLeft).toBe(1);
|
||||
await expect(as((c) => wishes.addWish(c, h, kai, bolognese))).rejects.toMatchObject({ reason: "already" });
|
||||
|
||||
Reference in new issue
Block a user