// Berichtsansicht aus denselben Bausteinen wie die ausführliche E-Mail (report.get → blocks, engine/mail-report*.ts): // Ergebnis-Kopf, Kurzfazit, Kennzahlen-Kacheln, Tabellen mit Symbolen, Kennzahlen, Listen – im Stil der App // (Papier/Tinte), mobil ab 390 px ohne Überlauf: lange Namen brechen um, Zahlenspalten bleiben schmal. import { Icon } from "../icons.tsx"; type Tone = "win" | "loss" | "warn" | "info"; type Cell = string | { v: string; tone?: Tone; bold?: boolean; muted?: boolean; icon?: string }; export type ReportBlock = | { type: "banner"; tone: Tone; kicker?: string; title: string; sub?: string } | { type: "tiles"; tiles: { label: string; value: string; tone?: Tone }[] } | { type: "section"; title: string } | { type: "table"; head: string[]; rows: Cell[][]; align?: ("left" | "right")[]; foot?: Cell[]; maxRows?: number; caption?: string } | { type: "facts"; facts: [string, string][] } | { type: "list"; items: string[] } | { type: "text"; text: string; tone?: "muted" | Tone }; const TONE_TEXT: Record = { win: "text-moos", loss: "text-siegel", warn: "text-messing", info: "text-ink", muted: "text-ink2" }; const TONE_RULE: Record = { win: "bg-moos", loss: "bg-siegel", warn: "bg-messing", info: "bg-see" }; /** Textsymbol der E-Mail (⚓︎, ✈︎, ♞︎, ▣) entfällt, wenn die App ein Bild zeigt. */ const stripSymbol = (s: string) => s.replace(/^[^\p{L}\p{N}]+/u, ""); function Banner({ b }: { b: Extract }) { return (
{b.kicker &&
{b.kicker}
}

{b.title}

{b.sub &&
{b.sub}
}
); } function Tiles({ b }: { b: Extract }) { return (
= 3 ? "grid-cols-3" : "grid-cols-2"}`}> {b.tiles.map((t, i) => (
{t.value}
{t.label}
))}
); } function CellView({ c, right, foot }: { c: Cell; right: boolean; foot?: boolean }) { const o = typeof c === "string" ? { v: c } : c; const color = o.tone ? TONE_TEXT[o.tone] : o.muted ? "text-ink2" : ""; const cls = `py-1 px-1.5 align-top ${right ? "text-right mono whitespace-nowrap" : "text-left break-words"} ${color} ${o.bold || foot ? "font-semibold" : ""}`; return ( {o.icon ? ( {stripSymbol(o.v)} ) : o.v} ); } function Table({ b }: { b: Extract }) { const right = (i: number) => (b.align?.[i] ?? (i === 0 ? "left" : "right")) === "right"; return (
{b.head.length > 0 && ( {b.head.map((h, i) => )} )} {b.rows.map((r, k) => ( {r.map((c, i) => )} ))} {b.foot && {b.foot.map((c, i) => )}}
{h}
{b.caption &&

{b.caption}

}
); } function Facts({ b }: { b: Extract }) { return (
{b.facts.map(([k, v], i) => (
{k}
{v}
))}
); } function Block({ b }: { b: ReportBlock }) { switch (b.type) { case "banner": return ; case "tiles": return ; case "section": return

{b.title}

; case "table": return ; case "facts": return ; case "list": return (
    {b.items.map((t, i) =>
  • {t}
  • )}
); case "text": return

{b.text}

; default: return null; } } /** Bausteine nacheinander; `only` beschränkt auf bestimmte Arten (z. B. nur den Kopf). */ export function ReportBlocks({ blocks, only }: { blocks: ReportBlock[]; only?: ReportBlock["type"][] }) { const shown = only ? blocks.filter((b) => only.includes(b.type)) : blocks; return
{shown.map((b, i) => )}
; }