diff --git a/src/components/GameView.js b/src/components/GameView.js index 83ef4513152731bdef597ab8206eedd58b45a4f1..04f12f6376f6001d1c98343d290dcd3b8595e8a6 100644 --- a/src/components/GameView.js +++ b/src/components/GameView.js @@ -21,8 +21,18 @@ export default class GameView extends React.Component { componentDidMount() { let gameId = new URL(window.location.href).searchParams.get("id"); let token = sessionStorage.getItem("token"); - let error = false; - // TODO: redirect to root if the game is not found + + console.log(gameId); + fetch(`${process.env.REACT_APP_API_URL}/game/${gameId}`) + .then(res => { + if (!res.ok) { + throw Error(); + } + }) + .catch(error => { + alert("Game not found"); + window.document.location.href = "/"; + }); // Get game info fetch(`${process.env.REACT_APP_API_URL}/game/${gameId}`) diff --git a/src/components/PlayerlistView.js b/src/components/PlayerlistView.js index 5eeeb64cab57db1228b9bd41f6452e1120ad352a..6967b0e2e0dc25017ff4940710e3d1e4488a6150 100644 --- a/src/components/PlayerlistView.js +++ b/src/components/PlayerlistView.js @@ -58,18 +58,29 @@ export default class PlayerlistView extends React.Component { return false; } - let factionlistItems = this.state.factions.map(faction => { - return ( - <PlayerlistFaction - key={faction.factionId} - faction={faction} - role={this.props.role} - gameId={this.props.gameId} - /> - ); - }); + let factionlistItems = this.state.factions.map(faction => ( + <PlayerlistFaction + key={faction.factionId} + faction={faction} + role={this.props.role} + gameId={this.props.gameId} + /> + )); - return <div className="fade-main">{factionlistItems}</div>; + return ( + <div className="fade-main"> + <div className="sticky"> + <span + id="closeEditGameFormX" + className="close" + onClick={() => this.props.toggleView()} + > + × + </span> + </div> + {factionlistItems} + </div> + ); } }