Fix Binary Search Magic Trick
Deactivate "Reveal Number" button until all cards are selected in one-by-one mode.
This commit is contained in:
parent
1dea9c874e
commit
207b77500e
1 changed files with 6 additions and 1 deletions
|
|
@ -124,6 +124,11 @@ const BinarySearchTrick = ({ showSocialShare = true }: BinarySearchTrickProps) =
|
||||||
// Check if at least one card has been selected (present or absent)
|
// Check if at least one card has been selected (present or absent)
|
||||||
const hasAnySelection = Object.values(cardStates).some(state => state !== 'unselected');
|
const hasAnySelection = Object.values(cardStates).some(state => state !== 'unselected');
|
||||||
|
|
||||||
|
// Check if all cards have been committed to in one-by-one mode
|
||||||
|
const allCardsCommitted = isOneByOne
|
||||||
|
? cards.every(card => cardStates[card.id] && cardStates[card.id] !== 'unselected')
|
||||||
|
: hasAnySelection;
|
||||||
|
|
||||||
// Get cards to display based on mode
|
// Get cards to display based on mode
|
||||||
const getDisplayCards = () => {
|
const getDisplayCards = () => {
|
||||||
if (isOneByOne) {
|
if (isOneByOne) {
|
||||||
|
|
@ -315,7 +320,7 @@ const BinarySearchTrick = ({ showSocialShare = true }: BinarySearchTrickProps) =
|
||||||
<div className="flex gap-4">
|
<div className="flex gap-4">
|
||||||
<Button
|
<Button
|
||||||
onClick={calculateResult}
|
onClick={calculateResult}
|
||||||
disabled={!hasAnySelection}
|
disabled={!allCardsCommitted}
|
||||||
size="lg"
|
size="lg"
|
||||||
className="min-w-32"
|
className="min-w-32"
|
||||||
>
|
>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue