import { useRouteContext } from '@tanstack/react-router' import { ArrowRight, BookOpen, House, MessagesSquare } from 'lucide-react' import { type FormEvent, useState } from 'react' import { Button } from '#/components/ui/button' import { Input } from '#/components/ui/input' import { Label } from '#/components/ui/label' import { authRequest } from './auth-client' import { AuthFrame } from './auth-page' export function OnboardingPage() { const { auth } = useRouteContext({ from: '__root__' }) const [name, setName] = useState(auth.owner?.name ?? '') const [step, setStep] = useState(1) const [pending, setPending] = useState(false) const [error, setError] = useState('') async function finish() { setPending(true) setError('') try { await authRequest({ action: 'onboard', name: name.trim() }) window.location.assign('/') } catch (cause) { setError( cause instanceof Error ? cause.message : 'Unable to save. Please try again.', ) setPending(false) } } async function signOut() { setPending(true) setError('') try { await authRequest({ action: 'logout' }) window.location.assign('/login') } catch (cause) { setError( cause instanceof Error ? cause.message : 'Unable to sign out. Please try again.', ) setPending(false) } } function next(event: FormEvent) { event.preventDefault() if (!name.trim()) return setStep(2) } return (

{step} of 2

{step === 1 ? ( <>

A little context, to start.

Your day, conversations, and reading, together in one place.

setName(event.target.value)} autoComplete="given-name" required maxLength={80} disabled={pending} />
) : ( <>

Start with today.

You can take it one thing at a time.

Home, contacts, notes, reading, and vitals currently use sample data. You can add connections from your profile menu whenever you’re ready.

)} {error && (

{error}

)}
) }