better-auth-dashboard
Version:
A better-Auth powered admin dashboard.
52 lines (51 loc) • 2.08 kB
JavaScript
"use client";
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { Building2, FileSliders, Home, Search, Settings, ShieldCheck, Users, } from "lucide-react";
import { useEffect, useState } from "react";
export const AppSidebar = ({ components, path, }) => {
const [pathname, setPathname] = useState("");
const { Sidebar, SidebarContent, SidebarGroup, SidebarGroupLabel, SidebarGroupContent, SidebarMenu, SidebarMenuButton, SidebarMenuItem, } = components;
const items = [
{
title: "Home",
url: `${path}`,
icon: Home,
},
{
title: "Search",
url: `${path}/search`,
icon: Search,
},
{
title: "Users",
url: `${path}/users`,
icon: Users,
},
{
title: "Organizations",
url: `${path}/organizations`,
icon: Building2,
},
{
title: "Route protection",
url: `${path}/route-protection`,
icon: ShieldCheck,
},
{
title: "Plugin Configuration",
url: `${path}/plugin-config`,
icon: FileSliders,
},
{
title: "Settings",
url: `${path}/settings`,
icon: Settings,
},
];
useEffect(() => {
setPathname(typeof window !== "undefined" ? window.location.pathname : "");
}, []);
return (_jsx(Sidebar, { children: _jsx(SidebarContent, { children: _jsxs(SidebarGroup, { children: [_jsx(SidebarGroupLabel, { children: "Admin Dashboard" }), _jsx(SidebarGroupContent, { children: _jsx(SidebarMenu, { children: items.map((item) => {
return (_jsx(SidebarMenuItem, { children: _jsx(SidebarMenuButton, { asChild: true, isActive: pathname === item.url, suppressHydrationWarning: true, children: _jsxs("a", { href: item.url, children: [_jsx(item.icon, {}), _jsx("span", { children: item.title })] }) }) }, item.title));
}) }) })] }) }) }));
};