import React, { useRef } from "react"; import { Box, Label, Input, Button, Flex, Checkbox } from "theme-ui"; import { useHistory } from "react-router-dom"; import shortid from "shortid"; import { useAuth } from "../contexts/AuthContext"; import useSetting from "../hooks/useSetting"; import Modal from "../components/Modal"; function StartModal({ isOpen, onRequestClose }) { let history = useHistory(); const { password, setPassword } = useAuth(); function handlePasswordChange(event) { setPassword(event.target.value); } const [usePassword, setUsePassword] = useSetting("game.usePassword"); function handleUsePasswordChange(event) { setUsePassword(event.target.checked); } function handleSubmit(event) { event.preventDefault(); if (!usePassword) { setPassword(""); } history.push(`/game/${shortid.generate()}`); } const inputRef = useRef(); function focusInput() { inputRef.current && inputRef.current.focus(); } return ( ); } export default StartModal;