testsAndMisc/poker-stakes/src/ui/CashOutPanel.tsx
Krzysztof kuhy Rudnicki 72a5e28456 Track poker-stakes so the file-length cap can reach it
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
2026-08-16 15:19:07 +02:00

34 lines
1.1 KiB
TypeScript

import type { ReactElement } from 'react'
import type { SessionState } from '../engine/session'
import type { BuyIn } from '../stakes/types'
import type { HandPhase } from './useGame'
interface CashOutPanelProps {
session: SessionState
buyIn: BuyIn
handPhase: HandPhase | null
onCashOut: () => void
}
/**
* Visible only between hands — mid-hand `session.stacks` is a stale pre-hand snapshot, and
* `useGame.cashOut` itself refuses mid-hand (the settlement-exploit fix), so this mirrors that
* restriction rather than showing a button that would silently do nothing when clicked.
*/
export const CashOutPanel = ({ session, buyIn, handPhase, onCashOut }: CashOutPanelProps): ReactElement | null => {
if (handPhase?.kind !== 'betweenHands') {
return null
}
const owedIfCashedOutNow = Math.max(0, 2 * buyIn.chips - session.stacks.player)
return (
<div className="panel">
<p>
Current stack: {session.stacks.player} chips. Cashing out now would owe {owedIfCashedOutNow} units.
</p>
<button type="button" className="button button--danger" onClick={onCashOut}>
Leave table
</button>
</div>
)
}