diff options
| author | it-fixcomart <it@fixcomart.co.id> | 2024-08-01 13:28:41 +0700 |
|---|---|---|
| committer | it-fixcomart <it@fixcomart.co.id> | 2024-08-01 13:28:41 +0700 |
| commit | 285e91d4b63ca8dbd0a9f55e9c7db8b833749c0a (patch) | |
| tree | 4f3036bc324e81af750a8559d149058267c72df1 /src-migrate/modules/product-detail/components | |
| parent | 7dbca25dede6cf213831f45321f5c7a28b4a6122 (diff) | |
<iman> update popup cart
Diffstat (limited to 'src-migrate/modules/product-detail/components')
| -rw-r--r-- | src-migrate/modules/product-detail/components/AddToCart.tsx | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src-migrate/modules/product-detail/components/AddToCart.tsx b/src-migrate/modules/product-detail/components/AddToCart.tsx index b2fed55d..42586032 100644 --- a/src-migrate/modules/product-detail/components/AddToCart.tsx +++ b/src-migrate/modules/product-detail/components/AddToCart.tsx @@ -10,6 +10,7 @@ import LazyLoad from 'react-lazy-load'; import ProductSimilar from '../../../../src/lib/product/components/ProductSimilar'; import { IProductDetail } from '~/types/product'; import ImageNext from 'next/image'; +import { useProductCartContext } from '@/contexts/ProductCartContext' type Props = { variantId: number | null, @@ -31,7 +32,9 @@ const AddToCart = ({ isClosable: true }) const [product, setProducts] = useState(products); - + const { productCart, setRefreshCart, setProductCart, refreshCart, isLoading, setIsloading } = + useProductCartContext() + const productSimilarQuery = [ product?.name, `fq=-product_id_i:${product.id}`, @@ -53,7 +56,7 @@ const AddToCart = ({ typeof auth !== 'object' ) return; setAddCartAlert(true); - + setRefreshCart(true) toast.promise( upsertUserCart({ userId: auth.id, @@ -100,10 +103,11 @@ const AddToCart = ({ active={addCartAlert} close={() => { setAddCartAlert(false); - setTimeout(() => { - window.location.reload(); - }, 1500); - }} + // setTimeout(() => { + // window.location.reload(); + // }, 1500); + } + } > <div className='flex mt-4'> <div className='w-[10%]'> |
