Fix Binary Search Magic Trick

Deactivate "Reveal Number" button until all cards are selected in one-by-one mode.
This commit is contained in:
gpt-engineer-app[bot] 2025-07-21 10:18:23 +00:00
parent 1dea9c874e
commit 207b77500e

View file

@ -123,6 +123,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 = () => {
@ -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"
> >