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