mirror of
https://github.com/kuhyx/testsAndMisc-archive.git
synced 2026-11-22 15:42:22 +01:00
The directory has existed on disk with 58 untracked files, four of them over the 250-line cap. An untracked file is invisible to every pre-commit hook, so those violations could not be fixed or gated while it stayed that way -- and its CI workflow was untracked too, so nothing ran against it. Landed with its already-written evidence artifact and a contract, since this crosses the 4-file threshold. Verified before staging: 58 plain text source/config files, no binaries, no node_modules, no build output. npm run check passes -- typecheck, eslint --max-warnings 0, and 220 tests at 100% statements/branches/functions/lines. Splitting its four oversized files is deliberately a separate commit. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011w2Pj4Ek3ZNMQVYcFHgXDY
64 lines
2.0 KiB
TypeScript
64 lines
2.0 KiB
TypeScript
import type { ReactElement } from 'react'
|
|
import type { DebtLoad } from '../stakes/storage'
|
|
import type { SettledDebt } from '../stakes/types'
|
|
import { OutstandingDebtRow } from './OutstandingDebtRow'
|
|
import { taskLabel } from './taskLabel'
|
|
|
|
interface DebtHistoryPanelProps {
|
|
debtLoad: DebtLoad
|
|
onLogDebtProgress: (debtId: string, units: number) => void
|
|
}
|
|
|
|
const reasonLabel = (reason: SettledDebt['reason']): string => (reason === 'bust' ? 'bust' : 'cashed out')
|
|
|
|
/** Cleared debts are read-only history — there is no control to un-pay one. */
|
|
const ClearedDebtRow = ({ debt }: { debt: SettledDebt }): ReactElement => (
|
|
<li>
|
|
<span>
|
|
{taskLabel(debt.taskTypeId)}: {debt.owedUnits} owed ({reasonLabel(debt.reason)}) — cleared
|
|
</span>
|
|
</li>
|
|
)
|
|
|
|
/**
|
|
* The durable ledger, separate from any single session: every `SettledDebt` ever recorded, newest
|
|
* first. Outstanding entries carry the same log-progress control `BuyInScreen`'s gate shows (the
|
|
* shared `OutstandingDebtRow`), so progress can be logged from either place with identical rules.
|
|
*/
|
|
export const DebtHistoryPanel = ({ debtLoad, onLogDebtProgress }: DebtHistoryPanelProps): ReactElement => {
|
|
if (debtLoad.status === 'unreadable') {
|
|
return (
|
|
<div className="panel">
|
|
<h2>Debt history</h2>
|
|
<p>Your debt history could not be read.</p>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
if (debtLoad.debts.length === 0) {
|
|
return (
|
|
<div className="panel">
|
|
<h2>Debt history</h2>
|
|
<p>No debts settled yet.</p>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
const newestFirst = [...debtLoad.debts].sort((a, b) => b.settledAt - a.settledAt)
|
|
|
|
return (
|
|
<div className="panel">
|
|
<h2>Debt history</h2>
|
|
<ul className="debt-list">
|
|
{newestFirst.map((debt) =>
|
|
debt.paidUnits < debt.owedUnits ? (
|
|
<OutstandingDebtRow key={debt.id} debt={debt} onLogDebtProgress={onLogDebtProgress} />
|
|
) : (
|
|
<ClearedDebtRow key={debt.id} debt={debt} />
|
|
),
|
|
)}
|
|
</ul>
|
|
</div>
|
|
)
|
|
}
|