import { useState } from 'react' import { NavLink, useNavigate } from 'react-router-dom' import { useAddonStore } from '../../store/addonStore' import { useAuthStore } from '../../store/authStore' import { useSettingsStore } from '../../store/settingsStore' import { useTranslation } from '../../i18n' import { Plane, CalendarDays, Globe, Compass, User, Settings, Shield, LogOut, X } from 'lucide-react' import type { LucideIcon } from 'lucide-react' const BASE_ITEMS: { to: string; label: string; icon: LucideIcon; addonId?: string }[] = [ { to: '/trips', label: 'Trips', icon: Plane }, ] const ADDON_NAV: Record = { vacay: { to: '/vacay', label: 'Vacay', icon: CalendarDays }, atlas: { to: '/atlas', label: 'Atlas', icon: Globe }, journey: { to: '/journey', label: 'Journey', icon: Compass }, } export default function BottomNav() { const { t } = useTranslation() const darkMode = useSettingsStore(s => s.settings.dark_mode) const dark = darkMode === true || darkMode === 'dark' || (darkMode === 'auto' && window.matchMedia('(prefers-color-scheme: dark)').matches) const addons = useAddonStore(s => s.addons) const globalAddons = addons.filter(a => a.type === 'global' && a.enabled) const [showProfile, setShowProfile] = useState(false) const items = [...BASE_ITEMS] for (const addon of globalAddons) { const nav = ADDON_NAV[addon.id] if (nav) items.push(nav) } return ( <> {showProfile && setShowProfile(false)} />} ) } function ProfileSheet({ onClose }: { onClose: () => void }) { const { t } = useTranslation() const { user, logout } = useAuthStore() const navigate = useNavigate() const handleNav = (path: string) => { onClose() navigate(path) } const handleLogout = () => { onClose() logout() navigate('/login') } return (
{/* Backdrop */}
{/* Sheet */}
e.stopPropagation()} > {/* Handle */}
{/* User info */}
{(user?.username || '?')[0].toUpperCase()}

{user?.username}

{user?.email}

{user?.role === 'admin' && ( Admin )}
{/* Links */}
{user?.role === 'admin' && ( )}
{/* Logout */}
) }