'use client'; import { useState, useEffect } from 'react'; import { useRouter, usePathname } from 'next/navigation'; import { motion } from 'framer-motion'; import { auth } from '@/lib/auth'; export function FloatingNavbar() { const router = useRouter(); const pathname = usePathname(); const [isScrolled, setIsScrolled] = useState(false); const [isLoggedIn, setIsLoggedIn] = useState(false); useEffect(() => { const handleScroll = () => { setIsScrolled(window.scrollY > 20); }; // Check authentication status setIsLoggedIn(auth.isAuthenticated()); window.addEventListener('scroll', handleScroll); return () => window.removeEventListener('scroll', handleScroll); }, []); const handleLogout = () => { auth.logout(); setIsLoggedIn(false); router.push('/'); }; const navItems = isLoggedIn ? [ { name: 'Dashboard', href: '/tasks' }, { name: 'New Task', href: '/tasks/new' }, { name: 'Audit Trail', href: '/audit-trail' }, ] : [ { name: 'Home', href: '/' }, { name: 'Features', href: '/#features' }, ]; return (
{navItems.map((item) => ( ))}
{isLoggedIn ? ( <> ) : ( <> )}
); }