diff --git a/vibn-frontend/app/[workspace]/projects/layout.tsx b/vibn-frontend/app/[workspace]/projects/layout.tsx index d693d079..ed17b051 100644 --- a/vibn-frontend/app/[workspace]/projects/layout.tsx +++ b/vibn-frontend/app/[workspace]/projects/layout.tsx @@ -1,28 +1,55 @@ "use client"; import { VIBNSidebar } from "@/components/layout/vibn-sidebar"; -import { ReactNode } from "react"; +import { ReactNode, useEffect, useState } from "react"; import { useParams } from "next/navigation"; import { Toaster } from "sonner"; -export default function ProjectsLayout({ - children, -}: { - children: ReactNode; -}) { +export default function ProjectsLayout({ children }: { children: ReactNode }) { const params = useParams(); const workspace = params.workspace as string; + const [isAgency, setIsAgency] = useState(null); + + useEffect(() => { + fetch(`/api/workspaces/${workspace}`, { + credentials: "include", + cache: "no-store", + }) + .then((res) => res.json()) + .then((data) => setIsAgency(!!data.isAgency)) + .catch(() => setIsAgency(false)); + }, [workspace]); + + // While loading, just render the background + if (isAgency === null) { + return
; + } + + // Agency users provide their own full-screen layouts (e.g. AgencyDashboard) + if (isAgency) { + return ( + <> + {children} + + + ); + } + return ( <> -
+
-
- {children} -
+
{children}
); } -