2023-10-25 18:18:56 +02:00
|
|
|
import './GameSelector.css';
|
|
|
|
import React from 'react';
|
|
|
|
import { useLocation, matchPath } from "react-router";
|
|
|
|
|
|
|
|
import { AppData } from "../../context/data"
|
2023-10-27 11:32:55 +02:00
|
|
|
import { AppContext } from "../../context/app"
|
2023-10-25 18:18:56 +02:00
|
|
|
import Proposal from './GameSelector/GameProposal';
|
|
|
|
|
2023-10-27 11:32:55 +02:00
|
|
|
export default function GameSelector() {
|
2023-10-25 18:18:56 +02:00
|
|
|
const [data] = React.useContext(AppData)
|
2023-10-27 11:32:55 +02:00
|
|
|
const [ctx, dispatchCtx] = React.useContext(AppContext)
|
2023-10-25 18:18:56 +02:00
|
|
|
|
|
|
|
const { pathname } = useLocation();
|
|
|
|
const isProposalPath = matchPath("/game/proposal/*", pathname);
|
2023-10-27 11:32:55 +02:00
|
|
|
const isActivelPath = matchPath("/game/active/*", pathname);
|
|
|
|
const isArchivePath = matchPath("/game/archive/*", pathname);
|
|
|
|
|
|
|
|
console.log("GameSelector appCtx", ctx)
|
|
|
|
|
|
|
|
const onClick_proposal = (selectedGame) => {
|
|
|
|
dispatchCtx({ component: "game-selector", selectedGameProposal: selectedGame })
|
|
|
|
}
|
|
|
|
|
2023-10-27 14:02:01 +02:00
|
|
|
// const onClick_active = (selectedGame) => {
|
|
|
|
// dispatchCtx({ component: "game-selector", selectedActiveGame: selectedGame })
|
|
|
|
// }
|
2023-10-27 11:32:55 +02:00
|
|
|
|
2023-10-27 14:02:01 +02:00
|
|
|
// const onClick_archive = (selectedGame) => {
|
|
|
|
// dispatchCtx({ component: "game-selector", selectedArchiveGame: selectedGame })
|
|
|
|
// }
|
2023-10-25 18:18:56 +02:00
|
|
|
|
|
|
|
if (!data.games)
|
|
|
|
return <div>Loading..</div>
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className='game-selector'>
|
2023-10-27 11:32:55 +02:00
|
|
|
{isProposalPath && <Proposal games={data.games} onClick={onClick_proposal} />}
|
|
|
|
{isActivelPath && <div>TBD #1</div>}
|
|
|
|
{isArchivePath && <div>TBD #2</div>}
|
2023-10-25 18:18:56 +02:00
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|