From 54b3b9670995d62c2e11b761911430e4300fa36e Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Tue, 19 Sep 2023 17:08:55 +0700 Subject: popup cart --- .../components/elements/Navbar/NavbarDesktop.jsx | 8 +- src/lib/cart/components/Cartheader.jsx | 127 +++++++++++++++++++++ 2 files changed, 132 insertions(+), 3 deletions(-) create mode 100644 src/lib/cart/components/Cartheader.jsx (limited to 'src') diff --git a/src/core/components/elements/Navbar/NavbarDesktop.jsx b/src/core/components/elements/Navbar/NavbarDesktop.jsx index 2e4b25fc..2bee64f7 100644 --- a/src/core/components/elements/Navbar/NavbarDesktop.jsx +++ b/src/core/components/elements/Navbar/NavbarDesktop.jsx @@ -23,6 +23,7 @@ import { useSession } from 'next-auth/react' import { AuthContext } from '@/pages/_app' import { TopBannerSkeleton } from '../Skeleton/TopBannerSkeleton' import { useProductContext } from '@/contexts/ProductContext' +import Cardheader from '@/lib/cart/components/Cartheader' const Search = dynamic(() => import('./Search')) const TopBanner = dynamic(() => import('./TopBanner'), { @@ -101,7 +102,7 @@ const NavbarDesktop = () => {
-
+
{
Quotation - + {/* {
Belanja - + */} { + const [count, setCardCount] = useState(null) + const [products, setProducts] = useState(null) + + const getCart = async () => { + const listCart = await getCartApi() + setProducts(listCart.products) + } + + useEffect(() => { + getCart() + }, []) + + return ( +
+ +
0 && 'mr-2'}`}> + + {cartCount.cartCount > 0 && ( + + {cartCount.cartCount} + + )} +
+ + Keranjang +
+ Belanja +
+ + {/*
*/} +
+
+
+
Keranjang Belanja
+ + Lihat Semua + +
+
+
+
    + {products && + products?.map((product, index) => ( + <> +
  • +
    +
    + + {product?.name} + +
    +
    + + {' '} +

    + {product.parent.name} +

    + + + {product?.price?.discountPercentage > 0 && ( +
    +
    + {product?.price?.discountPercentage}% +
    +
    + {currencyFormat(product?.price?.price)} +
    +
    + )} +
    +
    + {currencyFormat(product?.price?.priceDiscount)} +
    +
    +
    +
    +
  • + + ))} +
+
+
+ {/*
+ + Buka Keranjang Belanja + +
*/} +
+
+
+ ) +} + +export default Cardheader -- cgit v1.2.3