110 lines
3.2 KiB
TypeScript
110 lines
3.2 KiB
TypeScript
import { EmptyPlaceholder } from "@/components/dashboard/empty-placeholder";
|
|
// import { getTenantId } from "@/lib/auth";
|
|
// import { db } from "@/lib/db";
|
|
import { ShieldBan } from "lucide-react";
|
|
import Link from "next/link";
|
|
import { redirect } from "next/navigation";
|
|
// import { UsageBanner } from "./banner";
|
|
import { DesktopSidebar } from "./desktop-sidebar";
|
|
import { MobileSideBar } from "./mobile-sidebar";
|
|
import { TooltipProvider } from "@/components/ui/tooltip";
|
|
import service, { UserDataStorageName } from "@/lib/http/service";
|
|
interface LayoutProps {
|
|
children: React.ReactNode;
|
|
}
|
|
|
|
export default async function Layout({ children }: LayoutProps) {
|
|
// const tenantId = getTenantId();
|
|
|
|
// localStorage.getItem(UserDataStorageName);
|
|
|
|
// const workspace = await db.query.workspaces.findFirst({
|
|
// where: (table, { and, eq, isNull }) =>
|
|
// and(eq(table.tenantId, tenantId), isNull(table.deletedAt)),
|
|
// with: {
|
|
// apis: {
|
|
// where: (table, { isNull }) => isNull(table.deletedAt),
|
|
// },
|
|
// },
|
|
// });
|
|
// if (!workspace) {
|
|
// return redirect("/app/apis");
|
|
// }
|
|
|
|
// await service.post('/api/v1/customer/list/staff', {
|
|
// // email: infoRef.current.email
|
|
// }, {
|
|
// headers: {
|
|
// // 'Authorization': token
|
|
// }
|
|
// }).then(function (result: any) {
|
|
// console.log("result:", result)
|
|
// if (result && result.header.code != 0) {
|
|
// // toast.error(result.header.message)
|
|
// return
|
|
// }
|
|
// }).catch((err: any) => {
|
|
|
|
// });
|
|
|
|
const workspace =
|
|
{
|
|
apis: [
|
|
{
|
|
id: "xxxx",
|
|
name: "1号员工",
|
|
},
|
|
{
|
|
id: "2222222",
|
|
name: "2号员工",
|
|
},
|
|
{
|
|
id: "4444444",
|
|
name: "3号员工",
|
|
}
|
|
],
|
|
enabled: true
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
<>
|
|
<TooltipProvider>
|
|
<div className="relative flex flex-col min-h-screen bg-gray-100 lg:flex-row dark:bg-gray-950">
|
|
{/* <UsageBanner /> */}
|
|
<DesktopSidebar workspace={workspace} className="hidden lg:block" />
|
|
<MobileSideBar className="lg:hidden" />
|
|
<div className="p-4 border-l bg-white border-border lg:w-full lg:p-8 lg:ml-64">
|
|
|
|
{workspace.enabled ? (
|
|
children
|
|
) : (
|
|
<div className="flex items-center justify-center w-full h-full">
|
|
<EmptyPlaceholder className="border-0">
|
|
<EmptyPlaceholder.Icon>
|
|
<ShieldBan />
|
|
</EmptyPlaceholder.Icon>
|
|
<EmptyPlaceholder.Title>This workspace is disabled</EmptyPlaceholder.Title>
|
|
<EmptyPlaceholder.Description>
|
|
Contact{" "}
|
|
<Link
|
|
// href={`mailto:support@unkey.dev?body=workspaceId: ${workspace.id}`}
|
|
href={`mailto:support@unkey.dev?body=workspaceId:`}
|
|
className="underline"
|
|
>
|
|
support@unkey.dev
|
|
</Link>
|
|
</EmptyPlaceholder.Description>
|
|
</EmptyPlaceholder>
|
|
</div>
|
|
)}
|
|
</div>
|
|
</div>
|
|
|
|
</TooltipProvider>
|
|
|
|
</>
|
|
);
|
|
}
|