diff --git a/src/games/GamesBrowser.tsx b/src/games/GamesBrowser.tsx index e524170..3ce8573 100644 --- a/src/games/GamesBrowser.tsx +++ b/src/games/GamesBrowser.tsx @@ -11,9 +11,7 @@ function GamesBrowser() { const { user } = useUser(); const [opened, setOpened] = useState(undefined); function handleChapterClick(id: string) { - setOpened(prev => ( - prev === id ? undefined : id - )); + setOpened(prev => prev === id ? undefined : id); } return
{games.map((chapter) => ( @@ -38,9 +36,7 @@ function ChapterDisplay({ chapter, user, handleClick, expanded }: { const [opened, setOpened] = useState(undefined); const progress = getPercentageComplete(chapter, user?.tests); function handleTitleClick(id: string) { - setOpened(prev => ( - prev === id ? undefined : id - )); + setOpened(prev => prev === id ? undefined : id); } return
handleClick(chapter.chapter)}> @@ -103,13 +99,13 @@ function getPercentageComplete( tests: undefined | AT.TestResult[], ): "not logged in" | number { if (!tests) return "not logged in"; - console.log({ tests, chapter }); try { const chapterTestIds = chapter.items.map(gr => gr.id); const userCompletedIds = tests.map(t => t.id); const required = chapterTestIds.length; + console.log({ chapterTestIds, userCompletedIds }) const completed = chapterTestIds - .filter(userCompletedIds.includes) + .filter(x => userCompletedIds.includes(x)) .length; return Math.round(