import { createRootRoute, Link, Outlet } from '@tanstack/react-router'
import { AppLayout } from '../layouts/AppLayout'
import { ErrorBoundary } from '../components/ErrorBoundary'
import { Toaster } from '../components/ui/sonner'
import { Button } from '../components/ui/button'

export const Route = createRootRoute({
  component: () => (
    <>
      <AppLayout>
        <ErrorBoundary>
          <Outlet />
        </ErrorBoundary>
      </AppLayout>
      <Toaster />
    </>
  ),
  notFoundComponent: () => (
    <div className="flex flex-col items-center justify-center gap-4 py-12">
      <h1 className="text-2xl font-bold">Page not found</h1>
      <p className="text-muted-foreground">The page you are looking for does not exist.</p>
      <Button variant="outline" asChild>
        <Link to="/initiatives">Back to Dashboard</Link>
      </Button>
    </div>
  ),
})
