GameProposal: Accept
This commit is contained in:
parent
60d6af94e1
commit
cacc8c99d8
@ -90,4 +90,18 @@ public class GameProposalController {
|
||||
return ResponseEntity
|
||||
.ok(rejectedGameView);
|
||||
}
|
||||
|
||||
@PutMapping("/{uuid}/accept")
|
||||
public ResponseEntity<GameView> accept(
|
||||
@AuthenticationPrincipal User issuer,
|
||||
@PathVariable UUID uuid
|
||||
) {
|
||||
final GameView acceptedGameView = cordaClient.gameProposalAccept(
|
||||
issuer.getHoldingIdentity(),
|
||||
uuid
|
||||
);
|
||||
|
||||
return ResponseEntity
|
||||
.ok(acceptedGameView);
|
||||
}
|
||||
}
|
@ -37,6 +37,12 @@ export default function useGamesApi(gamesReducer, config) {
|
||||
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 })
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -96,7 +96,7 @@ function ActionPanel({ players, gamesApi }) {
|
||||
/>
|
||||
} />
|
||||
<Route path='proposal' element={[
|
||||
<Accept key={1} />,
|
||||
<Accept key={1} onClick={(uuid) => gamesApi.pushGameProposalAccept({ uuid })}/>,
|
||||
<Reject key={2} onClick={(uuid) => gamesApi.pushGameProposalReject({ uuid })} />,
|
||||
<Cancel key={3} onClick={(uuid) => gamesApi.pushGameProposalCancel({ uuid })} />
|
||||
]} />
|
||||
|
@ -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 (
|
||||
<button className={'Accept' + (isReady && ' ready')}>
|
||||
Accept
|
||||
<button className={'Accept' + (isReady && ' ready')}
|
||||
onClick={() => isReady ? onClick(selectedGame.uuid) : alert('You have to select some GameProposal')}
|
||||
>
|
||||
<Wobler text="Accept" dance={games.isPushingGameProposalAccept} />
|
||||
</button>
|
||||
)
|
||||
}
|
@ -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) {
|
||||
|
@ -29,6 +29,7 @@ export const gamesInitialState = {
|
||||
isPushingNewGame: false,
|
||||
isPushingGameProposalCancel: false,
|
||||
isPushingGameProposalReject: false,
|
||||
isPushingGameProposalAccept: false,
|
||||
|
||||
findGame,
|
||||
nextGameList,
|
||||
|
Loading…
Reference in New Issue
Block a user