import { RequireActiveTenancy } from "@wacht/react-router";
import { CreateOrganizationForm } from "./CreateOrganizationForm"; // Assume this is your UI
import { Sidebar } from "./Sidebar";
import { Outlet } from "react-router";
export default function DashboardLayout() {
// If no organizational context is active, we render an onboarding
// prompt INSTEAD of crashing the dashboard.
const fallbackUI = (
<div className="flex flex-col items-center justify-center min-h-screen text-center p-4">
<h2 className="font-extrabold text-3xl mb-4 text-zinc-900">Welcome to Acme</h2>
<p className="mb-8 text-zinc-500">Please create an organization to access your dashboard metrics.</p>
<div className="w-full max-w-sm">
<CreateOrganizationForm />
</div>
</div>
);
return (
<RequireActiveTenancy fallback={fallbackUI}>
{/*
Everything rendered inside this closure is mathematically guaranteed
by Wacht to have an active organization ID available in the session.
*/}
<div className="flex h-screen bg-zinc-50">
<Sidebar />
<main className="flex-1 overflow-y-auto p-8"><Outlet /></main>
</div>
</RequireActiveTenancy>
);
}