|
@@ -1,78 +0,0 @@
|
|
-import React, { useState } from "react";
|
|
|
|
-import styled from "styled-components";
|
|
|
|
-import ms from "pretty-ms";
|
|
|
|
-import Loading from "../../util/Loading";
|
|
|
|
-import HeaderAndFooter from "../../util/HeaderAndFooter";
|
|
|
|
-import { dispatch } from "../../../domain/gameStore";
|
|
|
|
-import Button from "../../util/Button";
|
|
|
|
-import { createGame } from "../../../domain/apiMethods";
|
|
|
|
-import Dropdown from "./Dropdown";
|
|
|
|
-
|
|
|
|
-const Container = styled.div`
|
|
|
|
- display: flex;
|
|
|
|
- flex-flow: column-reverse nowrap;
|
|
|
|
- justify-content: space-between;
|
|
|
|
- width: 50%;
|
|
|
|
- align-self: center;
|
|
|
|
-`
|
|
|
|
-
|
|
|
|
-const DropdownContainer = styled.div`
|
|
|
|
- display: flex;
|
|
|
|
- flex-flow: row nowrap;
|
|
|
|
- justify-content: center;
|
|
|
|
- align-items: center;
|
|
|
|
- width: 100%;
|
|
|
|
-`;
|
|
|
|
-
|
|
|
|
-const StartButton = styled(Button)`
|
|
|
|
- margin-bottom: 5px;
|
|
|
|
- width: 100%;
|
|
|
|
-`
|
|
|
|
-
|
|
|
|
-export default () => {
|
|
|
|
- const [loading, setLoading] = useState(false);
|
|
|
|
- const [timer, setTimer] = useState(300);
|
|
|
|
- const [rounds, setRounds] = useState(5);
|
|
|
|
-
|
|
|
|
- if (loading) {
|
|
|
|
- return <Loading/>
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- const onCreateGame = async () => {
|
|
|
|
- setLoading(true);
|
|
|
|
- const gameId = await createGame(timer, rounds);
|
|
|
|
- await dispatch.goToLobby(gameId);
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- return (
|
|
|
|
- <HeaderAndFooter>
|
|
|
|
- <Container>
|
|
|
|
- <DropdownContainer>
|
|
|
|
- <Dropdown
|
|
|
|
- options={{
|
|
|
|
- "30 Seconds": 30,
|
|
|
|
- "5 Minutes": 300,
|
|
|
|
- "1 Hour": 3600,
|
|
|
|
- }}
|
|
|
|
- onChange={setTimer}
|
|
|
|
- >
|
|
|
|
- Round Timer: {ms(timer * 1000)}
|
|
|
|
- </Dropdown>
|
|
|
|
- <Dropdown
|
|
|
|
- options={{
|
|
|
|
- "1 Round": 1,
|
|
|
|
- "5 Rounds": 5,
|
|
|
|
- "10 Rounds": 10,
|
|
|
|
- }}
|
|
|
|
- onChange={setRounds}
|
|
|
|
- >
|
|
|
|
- Rounds: {rounds}
|
|
|
|
- </Dropdown>
|
|
|
|
- </DropdownContainer>
|
|
|
|
- <StartButton onClick={onCreateGame}>
|
|
|
|
- Create New Game
|
|
|
|
- </StartButton>
|
|
|
|
- </Container>
|
|
|
|
- </HeaderAndFooter>
|
|
|
|
- );
|
|
|
|
-}
|
|
|