import { ErrorMessage, Field, Form, Formik } from 'formik'; import { Dispatch, useState } from 'react'; import sample from 'lodash/sample' const namePlaceholders = [ 'Alexander the Great', 'Genghis Khan', 'Boudicca', 'Cleopatra', 'Alaric the Visigoth', 'Cyrus the Great', 'Augustus', 'Hannibal', 'Tutankhamen', ] export default function UserSelector({ users, user, selectUser, removeUser, locked }: { users: string[], user?: string, selectUser: Dispatch, removeUser: () => void, locked: boolean }) { const [namePlaceholder] = useState(() => sample(namePlaceholders)) return
{user ? <>Playing as {user} : { const errors: Partial = {} if (values.newUser.length === 0) { errors.newUser = 'Name cannot be blank.' } return errors }} onSubmit={(values) => { selectUser(values.newUser) }} >{() =>
{' '} {' '} }
}
}