import { FC, useEffect, useState } from 'react' import { ArrowDown2, Card, CloseCircle, Element3, HambergerMenu, Logout, ProfileCircle, Receipt1, Setting2, TicketDiscount, Wallet } from 'iconsax-react' import AvatarImage from '../assets/images/avatar_image.png' import { useTranslation } from 'react-i18next' import { Link, useLocation } from 'react-router-dom' import { Pages } from '../config/Pages' import Notifications from '../pages/notification/Notification' import { useSharedStore } from './store/sharedStore' import { useGetProfile } from '../pages/profile/hooks/useProfileData' import { Popover, PopoverButton, PopoverPanel } from '@headlessui/react' import SideBarItem from './SideBarItem' import { useGetWalletBalance } from '../pages/wallet/hooks/useWalletData' import { NumberFormat } from '../config/func' import Search from './components/Search' const Header: FC = () => { const location = useLocation(); const [popoverKey, setPopoverKey] = useState(0); const { t } = useTranslation('global') const { setOpenSidebar, openSidebar } = useSharedStore() const { data } = useGetProfile() const getWalletBalance = useGetWalletBalance() useEffect(() => { setPopoverKey((prevKey) => prevKey + 1); }, [location.pathname]); return (
setOpenSidebar(!openSidebar)} className='xl:hidden block'>
{/* */}
{NumberFormat(getWalletBalance.data?.data?.balance) + ' ' + t('toman')}
{ data && (
{data?.data?.user?.firstName + ' ' + data?.data?.user?.lastName}
setPopoverKey((prevKey) => prevKey + 1)} size={20} color='black' />
{data?.data?.user?.firstName + ' ' + data?.data?.user?.lastName}
{data?.data?.user?.email}
} title={t('header.wallet')} link={Pages.wallet} isActive isWithoutLine />
{t('home.balance')}
{NumberFormat(getWalletBalance.data?.data?.balance) + ' ' + t('toman')}
} title={t('sidebar.transactions')} isActive link={Pages.transactions} isWithoutLine /> } title={t('header.discounts')} isActive link={Pages.discounts} isWithoutLine /> } title={t('header.financial_info')} isActive link={Pages.financial} isWithoutLine /> } title={t('header.profile')} isActive link={Pages.profile} isWithoutLine /> } title={t('header.setting')} isActive link={Pages.setting} isWithoutLine />
} title={t('sidebar.logout')} isActive link={Pages.setting} isWithoutLine isLogout />
) }
) } export default Header