import { useState, useEffect } from 'react' import { createPortal } from 'react-dom' import { useNavigate } from 'react-router-dom' import { useAuthStore } from '../../store/authStore' import { useInAppNotificationStore } from '../../store/inAppNotificationStore' import { useTranslation } from '../../i18n' import { Bell, Settings, Shield, LogOut } from 'lucide-react' // Mobile-only: a slim strip at the very top of the dashboard with the // notification + profile icons (right-aligned). Scrolls with the page. export default function MobileTopBar() { const { t } = useTranslation() const navigate = useNavigate() const { user, isAuthenticated } = useAuthStore() const unread = useInAppNotificationStore(s => s.unreadCount) const fetchUnreadCount = useInAppNotificationStore(s => s.fetchUnreadCount) const [showProfile, setShowProfile] = useState(false) useEffect(() => { if (isAuthenticated) fetchUnreadCount() }, [isAuthenticated]) return ( <>
{showProfile && createPortal( setShowProfile(false)} />, document.body)} ) } 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 (
e.stopPropagation()} >
{(user?.username || '?')[0].toUpperCase()}

{user?.username}

{user?.email}

{user?.role === 'admin' && ( Admin )}
{user?.role === 'admin' && ( )}
) }