"use client"; import { useState } from "react"; import type { ManagementBoard } from "@/lib/management/model"; import { chartColors, RetentionChart } from "./management-charts"; import { compactMoney, dateLabel, Filter, Legend, ManagementShell, money, Panel, Stat } from "./management-ui"; export function RetentionView({ board }: { board: ManagementBoard }) { const [month, setMonth] = useState("all"); const [query, setQuery] = useState(""); const entries = board.retentionSchedule.flatMap((m) => m.entries.map((entry) => ({ ...entry, date: m.date }))).filter((e) => (month === "all" || e.date === month) && `${e.project} ${e.debtor ?? ""}`.toLowerCase().includes(query.toLowerCase())); const total = entries.reduce((sum, e) => sum + e.amount, 0); return
}>
Opening balance{money(board.totals.retentionOpening)}
New retention{money(board.totals.retentionAdded)}
Less planned payouts{money(board.totals.payouts)}
Closing balance{money(board.totals.retentionClosing)}

The release calendar below comes from the separate “Retention 2026” sheet. Its dates and amounts are preserved separately; it is not deducted again from this balance.

{board.months.map((m) => )}
MonthOpeningAdditionsPayoutsClosing
{m.name}{money(m.retentionOpening)}{money(m.retentionAdded)}{money(m.payout)}{money(m.retentionClosing)}

Scheduled releases

November 2025–October 2026 · Separate payout schedule

{compactMoney(board.totals.scheduledPayouts)}

19 scheduled project entries

{board.retentionSchedule.map((m) =>
{dateLabel(m.date)}{m.entries.length ? `${m.entries.length} ${m.entries.length === 1 ? "project" : "projects"}` : "—"}
{m.entries.length === 0 ? "—" : compactMoney(m.total)}

{m.entries.length === 0 ? "No release listed" : m.entries.map((e) => e.project).join(" · ")}

)}
{board.retentionSchedule.map((m) => )}
{entries.map((e) => )}
ProjectDebtor / source noteRelease monthPlanned payout
{e.project}{e.debtor ?? "Not supplied"}{dateLabel(e.date)}{money(e.amount)}
Total in view{money(total)}
{entries.length === 0 &&

No releases match these filters.

}
; }