diff options
| author | Rafi Zadanly <zadanlyr@gmail.com> | 2023-03-20 17:14:16 +0700 |
|---|---|---|
| committer | Rafi Zadanly <zadanlyr@gmail.com> | 2023-03-20 17:14:16 +0700 |
| commit | d178a520534af7d1cbcc03134034ad8a2327b461 (patch) | |
| tree | 488606d5e19782d2c0942402ab7c6e7c8d16bc1c /src/lib/product/components/Product.jsx | |
| parent | 833488811b4164d7fbdce9bd70e171f06d62bf8d (diff) | |
product detail and cart header
Diffstat (limited to 'src/lib/product/components/Product.jsx')
| -rw-r--r-- | src/lib/product/components/Product.jsx | 37 |
1 files changed, 0 insertions, 37 deletions
diff --git a/src/lib/product/components/Product.jsx b/src/lib/product/components/Product.jsx deleted file mode 100644 index 9521cbe4..00000000 --- a/src/lib/product/components/Product.jsx +++ /dev/null @@ -1,37 +0,0 @@ -import { toast } from 'react-hot-toast' -import useWishlist from '@/lib/wishlist/hooks/useWishlist' -import createOrDeleteWishlistApi from '@/lib/wishlist/api/createOrDeleteWishlistApi' -import ProductDesktop from './ProductDesktop' -import useAuth from '@/core/hooks/useAuth' -import ProductMobile from './ProductMobile' -import { useRouter } from 'next/router' - -const Product = ({ product }) => { - const auth = useAuth() - const router = useRouter() - const { wishlist } = useWishlist({ productId: product?.id }) - - const toggleWishlist = async () => { - if (!auth) { - router.push('/login') - return - } - const data = { product_id: product.id } - await createOrDeleteWishlistApi({ data }) - if (wishlist?.data?.productTotal > 0) { - toast.success('Berhasil menghapus dari wishlist') - } else { - toast.success('Berhasil menambahkan ke wishlist') - } - wishlist.refetch() - } - - return ( - <> - <ProductMobile product={product} wishlist={wishlist} toggleWishlist={toggleWishlist} /> - <ProductDesktop product={product} wishlist={wishlist} toggleWishlist={toggleWishlist} /> - </> - ) -} - -export default Product |
