summaryrefslogtreecommitdiff
path: root/sw-ui/src/reducers.ts
blob: f885f642d14fc402de279b37c9d0830757b8233d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { routerReducer } from 'react-router-redux';
import { combineReducers } from 'redux';
import { ApiPlayer } from './api/model';
import { CurrentGameState, EMPTY_CURRENT_GAME } from './redux/currentGame';
import { createCurrentGameReducer } from './redux/currentGame';
import { EMPTY_GAMES, GamesState } from './redux/games';
import { createGamesReducer } from './redux/games';
import { currentUserReducer } from './redux/user';

export type GlobalState = {
  currentGame: CurrentGameState;
  currentUser: ApiPlayer | null;
  games: GamesState;
  routing: any;
}

export const INITIAL_STATE: GlobalState = {
  currentGame: EMPTY_CURRENT_GAME,
  currentUser: null,
  games: EMPTY_GAMES,
  routing: null,
};

export function createReducer() {
  return combineReducers({
    currentGame: createCurrentGameReducer(),
    currentUser: currentUserReducer,
    games: createGamesReducer(),
    routing: routerReducer,
  });
}
bgstack15