summaryrefslogtreecommitdiff
path: root/sw-ui/src/redux/actions/user.ts
blob: 29c857074f2c7ab3c80f09534cd192a6adca14fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import { Map } from 'immutable';
import { ApiPlayer } from '../../api/model';

export const REQUEST_CHOOSE_USERNAME = 'USER/REQUEST_CHOOSE_USERNAME';
export const SET_CURRENT_PLAYER = 'USER/SET_CURRENT_PLAYER';
export const UPDATE_PLAYERS = 'USER/UPDATE_PLAYERS';

export type RequestChooseUsernameAction = { type: typeof REQUEST_CHOOSE_USERNAME, username: string };
export type SetCurrentPlayerAction = { type: typeof SET_CURRENT_PLAYER, player: ApiPlayer };
export type UpdatePlayersAction = { type: typeof UPDATE_PLAYERS, players: Map<string, ApiPlayer> };

export type PlayerAction = RequestChooseUsernameAction | SetCurrentPlayerAction | UpdatePlayersAction;

export const actions = {
  chooseUsername: (username: string): RequestChooseUsernameAction => ({ type: REQUEST_CHOOSE_USERNAME, username }),
  setCurrentPlayer: (player: ApiPlayer): SetCurrentPlayerAction => ({ type: SET_CURRENT_PLAYER, player }),
};
bgstack15