|
@@ -13,7 +13,7 @@ import PreRound from '../pre-round.component';
|
|
|
import GamePanelContainer from "../game-panel.component";
|
|
|
import RoundSummary from '../round-summary.component';
|
|
|
import PlayerScoresContainer from "../player-scores.component";
|
|
|
-import { getGoogleApiKey, createGame, joinGame } from "../../services/ggsh.service";
|
|
|
+import { createGame, joinGame } from "../../services/ggsh.service";
|
|
|
import Loading from "../loading.component";
|
|
|
|
|
|
// TODO I want to break this down into some smaller container components that can handle making the API calls
|
|
@@ -23,7 +23,7 @@ class Game extends React.Component {
|
|
|
super(props);
|
|
|
this.state = {
|
|
|
googleApiKey: null,
|
|
|
- gameState: LOADING,
|
|
|
+ gameState: PRE_GAME,
|
|
|
playerName: null,
|
|
|
gameId: null,
|
|
|
lastRound: null,
|
|
@@ -38,11 +38,6 @@ class Game extends React.Component {
|
|
|
|
|
|
// TODO error handling throughout - at the moment it assumes all calls always succeed
|
|
|
|
|
|
- async componentDidMount() {
|
|
|
- const googleApiKey = await getGoogleApiKey();
|
|
|
- this.setState({ googleApiKey, gameState: PRE_GAME });
|
|
|
- }
|
|
|
-
|
|
|
async handleCreateGame() {
|
|
|
this.setState({ gameState: LOADING });
|
|
|
const { playerName } = this.state;
|
|
@@ -83,18 +78,17 @@ class Game extends React.Component {
|
|
|
}
|
|
|
|
|
|
renderInRound() {
|
|
|
- const { gameId, playerName, googleApiKey } = this.state;
|
|
|
+ const { gameId, playerName } = this.state;
|
|
|
return <GamePanelContainer
|
|
|
gameId={gameId}
|
|
|
playerName={playerName}
|
|
|
- googleApiKey={googleApiKey}
|
|
|
onRoundEnd={lastRound => this.setState({ gameState: POST_ROUND, lastRound })}
|
|
|
onGameEnd={() => this.setState({ gameState: POST_GAME })}
|
|
|
/>
|
|
|
}
|
|
|
|
|
|
renderPostRound() {
|
|
|
- const { googleApiKey, lastRound } = this.state;
|
|
|
+ const { lastRound } = this.state;
|
|
|
const {
|
|
|
roundNum,
|
|
|
selectedPoint,
|
|
@@ -103,7 +97,6 @@ class Game extends React.Component {
|
|
|
totalScore,
|
|
|
} = lastRound;
|
|
|
return <RoundSummary
|
|
|
- googleApiKey={googleApiKey}
|
|
|
roundNum={roundNum}
|
|
|
score={score}
|
|
|
totalScore={totalScore}
|