From f78b172836ee9f8e0e824307ec416b7b04c65d97 Mon Sep 17 00:00:00 2001 From: Kevin Thomas Date: Tue, 29 Jul 2025 00:21:47 -0400 Subject: [PATCH 1/3] fix: puzzles 'null' bug --- src/components/Puzzles/Feedback.tsx | 9 +++++-- src/pages/puzzles.tsx | 42 ++++++++++++++++++++++++++++- 2 files changed, 48 insertions(+), 3 deletions(-) diff --git a/src/components/Puzzles/Feedback.tsx b/src/components/Puzzles/Feedback.tsx index 367e8908..d8a73390 100644 --- a/src/components/Puzzles/Feedback.tsx +++ b/src/components/Puzzles/Feedback.tsx @@ -12,6 +12,8 @@ interface Props { getNewGame: () => Promise setStatus: Dispatch> controller: ReturnType + lastAttemptedMove: string | null + setLastAttemptedMove: Dispatch> } export const Feedback: React.FC = ({ @@ -21,6 +23,8 @@ export const Feedback: React.FC = ({ getNewGame, setAndGiveUp, controller: controller, + lastAttemptedMove, + setLastAttemptedMove, }: Props) => { const { targetIndex } = game @@ -37,12 +41,12 @@ export const Feedback: React.FC = ({ Find the best move for **${turn}**! ` const incorrectContent = ` - ##### ${controller.currentNode.san} is incorrect + ##### ${lastAttemptedMove || 'Move'} is incorrect Try again or give up to analyze the board and see the best move. ` const correctContent = ` - ##### Correct! ${controller.currentNode.san} is the best move. + ##### Correct! ${lastAttemptedMove || 'Move'} is the best move. You can now explore and analyze the position by making moves, or train on another position. ` @@ -93,6 +97,7 @@ export const Feedback: React.FC = ({