diff options
| author | IT Fixcomart <it@fixcomart.co.id> | 2024-08-01 09:21:35 +0000 |
|---|---|---|
| committer | IT Fixcomart <it@fixcomart.co.id> | 2024-08-01 09:21:35 +0000 |
| commit | 4eab7ee5ce33b73a7c6d4fb6311af1f29afd0f93 (patch) | |
| tree | d48a05c1586c2dcb403b2abacd5a970b06887f67 /src-migrate/modules/product-detail/components/AddToCart.tsx | |
| parent | 7907b4a3acd3f5f4270f2ac1743600bc7a077503 (diff) | |
| parent | 42829a0907590139ecf4328a7a9ff9f6504a9113 (diff) | |
Merged in Feature/iman-cart-popup (pull request #199)
Feature/iman cart popup
Diffstat (limited to 'src-migrate/modules/product-detail/components/AddToCart.tsx')
| -rw-r--r-- | src-migrate/modules/product-detail/components/AddToCart.tsx | 13 |
1 files changed, 7 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..644d5b90 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,8 @@ const AddToCart = ({ active={addCartAlert} close={() => { setAddCartAlert(false); - setTimeout(() => { - window.location.reload(); - }, 1500); - }} + } + } > <div className='flex mt-4'> <div className='w-[10%]'> |
