import { useState, type FormEvent } from 'react' import { useNavigate } from 'react-router-dom' import { api, ApiError } from '../api' import { useAuth } from '../auth' export default function SetupPage() { const { onSetupComplete } = useAuth() const navigate = useNavigate() const [username, setUsername] = useState('') const [password, setPassword] = useState('') const [error, setError] = useState(null) const [busy, setBusy] = useState(false) async function submit(e: FormEvent) { e.preventDefault() setBusy(true) setError(null) try { const { user } = await api.setup(username, password) onSetupComplete(user) navigate('/library', { replace: true }) } catch (err) { setError(err instanceof ApiError ? err.detail ?? err.code : 'Something went wrong') } finally { setBusy(false) } } return (

Welcome to record-shop

Create the admin account to get started.

setUsername(e.target.value)} className="w-full rounded-lg border border-neutral-700 bg-neutral-900 px-3 py-2" autoComplete="username" required minLength={3} />
setPassword(e.target.value)} className="w-full rounded-lg border border-neutral-700 bg-neutral-900 px-3 py-2" autoComplete="new-password" required minLength={8} />
{error &&

{error}

}
) }