Skip to content

feat(ui): Default buy-in amount to player balance when below table maximum #139

Description

@bitcoinbrisbane

Problem

When a player joins a table and their balance is less than the maximum buy-in, the buy-in modal defaults to the maximum amount instead of their actual balance. This creates a poor UX where the player must manually adjust the slider/input.

Example:

  • Table max buy-in: $2.00
  • Player balance: $0.80
  • Current behavior: Buy-in defaults to $2.00 (shows red warning, player must adjust)
  • Expected behavior: Buy-in should default to $0.80 (if >= min buy-in)

Current Implementation

In src/components/modals/BuyInModal.tsx:84:

// Initialize buyInAmount with maxBuyInFormatted
const [buyInAmount, setBuyInAmount] = useState(() => maxBuyInFormatted);

This always defaults to the maximum, regardless of player balance.

Proposed Solution

Update the initialization logic to:

const [buyInAmount, setBuyInAmount] = useState(() => {
  // Default to max buy-in, but cap at player balance if lower
  const maxBuyIn = parseFloat(maxBuyInFormatted);
  const balance = balanceFormatted;
  return Math.min(maxBuyIn, balance).toFixed(2);
});

Edge cases to handle:

  • If balance < min buy-in: Default to min (will show error, but still UX improvement)
  • If balance >= max buy-in: Default to max (current behavior)
  • If min <= balance < max: Default to player's balance

Related Issues

This complements the buy-in UX improvements:

Files to Modify

  1. src/components/modals/BuyInModal.tsx - Update buyInAmount initialization (line 84)
  2. Optional: Add unit tests for default buy-in logic

Acceptance Criteria

  • When balance > max buy-in → defaults to max (existing behavior)
  • When balance < max buy-in AND balance >= min → defaults to balance
  • When balance < min buy-in → defaults to min (shows error as expected)
  • Sit & Go games (fixed buy-in) unaffected
  • Slider position reflects the defaulted amount

Additional Context

This improves UX by reducing friction during the join flow. Players with lower balances won't need to manually adjust the amount every time they join a table.

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions