'use client' import { useState } from 'react' import { useRouter } from 'next/navigation' import { Heart, Shield, ArrowRight } from 'lucide-react' import { Button, Input, Card, showToast } from '@/components/ui' export default function OnboardingPage() { const router = useRouter() const [step, setStep] = useState<'disclaimer' | 'workspace'>('disclaimer') const [workspaceName, setWorkspaceName] = useState('') const [clinicPhone, setClinicPhone] = useState('') const [loading, setLoading] = useState(false) const [error, setError] = useState('') const handleAcceptDisclaimer = () => { setStep('workspace') } const handleCreateWorkspace = async (e: React.FormEvent) => { e.preventDefault() setError('') setLoading(true) try { // Create workspace const createRes = await fetch('/api/workspaces', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ name: workspaceName }), }) const createData = await createRes.json() if (!createRes.ok) { throw new Error(createData.error || 'Failed to create workspace') } // Update with clinic phone if provided if (clinicPhone.trim()) { await fetch(`/api/workspaces/${createData.workspace.id}`, { method: 'PATCH', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ clinicPhone: clinicPhone.trim() }), }) } showToast('All set! Welcome to Next Step.', 'success') router.push('/today') router.refresh() } catch (err) { setError(err instanceof Error ? err.message : 'Something went wrong') } finally { setLoading(false) } } if (step === 'disclaimer') { return (

Important Notice

Next Step is a tracking tool only. It helps you and your family stay organized with appointments and medications.

This app does not provide medical advice.{' '} Always consult your healthcare team for medical decisions.

For emergencies: Call 000 (Australia) or your local emergency services immediately.

If you have questions about your treatment, contact your clinic directly using the button we'll help you set up.

By continuing, you acknowledge that Next Step is for tracking purposes only and does not replace professional medical advice.

) } return (

Set Up Your Plan

Create a workspace to get started

setWorkspaceName(e.target.value)} placeholder="e.g., Grace's Plan" helperText="This is how family members will identify this workspace" required /> setClinicPhone(e.target.value)} placeholder="e.g., 08 9400 1234" helperText="We'll add a 'Call Clinic' button for quick access" /> {error && (

{error}

)}

You can add family members later from Settings

) }