69 lines
2.2 KiB
TypeScript
69 lines
2.2 KiB
TypeScript
import { Button } from '@/components/ui/button';
|
|
import { Link } from '@tanstack/react-router';
|
|
import { BarChart3, Building2, Home, LayoutDashboard, Shield, Users } from 'lucide-react';
|
|
import type { ReactNode } from 'react';
|
|
|
|
type NavItem = {
|
|
label: string;
|
|
href: string;
|
|
icon: ReactNode;
|
|
};
|
|
|
|
const navItems: NavItem[] = [
|
|
{ label: 'Dashboard', href: '/admin', icon: <LayoutDashboard className="size-4" /> },
|
|
{ label: 'Complejos', href: '/admin/complexes', icon: <Building2 className="size-4" /> },
|
|
{ label: 'Planes', href: '/admin/plans', icon: <BarChart3 className="size-4" /> },
|
|
{ label: 'Usuarios', href: '/admin/users', icon: <Users className="size-4" /> },
|
|
];
|
|
|
|
interface AdminLayoutProps {
|
|
children: ReactNode;
|
|
currentPath: string;
|
|
}
|
|
|
|
export function AdminLayout({ children, currentPath }: AdminLayoutProps) {
|
|
return (
|
|
<div className="flex min-h-[calc(100dvh-4rem)] gap-0">
|
|
<aside className="hidden w-56 shrink-0 border-r border-border/60 md:block">
|
|
<nav className="sticky top-20 flex flex-col gap-1 p-4">
|
|
<div className="mb-4 flex items-center gap-2 px-3">
|
|
<Shield className="size-4 text-emerald-600" />
|
|
<span className="text-xs font-semibold uppercase tracking-wider text-muted-foreground">
|
|
Admin
|
|
</span>
|
|
</div>
|
|
|
|
{navItems.map((item) => {
|
|
const isActive = currentPath === item.href;
|
|
|
|
return (
|
|
<Button
|
|
key={item.href}
|
|
variant={isActive ? 'secondary' : 'ghost'}
|
|
className="justify-start gap-3 rounded-xl"
|
|
asChild
|
|
>
|
|
<Link to={item.href}>
|
|
{item.icon}
|
|
{item.label}
|
|
</Link>
|
|
</Button>
|
|
);
|
|
})}
|
|
|
|
<div className="mt-6 border-t border-border/60 pt-4">
|
|
<Button variant="ghost" className="w-full justify-start gap-3 rounded-xl" asChild>
|
|
<Link to="/">
|
|
<Home className="size-4" />
|
|
Volver a Playzer
|
|
</Link>
|
|
</Button>
|
|
</div>
|
|
</nav>
|
|
</aside>
|
|
|
|
<div className="flex-1 overflow-hidden p-4 sm:p-6 lg:p-8">{children}</div>
|
|
</div>
|
|
);
|
|
}
|