'use client' import { useState, useEffect } from 'react' import { useRouter } from 'next/navigation' import { Heart, Shield, ArrowRight, Sparkles, Users, Bell } from 'lucide-react' import { Button, Input, 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 [mounted, setMounted] = useState(false) useEffect(() => { setMounted(true) }, []) 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('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 (
{/* Decorative blobs */}
{/* Logo/Icon */}

Next Step

Supporting you through every step

{/* Disclaimer Card */}

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.

000

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

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 (
{/* Decorative blobs */}
{/* Header */}

Set Up Your Plan

Create a workspace to get started

{/* Form */}
setWorkspaceName(e.target.value)} placeholder="e.g., Grace's Plan" className="input-sanctuary w-full" required />

This is how family members will identify this workspace

setClinicPhone(e.target.value)} placeholder="e.g., 08 9400 1234" className="input-sanctuary w-full pl-10" />

We'll add a quick "Call Clinic" button for easy access

{error && (

{error}

)}

You can add family members later from Settings

) }