import { useShallow } from 'zustand/react/shallow'; import { useLayoutStore } from './store'; import clsx from 'clsx'; import { Button, Dropdown } from 'antd'; import { message } from '@/modules/message'; import { CloseOutlined, CodeOutlined, DashboardOutlined, HomeOutlined, LogoutOutlined, MessageOutlined, ReadOutlined, RocketOutlined, SmileOutlined, SwapOutlined, SwitcherOutlined, UserOutlined, } from '@ant-design/icons'; import { useMemo } from 'react'; import { query } from '../query'; import { useNewNavigate } from '../navicate'; const meun = [ { title: 'Your profile', icon: , link: '/user/profile', }, { title: 'Your orgs', icon: , link: '/org/edit/list', }, { title: 'Site Map', icon: , link: '/map', }, ]; export const LayoutUser = () => { const { open, setOpen, ...store } = useLayoutStore( useShallow((state) => ({ open: state.openUser, // setOpen: state.setOpenUser, me: state.me, switchOrg: state.switchOrg, })), ); const navigate = useNewNavigate(); const items = useMemo(() => { const orgs = store.me?.orgs || []; return orgs.map((item) => { return { label: item, key: item, icon: , }; }); }, [store.me]); return (
{ setOpen(false); }}>
User: {store.me?.username}
{items.length > 0 && ( { store.switchOrg(item.key, 'org'); }, }}> )}
{meun.map((item, index) => { return (
{ if (item.link) { navigate(item.link); setOpen(false); } else { message.info('Coming soon'); } }}>
{item.icon}
{item.title}
); })}
{ query.removeToken(); window.open('/user/login', '_self'); }}>
Login Out
); };