'use client'

import { useEffect } from 'react'
import { useAppStore } from '@/lib/store'
import { Dashboard } from '@/components/dashboard/Dashboard'
import { EditorShell } from '@/components/editor/EditorShell'
import { PreviewView } from '@/components/preview/PreviewView'

export function AppRoot() {
  const view = useAppStore((s) => s.view)
  const boot = useAppStore((s) => s.boot)

  useEffect(() => {
    void boot()
  }, [])

  if (view.name === 'preview') return <PreviewView />
  if (view.name === 'editor') return <EditorShell />
  return <Dashboard />
}
