diff --git a/src/hooks/useChessGame.ts b/src/hooks/useChessGame.ts index 5a5b1c8..5460cb7 100644 --- a/src/hooks/useChessGame.ts +++ b/src/hooks/useChessGame.ts @@ -149,5 +149,6 @@ export const useChessGame = () => { handlePlyChange, handleToggleDiagram, currentPosition, + generatingPdf, }; }; diff --git a/src/pages/Chessboard.container.tsx b/src/pages/Chessboard.container.tsx deleted file mode 100644 index 049053c..0000000 --- a/src/pages/Chessboard.container.tsx +++ /dev/null @@ -1,23 +0,0 @@ -import { useChessGame } from "#/hooks/useChessGame.ts"; -import Chessboard from "#/pages/Chessboard.tsx"; - -const ChessboardContainer = () => { - const chessGameProps = useChessGame(); - - return ( - - ); -}; - -export default ChessboardContainer; diff --git a/src/pages/Chessboard.tsx b/src/pages/Chessboard.tsx index 4b9dd43..69a0605 100644 --- a/src/pages/Chessboard.tsx +++ b/src/pages/Chessboard.tsx @@ -1,34 +1,23 @@ -import type { ChangeEvent, RefObject } from "react"; import LichessButton from "#/components/LichessButton.tsx"; import PgnViewer from "#/components/PgnViewer.tsx"; import Section from "#/components/Section.tsx"; -import type { IGameState } from "#/reducers/gameReducer.ts"; +import { useChessGame } from "#/hooks/useChessGame.ts"; -interface IProps { - gameState: IGameState; - handleLoadPgn: (e: ChangeEvent) => void; - handleClearGame: () => void; - handleSavePgn: () => void; - handleSavePdf: () => void; - handleToggleClock: () => void; - handleToggleDiagram: () => void; - handlePlyChange: ({ ply, fen }: { ply: number; fen: string }) => void; - fileInputRef: RefObject; - currentPosition: { ply: number; fen: string }; -} +const Chessboard = () => { + const { + gameState, + fileInputRef, + currentPosition, + generatingPdf, + handleLoadPgn, + handleClearGame, + handleSavePgn, + handleSavePdf, + handleToggleClock, + handleToggleDiagram, + handlePlyChange, + } = useChessGame(); -const Chessboard = ({ - gameState, - handleLoadPgn, - handleClearGame, - handleSavePgn, - handleSavePdf, - handleToggleClock, - handleToggleDiagram, - handlePlyChange, - fileInputRef, - currentPosition, -}: IProps) => { return (
@@ -64,7 +53,7 @@ const Chessboard = ({ className="cursor-pointer" type="button" onClick={handleSavePdf} - disabled={!gameState.pgn} + disabled={!gameState.pgn || generatingPdf} > Save PDF diff --git a/src/routes/chessboard.tsx b/src/routes/chessboard.tsx index f6675f2..5d74cac 100644 --- a/src/routes/chessboard.tsx +++ b/src/routes/chessboard.tsx @@ -1,10 +1,10 @@ import { createFileRoute } from "@tanstack/react-router"; -import ChessboardContainer from "#/pages/Chessboard.container.tsx"; +import Chessboard from "#/pages/Chessboard.tsx"; export const Route = createFileRoute("/chessboard")({ component: RouteComponent, }); function RouteComponent() { - return ; + return ; }