"use client" import { useEffect, useState } from "react" /** * KanbanBoard — Kernfeature 3: VS-Auswahl, Spalten Neu/Bewertet/In Bau/Fertig * aus board-service (via /api/fleet/kanban), Poll 5 s (Statuswechsel <=10 s). */ type Card = { id: string; titel: string; score: number; status: string; ursprung: string; erstellt: string } type KanbanData = { value_streams: string[] boards: Array<{ vs: string; board: { kanban: Record } }> generated_at: string } const COLUMNS = ["Neu", "Bewertet", "In Bau", "Fertig"] as const export default function KanbanBoard() { const [data, setData] = useState(null) const [selectedVs, setSelectedVs] = useState("") const [error, setError] = useState(null) useEffect(() => { let cancelled = false const load = () => { fetch("/api/fleet/kanban", { cache: "no-store" }) .then(async (res) => { if (!res.ok) throw new Error((await res.json()).error || `HTTP ${res.status}`) return res.json() }) .then((d: KanbanData) => { if (cancelled) return setData(d) setError(null) if (!selectedVs && d.value_streams.length > 0) setSelectedVs(d.value_streams[0]) }) .catch((e: Error) => { if (!cancelled) setError(e.message) }) } load() const timer = setInterval(load, 5000) return () => { cancelled = true clearInterval(timer) } }, [selectedVs]) if (error) { return (

Board-Service nicht erreichbar

{error}

) } if (!data) { return (
LADEN...
) } const board = data.boards.find((b) => b.vs === selectedVs) const kanban = board?.board.kanban || { Neu: [], Bewertet: [], "In Bau": [], Fertig: [] } return (

KANBAN

{COLUMNS.map((col) => (
{col} {kanban[col]?.length || 0}
{(kanban[col] || []).map((c) => (
{c.id}
{c.titel}
score {c.score} · {c.ursprung}
))}
))}
) }