diff options
author | jbion <joffrey.bion@amadeus.com> | 2019-02-27 03:12:55 +0100 |
---|---|---|
committer | jbion <joffrey.bion@amadeus.com> | 2019-02-27 03:12:55 +0100 |
commit | 8d73d21108738754efd07b63ecc7368fd49502fa (patch) | |
tree | 8755dd1aa9c61e9f473fd6787ba8f3595006f0fa /frontend/src/components/lobby/Lobby.jsx | |
parent | Remove unnecessary Jackson annotation on non-DTOs (diff) | |
download | seven-wonders-8d73d21108738754efd07b63ecc7368fd49502fa.tar.gz seven-wonders-8d73d21108738754efd07b63ecc7368fd49502fa.tar.bz2 seven-wonders-8d73d21108738754efd07b63ecc7368fd49502fa.zip |
Simplify state and reducers
Diffstat (limited to 'frontend/src/components/lobby/Lobby.jsx')
-rw-r--r-- | frontend/src/components/lobby/Lobby.jsx | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/frontend/src/components/lobby/Lobby.jsx b/frontend/src/components/lobby/Lobby.jsx index f352ab83..cc979190 100644 --- a/frontend/src/components/lobby/Lobby.jsx +++ b/frontend/src/components/lobby/Lobby.jsx @@ -3,17 +3,17 @@ import { Button, Classes, Intent } from '@blueprintjs/core'; import { List } from 'immutable'; import React, { Component } from 'react'; import { connect } from 'react-redux'; -import type { Game } from '../../models/games'; -import type { Player } from '../../models/players'; +import type { ApiLobby, ApiPlayer } from '../../api/model'; +import type { GlobalState } from '../../reducers'; import { actions } from '../../redux/actions/lobby'; import { getCurrentGame } from '../../redux/games'; -import { getCurrentPlayer, getPlayers } from '../../redux/players'; +import { getCurrentPlayer } from '../../redux/user'; import { RadialPlayerList } from './RadialPlayerList'; export type LobbyProps = { - currentGame: Game, - currentPlayer: Player, - players: List<Player>, + currentGame: ApiLobby, + currentPlayer: ApiPlayer, + players: List<ApiPlayer>, startGame: () => void, } @@ -24,7 +24,7 @@ class LobbyPresenter extends Component<LobbyProps> { return ( <div> <h2>{currentGame.name + ' — Lobby'}</h2> - <RadialPlayerList players={players} owner={currentGame.owner} currentPlayer={currentPlayer}/> + <RadialPlayerList players={players}/> {currentPlayer.gameOwner && <Button text="START" className={Classes.LARGE} intent={Intent.PRIMARY} icon='play' onClick={startGame} disabled={players.size < 3}/>} </div> @@ -32,13 +32,13 @@ class LobbyPresenter extends Component<LobbyProps> { } } -const mapStateToProps = state => { - const game = getCurrentGame(state.get('games')); +const mapStateToProps = (state: GlobalState) => { + const game = getCurrentGame(state); console.info(game); return { currentGame: game, currentPlayer: getCurrentPlayer(state), - players: game ? getPlayers(state.get('players'), game.players) : new List(), + players: game ? new List(game.players) : new List(), }; }; |