'use client' import { useAuth } from '@thedaviddias/auth' import { Button } from '@thedaviddias/design-system/button' import { ArrowLeft, Bell, Github, Shield, User } from 'lucide-react' import Link from 'next/link' import { usePathname, useRouter } from 'next/navigation' import { useEffect } from 'react' import { Card } from '@/components/ui/card' import { analytics } from '@/lib/analytics' const settingsNavigation = [ { name: 'Account', href: '/settings/account', icon: User, description: 'Personal info and security' }, { name: 'Integrations', href: '/settings/integrations', icon: Github, description: 'Connected services' }, { name: 'Privacy', href: '/settings/privacy', icon: Shield, description: 'Data and privacy controls' }, { name: 'Notifications', href: '/settings/notifications', icon: Bell, description: 'Email and alert preferences' } ] interface SettingsLayoutProps { children: React.ReactNode } export default function SettingsLayout({ children }: SettingsLayoutProps) { const { user, isLoaded } = useAuth() const router = useRouter() const pathname = usePathname() // Redirect if not authenticated (but only after auth has loaded) useEffect(() => { if (isLoaded && !user) { router.push('/login?message=Please sign in to access settings') } }, [isLoaded, user, router]) // Show loading state while auth is loading or user is not yet available if (!isLoaded || !user) { return (
Loading...
) } return (
{/* Header */}

Settings

Manage your account settings and preferences

{/* Desktop Sidebar Navigation */}
{/* Mobile Navigation Cards */}
{settingsNavigation.map(item => { const isActive = pathname.startsWith(item.href) const Icon = item.icon return ( !isActive && analytics.settingsTabClick(pathname, item.href, 'settings-mobile') } className="block p-4 text-center space-y-2" >
{item.name}
) })}
{/* Main Content */}
{children}
) }