'use client' import { useEffect, useRef } from 'react' import Link from 'next/link' import { usePathname, useRouter } from 'next/navigation' import { LogOut, Search, ShieldCheck, User } from 'lucide-react' import { NotificationBell } from '@/components/notifications/bell' import { Avatar } from '@/components/ui/avatar' import { cx } from '@/components/ui/cx' import { MobileShell } from './mobile-shell' import { isActivePath, navItemsFor, searchHrefFor } from './nav-items' const ITEM = 'flex items-center gap-2.5 h-8 px-2.5 rounded-md text-[13px] w-full text-left' const ITEM_ACTIVE = 'bg-surface text-ink font-semibold shadow-chip' const ITEM_IDLE = 'text-ink-3 hover:bg-rule-2' export function AppShell({ role, userName, children, }: { role: string userName: string children: React.ReactNode }) { const pathname = usePathname() const router = useRouter() const items = navItemsFor(role) const searchHref = searchHrefFor(role) const searchRef = useRef(null) const displayName = userName || 'User' const roleLabel = role.replace(/_/g, ' ').replace(/\b\w/g, c => c.toUpperCase()) useEffect(() => { const onKey = (e: KeyboardEvent) => { if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === 'k') { e.preventDefault() searchRef.current?.focus() } } document.addEventListener('keydown', onKey) return () => document.removeEventListener('keydown', onKey) }, []) const logout = async () => { await fetch('/api/auth/logout', { method: 'POST' }) router.push('/login') router.refresh() } const accountActive = pathname === '/account' return (
IMS Setia HSE
{searchHref ? (
) : (
)}
{displayName}
{children}
) }