diff --git a/backend/src/main/java/djmil/cordacheckers/api/GameProposalController.java b/backend/src/main/java/djmil/cordacheckers/api/GameProposalController.java index e9af4d6..490f1d9 100644 --- a/backend/src/main/java/djmil/cordacheckers/api/GameProposalController.java +++ b/backend/src/main/java/djmil/cordacheckers/api/GameProposalController.java @@ -90,4 +90,18 @@ public class GameProposalController { return ResponseEntity .ok(rejectedGameView); } + + @PutMapping("/{uuid}/accept") + public ResponseEntity accept( + @AuthenticationPrincipal User issuer, + @PathVariable UUID uuid + ) { + final GameView acceptedGameView = cordaClient.gameProposalAccept( + issuer.getHoldingIdentity(), + uuid + ); + + return ResponseEntity + .ok(acceptedGameView); + } } \ No newline at end of file diff --git a/webapp/src/api/games.js b/webapp/src/api/games.js index f745ee9..00dd76b 100644 --- a/webapp/src/api/games.js +++ b/webapp/src/api/games.js @@ -31,12 +31,18 @@ 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 }) }), + + pushGameProposalAccept: ({ uuid }) => ifNot(games.isPushingGameProposalAccept) && + doPushing(`/api/gameproposal/${uuid}/accept`, 'PUT', null, { + onPushing: (isPushingGameProposalAccept) => dispatchGames({ type: 'next', isPushingGameProposalAccept }), + onSuccess: (acceptedGame) => dispatchGames({ type: 'next', gamesList: games.nextGameList(acceptedGame), proposal: gamesInitialState.proposal }) + }), } } diff --git a/webapp/src/container/Games.jsx b/webapp/src/container/Games.jsx index 264c599..635ebce 100644 --- a/webapp/src/container/Games.jsx +++ b/webapp/src/container/Games.jsx @@ -96,7 +96,7 @@ function ActionPanel({ players, gamesApi }) { /> } /> , + gamesApi.pushGameProposalAccept({ 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 cd8cac3..a23b0b6 100644 --- a/webapp/src/container/games/action/Accept.jsx +++ b/webapp/src/container/games/action/Accept.jsx @@ -1,4 +1,5 @@ import React, { useContext } from 'react'; +import Wobler from '../../../components/Wobler'; import { GamesContext } from '../../../context/games'; export default function Accept({ onClick }) { @@ -9,8 +10,10 @@ export default function Accept({ onClick }) { if (selectedGame?.status !== 'GAME_PROPOSAL_WAIT_FOR_OPPONENT') return ( - ) } \ No newline at end of file diff --git a/webapp/src/hook/api.js b/webapp/src/hook/api.js index 30fed93..11e4b17 100644 --- a/webapp/src/hook/api.js +++ b/webapp/src/hook/api.js @@ -81,7 +81,6 @@ export async function doPushing(uri, method, data, { onSuccess, onPushing }) { ? await response.json() : null; - console.log("rsponce", response, "content", content); onSuccess(content); } // } catch (err) { diff --git a/webapp/src/reducer/games.js b/webapp/src/reducer/games.js index 3700265..c5b0353 100644 --- a/webapp/src/reducer/games.js +++ b/webapp/src/reducer/games.js @@ -29,6 +29,7 @@ export const gamesInitialState = { isPushingNewGame: false, isPushingGameProposalCancel: false, isPushingGameProposalReject: false, + isPushingGameProposalAccept: false, findGame, nextGameList,