Files
device-management/resources/js/components/tenant-admin-nav.tsx
T
Wian Drs 1e80be180e
tests / ci (push) Has been cancelled
Initial commit device-management
2026-08-25 09:42:00 +07:00

46 lines
1.5 KiB
TypeScript

import { Link, usePage } from '@inertiajs/react';
import { Building2, Users } from 'lucide-react';
import { cn } from '@/lib/utils';
export function TenantAdminNav({ tenantId }: { tenantId: number }) {
const { auth } = usePage().props;
const base = `/administration/tenants/${tenantId}`;
const allowed = (permission: string) =>
auth.user.is_platform_admin || auth.permissions.includes(permission);
const items = [
{
label: 'Tenant',
href: `${base}/edit`,
icon: Building2,
show: auth.user.is_platform_admin,
},
{
label: 'Users',
href: `${base}/users`,
icon: Users,
show: allowed('user.view'),
},
];
return (
<nav className="flex flex-wrap gap-2 border-b pb-4">
{items
.filter((item) => item.show)
.map((item) => (
<Link
key={item.label}
href={item.href}
className={cn(
'inline-flex items-center gap-2 rounded-md px-3 py-2 text-sm font-medium hover:bg-muted',
location.pathname.startsWith(item.href) &&
'bg-muted text-primary',
)}
>
<item.icon className="size-4" />
{item.label}
</Link>
))}
</nav>
);
}