From 60d6af94e1935bba7260cce3bb53c36baddc58dd Mon Sep 17 00:00:00 2001 From: djmil Date: Wed, 15 Nov 2023 19:44:42 +0100 Subject: [PATCH] GameProposal: Reject --- .../api/GameProposalController.java | 14 ++++++++ webapp/src/api/games.js | 6 ++++ webapp/src/container/Games.css | 34 ++++++++++++------- webapp/src/container/Games.jsx | 4 +-- webapp/src/container/games/action/Accept.jsx | 5 +-- webapp/src/container/games/action/Cancel.jsx | 5 ++- webapp/src/container/games/action/Reject.jsx | 10 ++++-- webapp/src/reducer/games.js | 1 + 8 files changed, 58 insertions(+), 21 deletions(-) diff --git a/backend/src/main/java/djmil/cordacheckers/api/GameProposalController.java b/backend/src/main/java/djmil/cordacheckers/api/GameProposalController.java index 5c32c81..e9af4d6 100644 --- a/backend/src/main/java/djmil/cordacheckers/api/GameProposalController.java +++ b/backend/src/main/java/djmil/cordacheckers/api/GameProposalController.java @@ -76,4 +76,18 @@ public class GameProposalController { return ResponseEntity .ok(canceledGameView); } + + @PutMapping("/{uuid}/reject") + public ResponseEntity reject( + @AuthenticationPrincipal User issuer, + @PathVariable UUID uuid + ) { + final GameView rejectedGameView = cordaClient.gameProposalReject( + issuer.getHoldingIdentity(), + uuid + ); + + return ResponseEntity + .ok(rejectedGameView); + } } \ No newline at end of file diff --git a/webapp/src/api/games.js b/webapp/src/api/games.js index 6cfa0b8..f745ee9 100644 --- a/webapp/src/api/games.js +++ b/webapp/src/api/games.js @@ -31,6 +31,12 @@ export default function useGamesApi(gamesReducer, config) { onPushing: (isPushingGameProposalCancel) => dispatchGames({ type: 'next', isPushingGameProposalCancel }), onSuccess: (canceledGame) => dispatchGames({ type: 'next', gamesList: games.nextGameList(canceledGame), proposal: gamesInitialState.proposal }) }), + + pushGameProposalReject: ({ uuid }) => ifNot(games.isPushingGameProposalReject) && + doPushing(`/api/gameproposal/${uuid}/reject`, 'PUT', null, { + onPushing: (isPushingGameProposalReject) => dispatchGames({ type: 'next', isPushingGameProposalReject }), + onSuccess: (rejectedGame) => dispatchGames({ type: 'next', gamesList: games.nextGameList(rejectedGame), proposal: gamesInitialState.proposal }) + }), } } diff --git a/webapp/src/container/Games.css b/webapp/src/container/Games.css index 7f5ca19..674ec27 100644 --- a/webapp/src/container/Games.css +++ b/webapp/src/container/Games.css @@ -102,9 +102,8 @@ margin: 2px; } -.ActionPanel .Create.ready /* , */ /* OR .game-action.busy */ -{ - background-color:#00b0ff60; +.ActionPanel .Create.ready { /* , */ /* OR .game-action.busy */ + background-color:#00b0ff30; } .ActionPanel .Create.ready:hover { @@ -115,20 +114,29 @@ background-color:#00b0fff0; } -.ActionPanel .Cancel:hover, -.ActionPanel .Reject:hover { - background-color:#ff000030 +.ActionPanel .Cancel.ready, +.ActionPanel .Reject.ready { + background-color:#ffaaaa60 } -.ActionPanel .Cancel:active, -.ActionPanel .Reject:active { - background-color:#ff000080 +.ActionPanel .Cancel.ready:hover, +.ActionPanel .Reject.ready:hover { + background-color:#ff000060 } -.ActionPanel .Accept:hover { - background-color: #00af0030; +.ActionPanel .Cancel.ready:active, +.ActionPanel .Reject.ready:active { + background-color:#ff0000a0 } -.ActionPanel .Accept:active { - background-color:#00af0080; +.ActionPanel .Accept.ready { + background-color: #00af0018; +} + +.ActionPanel .Accept.ready:hover { + background-color:#00af0060; +} + +.ActionPanel .Accept.ready:active { + background-color:#00af00a0; } \ No newline at end of file diff --git a/webapp/src/container/Games.jsx b/webapp/src/container/Games.jsx index 8558afb..264c599 100644 --- a/webapp/src/container/Games.jsx +++ b/webapp/src/container/Games.jsx @@ -97,8 +97,8 @@ function ActionPanel({ players, gamesApi }) { } /> , - , - gamesApi.pushGameProposalCancel({ uuid })} /> + gamesApi.pushGameProposalReject({ uuid })} />, + gamesApi.pushGameProposalCancel({ uuid })} /> ]} /> , , ]} /> , ]} /> diff --git a/webapp/src/container/games/action/Accept.jsx b/webapp/src/container/games/action/Accept.jsx index 7a27b17..cd8cac3 100644 --- a/webapp/src/container/games/action/Accept.jsx +++ b/webapp/src/container/games/action/Accept.jsx @@ -1,14 +1,15 @@ import React, { useContext } from 'react'; import { GamesContext } from '../../../context/games'; -export default function Accept() { +export default function Accept({ onClick }) { const games = useContext(GamesContext); const selectedGame = games.findGame({ uuid: games.proposal.selectedUUID }); + const isReady = selectedGame?.status === 'GAME_PROPOSAL_WAIT_FOR_YOU' ? true : ''; if (selectedGame?.status !== 'GAME_PROPOSAL_WAIT_FOR_OPPONENT') return ( - ) diff --git a/webapp/src/container/games/action/Cancel.jsx b/webapp/src/container/games/action/Cancel.jsx index b66d6db..76341f8 100644 --- a/webapp/src/container/games/action/Cancel.jsx +++ b/webapp/src/container/games/action/Cancel.jsx @@ -6,10 +6,13 @@ export default function Cancel({ onClick }) { const games = useContext(GamesContext); const selectedGame = games.findGame({ uuid: games.proposal.selectedUUID }); + const isReady = selectedGame?.status === 'GAME_PROPOSAL_WAIT_FOR_OPPONENT' ? true : ''; if (selectedGame?.status === 'GAME_PROPOSAL_WAIT_FOR_OPPONENT') return ( - ) diff --git a/webapp/src/container/games/action/Reject.jsx b/webapp/src/container/games/action/Reject.jsx index c8672d9..b88e28b 100644 --- a/webapp/src/container/games/action/Reject.jsx +++ b/webapp/src/container/games/action/Reject.jsx @@ -1,15 +1,19 @@ import React, { useContext } from 'react'; +import Wobler from '../../../components/Wobler'; import { GamesContext } from '../../../context/games'; -export default function Reject() { +export default function Reject({ onClick }) { const games = useContext(GamesContext); const selectedGame = games.findGame({ uuid: games.proposal.selectedUUID }); + const isReady = selectedGame?.status === 'GAME_PROPOSAL_WAIT_FOR_YOU' ? true : ''; if (selectedGame?.status !== 'GAME_PROPOSAL_WAIT_FOR_OPPONENT') return ( - ) } \ No newline at end of file diff --git a/webapp/src/reducer/games.js b/webapp/src/reducer/games.js index c3b8d14..3700265 100644 --- a/webapp/src/reducer/games.js +++ b/webapp/src/reducer/games.js @@ -28,6 +28,7 @@ export const gamesInitialState = { isPollingGamesList: false, isPushingNewGame: false, isPushingGameProposalCancel: false, + isPushingGameProposalReject: false, findGame, nextGameList,