This commit is contained in:
lingdocs 2021-09-21 16:59:45 -04:00
parent 9ab9302147
commit 75e1b1d30f
1 changed files with 7 additions and 8 deletions

View File

@ -1,7 +1,6 @@
import React, { useState } from "react"; import React, { useState } from "react";
import games from "./games"; import games from "./games";
import { useUser } from "../user-context"; import { useUser } from "../user-context";
import GameDisplay from "./GameDisplay";
function GamesBrowser() { function GamesBrowser() {
const { user } = useUser(); const { user } = useUser();
@ -15,21 +14,21 @@ function GamesBrowser() {
{games.map((chapter) => ( {games.map((chapter) => (
<> <>
<h3 key={chapter.chapter}>{chapter.chapter}</h3> <h3 key={chapter.chapter}>{chapter.chapter}</h3>
{chapter.items.map((record) => { {chapter.items.map(({ id, title, Game }) => {
const done = user && user.tests.some(t => t.id === record.id); const done = user && user.tests.some(t => t.id === id);
const open = opened === record.id; const open = opened === id;
return <div key={record.title}> return <div key={id}>
<div className="d-flex flex-row justify-content-between align-items-center"> <div className="d-flex flex-row justify-content-between align-items-center">
<div> <div>
<h4 className="my-4 clickable" onClick={() => handleTitleClick(record.id)}> <h4 className="my-4 clickable" onClick={() => handleTitleClick(id)}>
{open ? "🞃" : "🞂"} {record.title} {open ? "🞃" : "🞂"} {title}
</h4> </h4>
</div> </div>
<div> <div>
<h4>{done ? "✅" : ""}</h4> <h4>{done ? "✅" : ""}</h4>
</div> </div>
</div> </div>
{open && <record.Game />} {open && <Game />}
</div> </div>
})} })}
</> </>