LinkedGame.jsx 781 B

12345678910111213141516171819202122232425262728
  1. import React from "react";
  2. import styled from "styled-components";
  3. import { dispatch } from '../../../domain/gameStore';
  4. import { linkGame } from '../../../domain/apiMethods';
  5. import GameCreationForm from '../../util/GameCreationForm';
  6. const LinkedGameContainer = styled.div`
  7. display: flex;
  8. justify-content: center;
  9. margin-top: 1em;
  10. margin-bottom: 1em;
  11. `
  12. const StyledButton = styled.button`
  13. margin-top: 0.5em;
  14. `
  15. export default React.memo(({ linkedGame, gameId }) => (
  16. <LinkedGameContainer>
  17. {
  18. linkedGame
  19. ? <StyledButton onClick={() => dispatch.goToLobby(linkedGame)}>
  20. Continue to Linked Game Lobby
  21. </StyledButton>
  22. : <GameCreationForm afterCreate={linkId => linkGame(gameId, linkId)}/>
  23. }
  24. </LinkedGameContainer>
  25. ));