GameProposal: Accept
This commit is contained in:
parent
60d6af94e1
commit
cacc8c99d8
@ -90,4 +90,18 @@ public class GameProposalController {
|
|||||||
return ResponseEntity
|
return ResponseEntity
|
||||||
.ok(rejectedGameView);
|
.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 }),
|
onPushing: (isPushingGameProposalReject) => dispatchGames({ type: 'next', isPushingGameProposalReject }),
|
||||||
onSuccess: (rejectedGame) => dispatchGames({ type: 'next', gamesList: games.nextGameList(rejectedGame), proposal: gamesInitialState.proposal })
|
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={[
|
<Route path='proposal' element={[
|
||||||
<Accept key={1} />,
|
<Accept key={1} onClick={(uuid) => gamesApi.pushGameProposalAccept({ uuid })}/>,
|
||||||
<Reject key={2} onClick={(uuid) => gamesApi.pushGameProposalReject({ uuid })} />,
|
<Reject key={2} onClick={(uuid) => gamesApi.pushGameProposalReject({ uuid })} />,
|
||||||
<Cancel key={3} onClick={(uuid) => gamesApi.pushGameProposalCancel({ uuid })} />
|
<Cancel key={3} onClick={(uuid) => gamesApi.pushGameProposalCancel({ uuid })} />
|
||||||
]} />
|
]} />
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import React, { useContext } from 'react';
|
import React, { useContext } from 'react';
|
||||||
|
import Wobler from '../../../components/Wobler';
|
||||||
import { GamesContext } from '../../../context/games';
|
import { GamesContext } from '../../../context/games';
|
||||||
|
|
||||||
export default function Accept({ onClick }) {
|
export default function Accept({ onClick }) {
|
||||||
@ -9,8 +10,10 @@ export default function Accept({ onClick }) {
|
|||||||
|
|
||||||
if (selectedGame?.status !== 'GAME_PROPOSAL_WAIT_FOR_OPPONENT')
|
if (selectedGame?.status !== 'GAME_PROPOSAL_WAIT_FOR_OPPONENT')
|
||||||
return (
|
return (
|
||||||
<button className={'Accept' + (isReady && ' ready')}>
|
<button className={'Accept' + (isReady && ' ready')}
|
||||||
Accept
|
onClick={() => isReady ? onClick(selectedGame.uuid) : alert('You have to select some GameProposal')}
|
||||||
|
>
|
||||||
|
<Wobler text="Accept" dance={games.isPushingGameProposalAccept} />
|
||||||
</button>
|
</button>
|
||||||
)
|
)
|
||||||
}
|
}
|
@ -81,7 +81,6 @@ export async function doPushing(uri, method, data, { onSuccess, onPushing }) {
|
|||||||
? await response.json()
|
? await response.json()
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
console.log("rsponce", response, "content", content);
|
|
||||||
onSuccess(content);
|
onSuccess(content);
|
||||||
}
|
}
|
||||||
// } catch (err) {
|
// } catch (err) {
|
||||||
|
@ -29,6 +29,7 @@ export const gamesInitialState = {
|
|||||||
isPushingNewGame: false,
|
isPushingNewGame: false,
|
||||||
isPushingGameProposalCancel: false,
|
isPushingGameProposalCancel: false,
|
||||||
isPushingGameProposalReject: false,
|
isPushingGameProposalReject: false,
|
||||||
|
isPushingGameProposalAccept: false,
|
||||||
|
|
||||||
findGame,
|
findGame,
|
||||||
nextGameList,
|
nextGameList,
|
||||||
|
Loading…
Reference in New Issue
Block a user