pass generatingPdf state to checkbox to disable, remove container compoentn for chessboard

This commit is contained in:
2026-06-02 15:24:19 +02:00
parent 9fab5e10f2
commit f841b7aeee
4 changed files with 19 additions and 52 deletions
-23
View File
@@ -1,23 +0,0 @@
import { useChessGame } from "#/hooks/useChessGame.ts";
import Chessboard from "#/pages/Chessboard.tsx";
const ChessboardContainer = () => {
const chessGameProps = useChessGame();
return (
<Chessboard
gameState={chessGameProps.gameState}
handleLoadPgn={chessGameProps.handleLoadPgn}
handleClearGame={chessGameProps.handleClearGame}
handleSavePgn={chessGameProps.handleSavePgn}
handleSavePdf={chessGameProps.handleSavePdf}
handleToggleClock={chessGameProps.handleToggleClock}
handleToggleDiagram={chessGameProps.handleToggleDiagram}
handlePlyChange={chessGameProps.handlePlyChange}
fileInputRef={chessGameProps.fileInputRef}
currentPosition={chessGameProps.currentPosition}
/>
);
};
export default ChessboardContainer;
+16 -27
View File
@@ -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<HTMLInputElement>) => void;
handleClearGame: () => void;
handleSavePgn: () => void;
handleSavePdf: () => void;
handleToggleClock: () => void;
handleToggleDiagram: () => void;
handlePlyChange: ({ ply, fen }: { ply: number; fen: string }) => void;
fileInputRef: RefObject<HTMLInputElement | null>;
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 (
<main className="px-4 pb-8 place-self-center min-h-[calc(100vh-226px)]">
<Section title="Convert PGN to PDF">
@@ -64,7 +53,7 @@ const Chessboard = ({
className="cursor-pointer"
type="button"
onClick={handleSavePdf}
disabled={!gameState.pgn}
disabled={!gameState.pgn || generatingPdf}
>
Save PDF
</button>