'use client'; import { useState, useEffect } from 'react'; import { useRouter, usePathname } from 'next/navigation'; import Link from 'next/link'; const NAV = [ { label: 'Dashboard', href: '/dashboard' }, { label: 'Invoices', href: '/invoices' }, { label: 'Payments', href: '/payments' }, { label: 'Tickets', href: '/tickets' }, { label: 'Profile', href: '/profile' }, ]; export default function PortalLayout({ children }: { children: React.ReactNode }) { const router = useRouter(); const pathname = usePathname(); const [client, setClient] = useState(null); useEffect(() => { const token = localStorage.getItem('portalToken'); const clientData = localStorage.getItem('portalClient'); if (!token) { router.push('/login'); return; } if (clientData) setClient(JSON.parse(clientData)); }, [router]); function handleLogout() { localStorage.removeItem('portalToken'); localStorage.removeItem('portalClient'); router.push('/login'); } return (
{/* Header */}
FiberOps Portal
{client && {client.firstName} {client.lastName}}
{/* Nav tabs */}
{children}
); }