diff --git a/TODO b/TODO index 26a35de..6b15b09 100644 --- a/TODO +++ b/TODO @@ -10,6 +10,4 @@ - react query on for study and chapter load, to allow caching - https://specification.website/checklist/ -- Custom headers do not work - the subtitle is appearing above every thing on first page, and the game starts 2nd page - - react query to cache the study and chapters \ No newline at end of file diff --git a/src/components/LichessStudyLinkInput.tsx b/src/components/LichessStudyLinkInput.tsx index 00e4eb8..989b457 100644 --- a/src/components/LichessStudyLinkInput.tsx +++ b/src/components/LichessStudyLinkInput.tsx @@ -28,6 +28,8 @@ const LichessStudyLinkInput = ({ setSelectedStudyId }: IProps) => { return; } + console.log(result.data); + setSelectedStudyId(result.data); toast.success("Study loaded — pick a chapter"); }; diff --git a/src/components/SelectStudyChapter.tsx b/src/components/SelectStudyChapter.tsx index 0292323..8aee515 100644 --- a/src/components/SelectStudyChapter.tsx +++ b/src/components/SelectStudyChapter.tsx @@ -2,11 +2,11 @@ import { type Dispatch, useActionState, useEffect, - useRef, + // useRef, useState, } from "react"; import { toast } from "react-toastify"; -import { useClickOutside } from "#/hooks/useClickOutside.ts"; +// import { useClickOutside } from "#/hooks/useClickOutside.ts"; import { useLichess } from "#/hooks/useLichess.ts"; import type { IUserStudyChapter } from "#/interfaces.ts"; import type { GameAction } from "#/reducers/gameReducer.ts"; @@ -31,7 +31,7 @@ const initialChapterState: ChapterState = { const SelectStudyChapter = ({ selectedStudyId, gameDispatch }: IProps) => { const [isOpen, setIsOpen] = useState(false); const [search, setSearch] = useState(""); - const dropdownRef = useRef(null); + // const dropdownRef = useRef(null); const { getLichessStudyChapters, loadLichessStudyChapter } = useLichess(); @@ -47,6 +47,9 @@ const SelectStudyChapter = ({ selectedStudyId, gameDispatch }: IProps) => { const result = await getLichessStudyChapters({ studyId: selectedStudyId, }); + + console.log(result); + if (result.ok) { return { status: "success", @@ -54,6 +57,7 @@ const SelectStudyChapter = ({ selectedStudyId, gameDispatch }: IProps) => { error: null, } satisfies ChapterState; } + return { status: "error", chapters: [], @@ -67,7 +71,7 @@ const SelectStudyChapter = ({ selectedStudyId, gameDispatch }: IProps) => { chapter.name.toLowerCase().includes(search.toLowerCase()), ); - useClickOutside({ isOpen, setIsOpen, setSearch, ref: dropdownRef }); + // useClickOutside({ isOpen, setIsOpen, setSearch, ref: dropdownRef }); useEffect(() => { if (isPending || chapterState.status === "success") { diff --git a/src/pages/Chessboard.tsx b/src/pages/Chessboard.tsx index 4252d73..65ab725 100644 --- a/src/pages/Chessboard.tsx +++ b/src/pages/Chessboard.tsx @@ -65,7 +65,10 @@ const Chessboard = () => { /> ) : null} {user ? ( - +
+

or

+ +
) : null}