fix(agency): bypass standard maker sidebar inside projects layout for agency workspaces
This commit is contained in:
@@ -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<boolean | null>(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 <div style={{ height: "100vh", background: "#f6f4f0" }} />;
|
||||
}
|
||||
|
||||
// Agency users provide their own full-screen layouts (e.g. AgencyDashboard)
|
||||
if (isAgency) {
|
||||
return (
|
||||
<>
|
||||
{children}
|
||||
<Toaster position="top-center" />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<div style={{ display: "flex", height: "100vh", background: "#f6f4f0", overflow: "hidden" }}>
|
||||
<div
|
||||
style={{
|
||||
display: "flex",
|
||||
height: "100vh",
|
||||
background: "#f6f4f0",
|
||||
overflow: "hidden",
|
||||
}}
|
||||
>
|
||||
<VIBNSidebar workspace={workspace} />
|
||||
<main style={{ flex: 1, overflow: "auto" }}>
|
||||
{children}
|
||||
</main>
|
||||
<main style={{ flex: 1, overflow: "auto" }}>{children}</main>
|
||||
</div>
|
||||
<Toaster position="top-center" />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user