import { useState } from 'react' import { useNavigate } from 'react-router-dom' import { useAuth } from './useAuth' export const SetupForm = () => { const [password, setPassword] = useState('') const [confirmPassword, setConfirmPassword] = useState('') const [localError, setLocalError] = useState('') const { setup, error, isLoading } = useAuth() const navigate = useNavigate() const handleSubmit = async (e: React.FormEvent) => { e.preventDefault() setLocalError('') if (password.length < 8) { setLocalError('Password must be at least 8 characters long') return } if (password !== confirmPassword) { setLocalError('Passwords do not match') return } try { await setup({ password }) navigate('/') } catch { // Error is handled by the store } } const displayError = localError || error return (

Set up PaperJet

Create a master password to secure your documents. Make sure you remember it!

setPassword(e.target.value)} disabled={isLoading} />
setConfirmPassword(e.target.value)} disabled={isLoading} />
{displayError && (
{displayError}
)}
) }