'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 (
Supporting you through every step
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.
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.
Create a workspace to get started
You can add family members later from Settings