From 21dd37521b4af27edea8cb338c3efab665d5a0b7 Mon Sep 17 00:00:00 2001 From: djmil Date: Fri, 27 Oct 2023 12:34:58 +0200 Subject: [PATCH] front: GameHeader: add New gameView - GameActions for each GameView - activate GameAction per relevan GameView --- webapp/src/App.js | 1 + webapp/src/components/Game/GameAction.jsx | 45 ++++++++++++++----- .../components/Game/GameAction/Backward.jsx | 6 +++ .../components/Game/GameAction/DrawAcq.jsx | 6 +++ .../components/Game/GameAction/DrawReq.jsx | 6 +++ .../components/Game/GameAction/Forward.jsx | 6 +++ .../components/Game/GameAction/Surrender.jsx | 6 +++ webapp/src/components/Game/GameHeader.jsx | 1 + webapp/src/components/Game/NewGame.css | 0 webapp/src/components/Game/NewGame.jsx | 21 +++++++++ webapp/src/components/Game/index.jsx | 26 +++++------ 11 files changed, 99 insertions(+), 25 deletions(-) create mode 100644 webapp/src/components/Game/GameAction/Backward.jsx create mode 100644 webapp/src/components/Game/GameAction/DrawAcq.jsx create mode 100644 webapp/src/components/Game/GameAction/DrawReq.jsx create mode 100644 webapp/src/components/Game/GameAction/Forward.jsx create mode 100644 webapp/src/components/Game/GameAction/Surrender.jsx create mode 100644 webapp/src/components/Game/NewGame.css create mode 100644 webapp/src/components/Game/NewGame.jsx diff --git a/webapp/src/App.js b/webapp/src/App.js index c0f7a11..8bda870 100644 --- a/webapp/src/App.js +++ b/webapp/src/App.js @@ -16,6 +16,7 @@ function App() { {/* https://stackoverflow.com/questions/40541994/multiple-path-names-for-a-same-component-in-react-router */} } /> + } /> } /> } /> } /> diff --git a/webapp/src/components/Game/GameAction.jsx b/webapp/src/components/Game/GameAction.jsx index 435b853..8cdbcf9 100644 --- a/webapp/src/components/Game/GameAction.jsx +++ b/webapp/src/components/Game/GameAction.jsx @@ -1,24 +1,45 @@ import './GameAction.css'; import React from 'react'; +import { useLocation, matchPath } from "react-router"; + +import Create from './GameAction/Create'; + +import Reject from './GameAction/Reject'; +import Cancel from './GameAction/Cancel'; +import Accept from './GameAction/Accept'; + +import DrawReq from './GameAction/DrawReq'; +import DrawAcq from './GameAction/DrawAcq'; +import Surrender from './GameAction/Surrender'; + +import Backward from './GameAction/Backward'; +import Forward from './GameAction/Forward'; -import Create from './GameAction/Create' -import Reject from './GameAction/Reject' -import Cancel from './GameAction/Cancel' -import Accept from './GameAction/Accept' // import { AppContext } from '../../context/app' export default function GameAction() { // const [ctx, dispatchCtx] = React.useContext(AppContext) + const { pathname } = useLocation(); + const isNewGamePath = matchPath("/game/new", pathname); + const isProposalPath = matchPath("/game/proposal/*", pathname); + const isActivelPath = matchPath("/game/active/*", pathname); + const isArchivePath = matchPath("/game/archive/*", pathname); + return ( -
-
- - - - -
- {/* {isProposalPath && } */} +
+ {isNewGamePath && } + + {isProposalPath && } + {isProposalPath && } + {isProposalPath && } + + {isActivelPath && } + {isActivelPath && } + {isActivelPath && } + + {isArchivePath && } + {isArchivePath && }
) } \ No newline at end of file diff --git a/webapp/src/components/Game/GameAction/Backward.jsx b/webapp/src/components/Game/GameAction/Backward.jsx new file mode 100644 index 0000000..2cebb00 --- /dev/null +++ b/webapp/src/components/Game/GameAction/Backward.jsx @@ -0,0 +1,6 @@ +import React from 'react'; + +export default function Backward() { + + return +} diff --git a/webapp/src/components/Game/GameAction/DrawAcq.jsx b/webapp/src/components/Game/GameAction/DrawAcq.jsx new file mode 100644 index 0000000..5d1a5af --- /dev/null +++ b/webapp/src/components/Game/GameAction/DrawAcq.jsx @@ -0,0 +1,6 @@ +import React from 'react'; + +export default function DrawAcq() { + + return +} diff --git a/webapp/src/components/Game/GameAction/DrawReq.jsx b/webapp/src/components/Game/GameAction/DrawReq.jsx new file mode 100644 index 0000000..33f147e --- /dev/null +++ b/webapp/src/components/Game/GameAction/DrawReq.jsx @@ -0,0 +1,6 @@ +import React from 'react'; + +export default function DrawReq() { + + return +} diff --git a/webapp/src/components/Game/GameAction/Forward.jsx b/webapp/src/components/Game/GameAction/Forward.jsx new file mode 100644 index 0000000..a9f5380 --- /dev/null +++ b/webapp/src/components/Game/GameAction/Forward.jsx @@ -0,0 +1,6 @@ +import React from 'react'; + +export default function Forward() { + + return +} diff --git a/webapp/src/components/Game/GameAction/Surrender.jsx b/webapp/src/components/Game/GameAction/Surrender.jsx new file mode 100644 index 0000000..fb53cb4 --- /dev/null +++ b/webapp/src/components/Game/GameAction/Surrender.jsx @@ -0,0 +1,6 @@ +import React from 'react'; + +export default function Surrender() { + + return +} diff --git a/webapp/src/components/Game/GameHeader.jsx b/webapp/src/components/Game/GameHeader.jsx index 4b9ffe9..b2ae0b1 100644 --- a/webapp/src/components/Game/GameHeader.jsx +++ b/webapp/src/components/Game/GameHeader.jsx @@ -6,6 +6,7 @@ export default function GameHeader() { return (