Files
portabase/src/components/wrappers/dashboard/common/sidebar/menu-sidebar-main.tsx
T

122 lines
4.1 KiB
TypeScript
Raw Normal View History

2025-07-26 14:43:59 +02:00
"use client"
2025-12-06 15:50:23 +01:00
import {
Home,
Settings,
Users,
Layers,
ChartArea,
ShieldHalf,
2026-01-12 21:16:52 +01:00
Building, UserRoundCog, Mail, PackageOpen, Logs, Megaphone, Blocks, Warehouse
2025-12-06 15:50:23 +01:00
} from "lucide-react";
2025-07-26 14:43:59 +02:00
import {SidebarGroupItem, SidebarMenuCustomBase} from "@/components/wrappers/dashboard/common/sidebar/menu-sidebar";
import {authClient, useSession} from "@/lib/auth/auth-client";
export const SidebarMenuCustomMain = () => {
const BASE_URL = `/dashboard`;
2025-12-06 15:50:23 +01:00
const {data: activeOrganization} = authClient.useActiveOrganization();
const {data: organizations} = authClient.useListOrganizations();
2025-07-26 14:43:59 +02:00
const {data: session, isPending, error} = authClient.useSession();
const member = authClient.useActiveMember();
if (isPending) return null;
if (error || !session) {
return null;
}
2025-07-29 08:51:50 +02:00
const groupContentApplication: SidebarGroupItem["group_content"] = [
2025-12-06 15:50:23 +01:00
{title: "Dashboard", url: "/home", icon: Home, type: "item"},
2025-07-29 08:51:50 +02:00
];
2025-07-28 16:53:21 +02:00
2025-07-26 14:43:59 +02:00
const groupContent: SidebarGroupItem["group_content"] = [
2025-12-06 15:50:23 +01:00
{title: "Projects", url: "/projects", icon: Layers, details: true, type: "item"},
{title: "Statistics", url: "/statistics", icon: ChartArea, type: "item"},
{title: "Settings", url: "/settings", icon: Settings, details: true, type: "item"}
2025-07-26 14:43:59 +02:00
];
2025-11-01 14:50:08 +01:00
// if (activeOrganization && (member?.data?.role === "admin" || member?.data?.role === "owner")) {
// groupContent.push({ title: "Settings", url: "/settings", icon: Settings, details:true });
// }
2025-07-26 14:43:59 +02:00
const items: SidebarGroupItem[] = [
{
label: "Application",
type: "list",
2025-07-29 08:51:50 +02:00
group_content: groupContentApplication,
},
{
label: "Organization",
type: "list",
2025-07-26 14:43:59 +02:00
group_content: groupContent,
},
];
if (session?.user.role == "admin" || session?.user.role == "superadmin") {
items.push({
label: "Administration",
type: "list",
group_content: [
2025-12-06 15:50:23 +01:00
{
title: "Agents",
url: "/agents",
icon: ShieldHalf,
details: true,
type: "item"
},
2025-12-06 23:14:59 +01:00
{
title: "Notifications",
url: "/notifications",
icon: Megaphone,
details: true,
type: "collapse",
submenu: [
{ title: "Channels", url: "/notifications/channels", icon: Blocks, type: "item" },
{ title: "Activity Logs", url: "/notifications/logs", icon: Logs, type: "item" },
],
},
2026-01-12 21:16:52 +01:00
{
title: "Storages",
url: "/storages",
icon: Warehouse,
details: true,
type: "collapse",
submenu: [
{ title: "Channels", url: "/storages/channels", icon: Blocks, type: "item" },
],
},
2025-12-06 15:50:23 +01:00
{
title: "Access management",
url: "/admin",
icon: UserRoundCog,
details: true,
type: "collapse",
submenu: [
{title: "Users", url: "/admin/users", icon: Users, type: "item"},
{title: "Organizations", url: "/admin/organizations", icon: Building, type: "item"},
],
},
{
title: "Settings",
url: "/admin/settings",
icon: Settings,
details: true,
type: "collapse",
submenu: [
{title: "Email", url: "/admin/settings/email", icon: Mail, type: "item"},
{title: "Storage", url: "/admin/settings/storage", icon: PackageOpen, type: "item"},
],
},
],
});
2025-07-26 14:43:59 +02:00
}
return <SidebarMenuCustomBase baseUrl={BASE_URL} items={items}/>;
};