import { useState } from 'react' import { createGame, joinGame } from '../api' import type { BotDifficulty } from '../api' import type { Session } from '../types' const BOT_LEVELS: { value: BotDifficulty; label: string; blurb: string }[] = [ { value: 'easy', label: '🐣 Easy', blurb: 'Learns you the ropes' }, { value: 'medium', label: '🐺 Medium', blurb: 'Puts up a fight' }, { value: 'hard', label: '🦁 Hard', blurb: 'Shows no mercy' }, ] // Home is the create/join screen shown when there's no active session. export function Home({ onSession }: { onSession: (s: Session) => void }) { const [name, setName] = useState('') const [code, setCode] = useState('') const [busy, setBusy] = useState(false) const [error, setError] = useState(null) async function run(fn: () => Promise) { setBusy(true) setError(null) try { onSession(await fn()) } catch (e) { setError(e instanceof Error ? e.message : 'something went wrong') } finally { setBusy(false) } } return (
πŸ·πŸ¦”πŸΆπŸ¦©πŸ‰

Super Auto Pets The Board Game

or challenge the computer
{BOT_LEVELS.map((b) => ( ))}
or join a friend
setCode(e.target.value.toUpperCase())} />
{error &&
{error}
}
) }