import React, { useState } from 'react'; import { Avatar, Popover, Stack, UnstyledButton, Group, Text, Divider, } from '@mantine/core'; import { IconUser, IconUsers, IconLogout, IconSettings, } from '@tabler/icons-react'; import { useAuth } from '../../contexts/AuthContext'; import AccountSettings from '../settings/account/AccountSettings'; import AdminDashboard from '../settings/admin/AdminDashboard'; const UserMenu = () => { const [accountSettingsOpened, setAccountSettingsOpened] = useState(false); const [adminDashboardOpened, setAdminDashboardOpened] = useState(false); const [opened, setOpened] = useState(false); const { user, logout } = useAuth(); const handleLogout = () => { logout(); }; return ( <> setOpened((o) => !o)} > {/* User Info Section */} {user.displayName || user.email} {/* Menu Items */} { setAccountSettingsOpened(true); setOpened(false); }} px="sm" py="xs" style={(theme) => ({ borderRadius: theme.radius.sm, '&:hover': { backgroundColor: theme.colorScheme === 'dark' ? theme.colors.dark[5] : theme.colors.gray[0], }, })} > Account Settings {user.role === 'admin' && ( { setAdminDashboardOpened(true); setOpened(false); }} px="sm" py="xs" style={(theme) => ({ borderRadius: theme.radius.sm, '&:hover': { backgroundColor: theme.colorScheme === 'dark' ? theme.colors.dark[5] : theme.colors.gray[0], }, })} > Admin Dashboard )} ({ borderRadius: theme.radius.sm, '&:hover': { backgroundColor: theme.colorScheme === 'dark' ? theme.colors.dark[5] : theme.colors.gray[0], }, })} > Logout setAccountSettingsOpened(false)} /> setAdminDashboardOpened(false)} /> > ); }; export default UserMenu;