'use client' import { FC, useState } from 'react' import { Profile, MessageText, ShoppingCart, HambergerMenu, Home } from 'iconsax-react' import { useRouter, usePathname } from 'next/navigation' import CategoryModal from './CategoryModal' import { useSharedStore } from '@/share/store/sharedStore' import { useLocalCart } from '@/app/product/hooks/useLocalCart' import { useGetCart } from '@/app/cart/hooks/useCartData' import { PRIMARY_COLOR } from '@/config/const' import ChatbotWidget from '@/app/chatbot/components/ChatbotWidget' const MobileBottomMenu: FC = () => { const router = useRouter() const pathname = usePathname() const [isCategoryModalOpen, setIsCategoryModalOpen] = useState(false) const [isChatbotOpen, setIsChatbotOpen] = useState(false) const { isLogin } = useSharedStore() // Get cart count based on login status const { data: cartData } = useGetCart() const { getLocalCartItemsCount } = useLocalCart() const cartCount = isLogin ? (cartData?.results?.cart?.items_count || 0) : getLocalCartItemsCount() const handleNavigation = (path: string) => { router.push(path) } const menuItems = [ { icon: Profile, label: 'پروفایل', path: '/profile', onClick: () => handleNavigation(isLogin ? '/profile' : '/auth') }, { icon: MessageText, label: 'چت', path: '/profile/chat', onClick: () => setIsChatbotOpen(true) }, { icon: ShoppingCart, label: 'سبد خرید', path: '/cart', badge: cartCount, onClick: () => handleNavigation('/cart') }, { icon: HambergerMenu, label: 'منو', path: '', onClick: () => setIsCategoryModalOpen(!isCategoryModalOpen) }, { icon: Home, label: 'خانه', path: '/', onClick: () => handleNavigation('/') }, ] return ( <> {/* Mobile Bottom Menu */}
{menuItems.map((item, index) => { const IconComponent = item.icon const isActive = item.path ? pathname === item.path : false return ( ) })}
{/* Category Modal */} setIsCategoryModalOpen(false)} /> {/* Chatbot Widget */} setIsChatbotOpen(false)} /> ) } export default MobileBottomMenu