diff options
| author | it-fixcomart <it@fixcomart.co.id> | 2024-08-01 13:40:57 +0700 |
|---|---|---|
| committer | it-fixcomart <it@fixcomart.co.id> | 2024-08-01 13:40:57 +0700 |
| commit | 42829a0907590139ecf4328a7a9ff9f6504a9113 (patch) | |
| tree | 28ef20df9280bdac9d736bc7f5272018dfec0ff8 /src-migrate/modules | |
| parent | 285e91d4b63ca8dbd0a9f55e9c7db8b833749c0a (diff) | |
<iman> update pop up cart
Diffstat (limited to 'src-migrate/modules')
| -rw-r--r-- | src-migrate/modules/product-detail/components/AddToCart.tsx | 5 | ||||
| -rw-r--r-- | src-migrate/modules/product-promo/components/AddToCart.tsx | 12 |
2 files changed, 5 insertions, 12 deletions
diff --git a/src-migrate/modules/product-detail/components/AddToCart.tsx b/src-migrate/modules/product-detail/components/AddToCart.tsx index 42586032..644d5b90 100644 --- a/src-migrate/modules/product-detail/components/AddToCart.tsx +++ b/src-migrate/modules/product-detail/components/AddToCart.tsx @@ -56,7 +56,7 @@ const AddToCart = ({ typeof auth !== 'object' ) return; setAddCartAlert(true); - setRefreshCart(true) + setRefreshCart(true); toast.promise( upsertUserCart({ userId: auth.id, @@ -103,9 +103,6 @@ const AddToCart = ({ active={addCartAlert} close={() => { setAddCartAlert(false); - // setTimeout(() => { - // window.location.reload(); - // }, 1500); } } > diff --git a/src-migrate/modules/product-promo/components/AddToCart.tsx b/src-migrate/modules/product-promo/components/AddToCart.tsx index 488f3f98..aae5cfc0 100644 --- a/src-migrate/modules/product-promo/components/AddToCart.tsx +++ b/src-migrate/modules/product-promo/components/AddToCart.tsx @@ -15,6 +15,7 @@ import Link from 'next/link' import LazyLoad from 'react-lazy-load' import ProductSimilar from '../../../../src/lib/product/components/ProductSimilar'; import { IProductDetail } from '~/types/product'; +import { useProductCartContext } from '@/contexts/ProductCartContext' type Props = { promotion: IPromotion @@ -24,13 +25,13 @@ type Props = { type Status = 'idle' | 'loading' | 'success' const ProductPromoAddToCart = ({product, promotion }: Props) => { - console.log("promotion",promotion) const auth = getAuth() const toast = useToast() const router = useRouter() const [status, setStatus] = useState<Status>('idle') - + const { productCart, setRefreshCart, setProductCart, refreshCart, isLoading, setIsloading } = + useProductCartContext() const productSimilarQuery = [ promotion?.name, `fq=-product_id_i:${promotion.products[0].product_id}`, @@ -58,6 +59,7 @@ const ProductPromoAddToCart = ({product, promotion }: Props) => { }) setStatus('idle') setAddCartAlert(true); + setRefreshCart(true); toast({ title: 'Tambah ke keranjang', description: 'Berhasil menambahkan barang ke keranjang belanja', @@ -66,9 +68,6 @@ const ProductPromoAddToCart = ({product, promotion }: Props) => { isClosable: true, position: 'top', }) - // setTimeout(() => { - // window.location.reload(); - // }, 1500); } useEffect(() => { @@ -116,9 +115,6 @@ const ProductPromoAddToCart = ({product, promotion }: Props) => { active={addCartAlert} close={() => { setAddCartAlert(false); - setTimeout(() => { - window.location.reload(); - }, 1500); }} > <div className='flex mt-4'> |
