import React, { useState } from "react";
import styled from "styled-components";
import ms from "pretty-ms";
import Loading from "./Loading";
import Button from "./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 ({ afterCreate }) => {
const [loading, setLoading] = useState(false);
const [timer, setTimer] = useState(300);
const [rounds, setRounds] = useState(5);
const [onlyAmerica, setOnlyAmerica] = useState(false);
if (loading) {
return
}
const onCreateGame = async () => {
setLoading(true);
const gameId = await createGame(timer, rounds, onlyAmerica);
if (afterCreate) {
afterCreate(gameId);
}
};
return (
Round Timer: {ms(timer * 1000)}
Rounds: {rounds}
{onlyAmerica ? "Just America" : "All Countries" }
Create New Game
);
}