'use client'; import React from 'react' import Link from 'next/link' import BottomNavLink from './BottomNavLink' import BottomNavHighlightLink from './BottomNavLinkBig' import PagerIcon from '../icons/PagerIcon' import BagIcon from '../icons/BagIcon' import HeartIcon from '../icons/HeartIcon' import { useParams, usePathname, useRouter } from 'next/navigation' import HomeIcon from '../icons/HomeIcon' import { useTranslation } from 'react-i18next'; import { useCart } from '@/app/[name]/(Dialogs)/cart/hook/useCart'; import { Building } from 'iconsax-react'; import clsx from 'clsx'; import { useGetProfile } from '@/app/[name]/(Profile)/profile/hooks/userProfileData'; import { toast } from '../Toast'; type BottomNavBarProps = { onPagerClick?: () => void; }; function BottomNavBar({ onPagerClick }: BottomNavBarProps) { const params = useParams(); const { name } = params; const pathname = usePathname(); const isHomeRoute = pathname === `/${name}`; const isAboutRoute = pathname.includes('about'); const buildingVariant = React.useMemo(() => { return (isAboutRoute ? 'Bold' : 'Outline') as 'Bold' | 'Outline'; }, [isAboutRoute]); const { isSuccess } = useGetProfile() const router = useRouter() const { t } = useTranslation('common', { keyPrefix: 'BottomNavbar' }); const { items } = useCart(); const cartItemsCount = React.useMemo(() => { return Object.values(items).reduce((total, item) => { return total + (item?.quantity || 0); }, 0); }, [items]); const handleFavoritesClick = (e: React.MouseEvent) => { e.preventDefault(); if (isSuccess) { router.push(`/${name}/favorite`); } else { e.stopPropagation(); toast('ابتدا لاگین کنید', 'error'); router.push(`/${name}/auth`); } } return (
{/* 🔽 Your HTML content inside SVG */} {/* Badge Layer - خارج از SVG - دقیقاً مثل foreignObject */} {cartItemsCount > 0 && (
{cartItemsCount > 99 ? '99+' : cartItemsCount}
{t('Cart')}
)}
) } export default BottomNavBar