@@ -1,6 +1,8 @@
|
||||
import { Link, usePage } from '@inertiajs/react';
|
||||
import {
|
||||
Building2,
|
||||
BookOpen,
|
||||
CreditCard,
|
||||
LayoutGrid,
|
||||
Network,
|
||||
Settings2,
|
||||
@@ -24,14 +26,19 @@ import type { NavItem } from '@/types';
|
||||
|
||||
export function AppSidebar() {
|
||||
const { auth } = usePage().props;
|
||||
|
||||
if (!auth.user) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const permissions = auth.permissions ?? [];
|
||||
const mainNavItems: NavItem[] = [
|
||||
{ title: 'Dashboard', href: dashboard(), icon: LayoutGrid },
|
||||
...(!auth.user.is_platform_admin &&
|
||||
auth.permissions.includes('device.view')
|
||||
...(!auth.user.is_platform_admin && permissions.includes('device.view')
|
||||
? [{ title: 'Perangkat', href: '/devices', icon: Network }]
|
||||
: []),
|
||||
...(!auth.user.is_platform_admin &&
|
||||
auth.permissions.includes('device.user.view')
|
||||
permissions.includes('device.user.view')
|
||||
? [
|
||||
{
|
||||
title: 'Users Perangkat',
|
||||
@@ -40,8 +47,22 @@ export function AppSidebar() {
|
||||
},
|
||||
]
|
||||
: []),
|
||||
{
|
||||
title: 'Dokumentasi',
|
||||
href: '/documentation/deployment',
|
||||
icon: BookOpen,
|
||||
},
|
||||
...(!auth.user.is_platform_admin && permissions.includes('license.view')
|
||||
? [
|
||||
{
|
||||
title: 'Lisensi & Tagihan',
|
||||
href: '/billing',
|
||||
icon: CreditCard,
|
||||
},
|
||||
]
|
||||
: []),
|
||||
...(!auth.user.is_platform_admin &&
|
||||
auth.permissions.includes('device.credential.create')
|
||||
permissions.includes('device.credential.create')
|
||||
? [
|
||||
{
|
||||
title: 'Pengaturan Perangkat',
|
||||
@@ -57,11 +78,16 @@ export function AppSidebar() {
|
||||
href: '/administration/tenants',
|
||||
icon: Building2,
|
||||
},
|
||||
{
|
||||
title: 'Order Lisensi',
|
||||
href: '/administration/billing-orders',
|
||||
icon: CreditCard,
|
||||
},
|
||||
]
|
||||
: []),
|
||||
...(!auth.user.is_platform_admin &&
|
||||
auth.user.tenant_id &&
|
||||
auth.permissions.includes('user.view')
|
||||
permissions.includes('user.view')
|
||||
? [
|
||||
{
|
||||
title: 'Users',
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
import { Moon, Sun } from 'lucide-react';
|
||||
import { useAppearance } from '@/hooks/use-appearance';
|
||||
|
||||
export default function PublicThemeToggle() {
|
||||
const { resolvedAppearance, updateAppearance } = useAppearance();
|
||||
const isDark = resolvedAppearance === 'dark';
|
||||
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => updateAppearance(isDark ? 'light' : 'dark')}
|
||||
className="inline-flex size-10 items-center justify-center rounded-lg border border-border bg-background text-foreground transition hover:bg-muted"
|
||||
aria-label={isDark ? 'Gunakan mode terang' : 'Gunakan mode gelap'}
|
||||
title={isDark ? 'Mode terang' : 'Mode gelap'}
|
||||
>
|
||||
{isDark ? <Sun className="size-4" /> : <Moon className="size-4" />}
|
||||
</button>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user