import { Button, Avatar, Dropdown, Label } from '@heroui/react' import { buttonVariants } from '@heroui/styles' import { useEffect, useState } from 'react' import { useSession, signOut } from '../lib/auth-client' import { SunIcon, MoonIcon } from '@heroicons/react/24/outline' import { Link as RouterLink } from 'react-router-dom' export function SiteNavbar() { const { data: session } = useSession() const [theme, setTheme] = useState<'light' | 'dark'>(() => { if (typeof window !== 'undefined') { return document.documentElement.classList.contains('dark') ? 'dark' : 'light' } return 'light' }) useEffect(() => { // Sync theme on mount if needed, but the state is already initialized }, []) const toggleTheme = () => { const nextTheme = theme === 'dark' ? 'light' : 'dark' document.documentElement.classList.remove('light', 'dark') document.documentElement.classList.add(nextTheme) document.documentElement.setAttribute('data-theme', nextTheme) localStorage.setItem('theme', nextTheme) setTheme(nextTheme) } return ( ) }