infiniti scroll product list
This commit is contained in:
@@ -4,6 +4,7 @@ import { Heart } from 'iconsax-react'
|
||||
import Image from 'next/image'
|
||||
import { FC, useState } from 'react'
|
||||
import { useAddWishlist, useRemoveWishlist } from '@/app/products/hooks/useProductsData'
|
||||
import { useSharedStore } from '@/share/store/sharedStore'
|
||||
|
||||
type Props = {
|
||||
item?: IProduct
|
||||
@@ -12,6 +13,7 @@ type Props = {
|
||||
|
||||
const ProductCard: FC<Props> = ({ item }) => {
|
||||
|
||||
const { isLogin } = useSharedStore()
|
||||
const [isWished, setIsWished] = useState(item?.isWishlist)
|
||||
|
||||
const { mutate: addWishlist } = useAddWishlist()
|
||||
@@ -19,6 +21,7 @@ const ProductCard: FC<Props> = ({ item }) => {
|
||||
|
||||
|
||||
const handleWish = () => {
|
||||
if (!isLogin) return
|
||||
if (!item?._id || !item?.variants[0]?._id) return
|
||||
|
||||
if (isWished) {
|
||||
|
||||
Reference in New Issue
Block a user