import ms from 'pretty-ms'; import React, { useState } from 'react'; import { createGame } from '../../../domain/apiMethods'; import { MAP_CRUNCH, RANDOM_STREET_VIEW, URBAN } from '../../../domain/genMethods'; import { FROZEN, NORMAL, TIME_BANK } from '../../../domain/ruleSets'; import Loading from '../Loading'; import { Dropdown, DropdownGroup, Item } from './Dropdown'; import styles from './GameCreationForm.module.css'; export default ({ afterCreate }) => { const [ loading, setLoading ] = useState(false); const [ timer, setTimer ] = useState(300); const [ rounds, setRounds ] = useState(5); const [ onlyAmerica, setOnlyAmerica ] = useState(false); const [ genMethod, setGenMethod ] = useState(MAP_CRUNCH); const [ ruleSet, setRuleSet ] = useState(NORMAL); if (loading) { return ; } const onCreateGame = async () => { setLoading(true); const gameId = await createGame(timer, rounds, onlyAmerica, genMethod, ruleSet); if (afterCreate) { afterCreate(gameId); } }; return (
30 Seconds 2 Minutes 5 Minutes 1 Hour 1 Round 3 Rounds 5 Rounds 10 Rounds All Countries Just America Map Crunch Random Street View Urban Centers Normal Time Bank Frozen
); };