Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions frontend/src/lib/game-of-life/hooks/usePuzzleGame.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,17 @@ export function usePuzzleGame() {
throw new Error(validationResult.errorMessage || "Solution is not valid");
}

return lineraService.submitSolution(currentPuzzle.id, board);
const result = await lineraService.submitSolution(currentPuzzle.id, board);

if (!result) {
setValidationResult({ isValid: false, message: "Incorrect solution, try again" });
} else {
setValidationResult({ isValid: true, message: "Solution submitted successfully!" });
}

return result;
},
onSuccess: () => {
setValidationResult({
isValid: true,
message: "Solution submitted successfully!",
});
// Invalidate queries to refresh completion status from blockchain
queryClient.invalidateQueries({ queryKey: ["completedPuzzles"] });
queryClient.invalidateQueries({
Expand Down Expand Up @@ -222,7 +226,7 @@ export function usePuzzleGame() {
const loadNextPuzzle = useCallback(() => {
if (!currentPuzzleId) return false;

const currentIndex = KNOWN_PUZZLES.findIndex(p => p.id === currentPuzzleId);
const currentIndex = KNOWN_PUZZLES.findIndex((p) => p.id === currentPuzzleId);
if (currentIndex === -1) return false;

// Get next puzzle (cycle to beginning if at end)
Expand All @@ -239,7 +243,7 @@ export function usePuzzleGame() {
const loadPreviousPuzzle = useCallback(() => {
if (!currentPuzzleId) return false;

const currentIndex = KNOWN_PUZZLES.findIndex(p => p.id === currentPuzzleId);
const currentIndex = KNOWN_PUZZLES.findIndex((p) => p.id === currentPuzzleId);
if (currentIndex === -1) return false;

// Get previous puzzle (cycle to end if at beginning)
Expand Down