'use client' import React, { useState } from 'react' import { Header } from '../common/Header' import { useAuth } from '@/lib/hooks/useAuth' import { useRouter, usePathname } from 'next/navigation' import { Link } from '../common/Link' export interface DashboardLayoutProps { children: React.ReactNode } export const DashboardLayout = ({ children }: DashboardLayoutProps) => { const { user, isAuthenticated, logout } = useAuth() const router = useRouter() const pathname = usePathname() const [sidebarOpen, setSidebarOpen] = useState(false) // Redirect to login if not authenticated React.useEffect(() => { if (!isAuthenticated) { router.push('/login') } }, [isAuthenticated, router]) const handleLogin = () => { router.push('/login') } const sidebarItems = [ { label: 'Overview', href: '/dashboard', icon: '📊' }, { label: 'Profile', href: '/dashboard/profile', icon: '👤' }, { label: 'Preferences', href: '/dashboard/preferences', icon: '⚙️' }, { label: 'Security', href: '/dashboard/security', icon: '🔒' }, { label: 'Privacy', href: '/dashboard/privacy', icon: '🛡️' }, ] if (!isAuthenticated) { return null // or a loading spinner } return (
{/* Sidebar for desktop */} {/* Mobile sidebar */} {sidebarOpen && (
setSidebarOpen(false)} />
Dashboard
)} {/* Main content */}
{/* Mobile sidebar toggle */}
{children}
) }