more debug
This commit is contained in:
parent
21072755c1
commit
86bf939a1a
|
@ -11,9 +11,7 @@ function GamesBrowser() {
|
||||||
const { user } = useUser();
|
const { user } = useUser();
|
||||||
const [opened, setOpened] = useState<string | undefined>(undefined);
|
const [opened, setOpened] = useState<string | undefined>(undefined);
|
||||||
function handleChapterClick(id: string) {
|
function handleChapterClick(id: string) {
|
||||||
setOpened(prev => (
|
setOpened(prev => prev === id ? undefined : id);
|
||||||
prev === id ? undefined : id
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
return <div>
|
return <div>
|
||||||
{games.map((chapter) => (
|
{games.map((chapter) => (
|
||||||
|
@ -38,9 +36,7 @@ function ChapterDisplay({ chapter, user, handleClick, expanded }: {
|
||||||
const [opened, setOpened] = useState<string | undefined>(undefined);
|
const [opened, setOpened] = useState<string | undefined>(undefined);
|
||||||
const progress = getPercentageComplete(chapter, user?.tests);
|
const progress = getPercentageComplete(chapter, user?.tests);
|
||||||
function handleTitleClick(id: string) {
|
function handleTitleClick(id: string) {
|
||||||
setOpened(prev => (
|
setOpened(prev => prev === id ? undefined : id);
|
||||||
prev === id ? undefined : id
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
return <div className="mb-3">
|
return <div className="mb-3">
|
||||||
<div className="card clickable" onClick={() => handleClick(chapter.chapter)}>
|
<div className="card clickable" onClick={() => handleClick(chapter.chapter)}>
|
||||||
|
@ -103,13 +99,13 @@ function getPercentageComplete(
|
||||||
tests: undefined | AT.TestResult[],
|
tests: undefined | AT.TestResult[],
|
||||||
): "not logged in" | number {
|
): "not logged in" | number {
|
||||||
if (!tests) return "not logged in";
|
if (!tests) return "not logged in";
|
||||||
console.log({ tests, chapter });
|
|
||||||
try {
|
try {
|
||||||
const chapterTestIds = chapter.items.map(gr => gr.id);
|
const chapterTestIds = chapter.items.map(gr => gr.id);
|
||||||
const userCompletedIds = tests.map(t => t.id);
|
const userCompletedIds = tests.map(t => t.id);
|
||||||
const required = chapterTestIds.length;
|
const required = chapterTestIds.length;
|
||||||
|
console.log({ chapterTestIds, userCompletedIds })
|
||||||
const completed = chapterTestIds
|
const completed = chapterTestIds
|
||||||
.filter(userCompletedIds.includes)
|
.filter(x => userCompletedIds.includes(x))
|
||||||
.length;
|
.length;
|
||||||
|
|
||||||
return Math.round(
|
return Math.round(
|
||||||
|
|
Loading…
Reference in New Issue