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 Loading from '../Loading'; import OldDropdown, { Dropdown, 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); if (loading) { return ; } const invalidCombo = genMethod === URBAN && onlyAmerica; const onCreateGame = async () => { setLoading(true); const gameId = await createGame(timer, rounds, onlyAmerica, genMethod); if (afterCreate) { afterCreate(gameId); } }; return (
30 Seconds 2 Minutes 5 Minutes 1 Hour Rounds: {rounds} {onlyAmerica ? 'Just America' : 'All Countries'} Generator:{' '} {genMethod === MAP_CRUNCH ? 'Map Crunch' : genMethod === RANDOM_STREET_VIEW ? 'RSV' : 'Urban Centers'}
); };