diff options
author | jbion <joffrey.bion@amadeus.com> | 2019-05-07 10:21:51 +0200 |
---|---|---|
committer | jbion <joffrey.bion@amadeus.com> | 2019-05-07 10:21:51 +0200 |
commit | dd8b7403fb1cdfba278b1cb097adea1b5bed1410 (patch) | |
tree | 4230af60a00ad344b6583d7a418c51bad9180801 /frontend | |
parent | Fix yarn.lock private URL (diff) | |
download | seven-wonders-dd8b7403fb1cdfba278b1cb097adea1b5bed1410.tar.gz seven-wonders-dd8b7403fb1cdfba278b1cb097adea1b5bed1410.tar.bz2 seven-wonders-dd8b7403fb1cdfba278b1cb097adea1b5bed1410.zip |
Convert index.js to TypeScript
Diffstat (limited to 'frontend')
-rw-r--r-- | frontend/src/index.tsx (renamed from frontend/src/index.js) | 5 | ||||
-rw-r--r-- | frontend/src/reducers.ts | 12 | ||||
-rw-r--r-- | frontend/src/redux/currentGame.ts | 5 | ||||
-rw-r--r-- | frontend/src/redux/games.ts | 5 |
4 files changed, 21 insertions, 6 deletions
diff --git a/frontend/src/index.js b/frontend/src/index.tsx index c7dbd5bb..1733ab26 100644 --- a/frontend/src/index.js +++ b/frontend/src/index.tsx @@ -1,4 +1,3 @@ -// @flow import '@blueprintjs/core/lib/css/blueprint.css'; import 'babel-polyfill'; import React from 'react'; @@ -6,10 +5,10 @@ import ReactDOM from 'react-dom'; import { Provider } from 'react-redux'; import { ConnectedRouter } from 'react-router-redux'; import { Application } from './components/Application'; +import { INITIAL_STATE } from './reducers'; import { configureStore } from './store'; -const initialState = {}; -const { store, history } = configureStore(initialState); +const { store, history } = configureStore(INITIAL_STATE); const rootElement = document.getElementById('root'); if (rootElement) { diff --git a/frontend/src/reducers.ts b/frontend/src/reducers.ts index 679bffe1..f885f642 100644 --- a/frontend/src/reducers.ts +++ b/frontend/src/reducers.ts @@ -1,10 +1,9 @@ -// @flow import { routerReducer } from 'react-router-redux'; import { combineReducers } from 'redux'; import { ApiPlayer } from './api/model'; -import { CurrentGameState } from './redux/currentGame'; +import { CurrentGameState, EMPTY_CURRENT_GAME } from './redux/currentGame'; import { createCurrentGameReducer } from './redux/currentGame'; -import { GamesState } from './redux/games'; +import { EMPTY_GAMES, GamesState } from './redux/games'; import { createGamesReducer } from './redux/games'; import { currentUserReducer } from './redux/user'; @@ -15,6 +14,13 @@ export type GlobalState = { 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(), diff --git a/frontend/src/redux/currentGame.ts b/frontend/src/redux/currentGame.ts index 76006677..5e015d60 100644 --- a/frontend/src/redux/currentGame.ts +++ b/frontend/src/redux/currentGame.ts @@ -9,6 +9,11 @@ export type CurrentGameState = { table: ApiTable | null; } +export const EMPTY_CURRENT_GAME: CurrentGameState = { + turnInfo: null, + table: null, +}; + export function createCurrentGameReducer() { return combineReducers({ turnInfo: turnInfoReducer, diff --git a/frontend/src/redux/games.ts b/frontend/src/redux/games.ts index 5e21211a..4df2f1da 100644 --- a/frontend/src/redux/games.ts +++ b/frontend/src/redux/games.ts @@ -10,6 +10,11 @@ export type GamesState = { current: string | null }; +export const EMPTY_GAMES: GamesState = { + all: Map(), + current: null, +}; + export const createGamesReducer = () => { return combineReducers({ all: allGamesReducer, |