Skip to content

Commit 7cb2b0a

Browse files
committed
Updated makeMove, resetGame, and undoMove to make a call to getGame.
1 parent 6d67874 commit 7cb2b0a

1 file changed

Lines changed: 14 additions & 8 deletions

File tree

src/frontend/Sudoku.React/src/api/apiClient.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,24 +41,30 @@ export const apiClient = {
4141
deleteGame: (alias: string, gameId: string): Promise<void> =>
4242
request(`/api/players/${alias}/games/${gameId}`, { method: 'DELETE' }),
4343

44-
makeMove: (
44+
makeMove: async (
4545
alias: string,
4646
gameId: string,
4747
row: number,
4848
column: number,
4949
value: number | null,
5050
playDuration: string
51-
): Promise<GameModel> =>
52-
request(`/api/players/${alias}/games/${gameId}/actions`, {
51+
): Promise<GameModel> => {
52+
await request(`/api/players/${alias}/games/${gameId}/actions`, {
5353
method: 'PUT',
5454
body: JSON.stringify({ row, column, value, playDuration }),
55-
}),
55+
});
56+
return request(`/api/players/${alias}/games/${gameId}`);
57+
},
5658

57-
resetGame: (alias: string, gameId: string): Promise<GameModel> =>
58-
request(`/api/players/${alias}/games/${gameId}/actions/reset`, { method: 'POST' }),
59+
resetGame: async (alias: string, gameId: string): Promise<GameModel> => {
60+
await request(`/api/players/${alias}/games/${gameId}/actions/reset`, { method: 'POST' });
61+
return request(`/api/players/${alias}/games/${gameId}`);
62+
},
5963

60-
undoMove: (alias: string, gameId: string): Promise<GameModel> =>
61-
request(`/api/players/${alias}/games/${gameId}/actions/undo`, { method: 'POST' }),
64+
undoMove: async (alias: string, gameId: string): Promise<GameModel> => {
65+
await request(`/api/players/${alias}/games/${gameId}/actions/undo`, { method: 'POST' });
66+
return request(`/api/players/${alias}/games/${gameId}`);
67+
},
6268

6369
updateStatus: (alias: string, gameId: string, status: string): Promise<void> =>
6470
request(`/api/players/${alias}/games/${gameId}/status/${status}`, { method: 'PATCH' }),

0 commit comments

Comments
 (0)