mirror of
https://github.com/TheRealOwenRees/chess-scribe-website.git
synced 2026-07-23 09:56:57 +00:00
pass generatingPdf state to checkbox to disable, remove container compoentn for chessboard
This commit is contained in:
@@ -149,5 +149,6 @@ export const useChessGame = () => {
|
||||
handlePlyChange,
|
||||
handleToggleDiagram,
|
||||
currentPosition,
|
||||
generatingPdf,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
@@ -1,24 +1,14 @@
|
||||
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 Chessboard = () => {
|
||||
const {
|
||||
gameState,
|
||||
fileInputRef,
|
||||
currentPosition,
|
||||
generatingPdf,
|
||||
handleLoadPgn,
|
||||
handleClearGame,
|
||||
handleSavePgn,
|
||||
@@ -26,9 +16,8 @@ const Chessboard = ({
|
||||
handleToggleClock,
|
||||
handleToggleDiagram,
|
||||
handlePlyChange,
|
||||
fileInputRef,
|
||||
currentPosition,
|
||||
}: IProps) => {
|
||||
} = useChessGame();
|
||||
|
||||
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>
|
||||
|
||||
@@ -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 <ChessboardContainer />;
|
||||
return <Chessboard />;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user