From 54b3b9670995d62c2e11b761911430e4300fa36e Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Tue, 19 Sep 2023 17:08:55 +0700 Subject: popup cart --- src/lib/cart/components/Cartheader.jsx | 127 +++++++++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 src/lib/cart/components/Cartheader.jsx (limited to 'src/lib') diff --git a/src/lib/cart/components/Cartheader.jsx b/src/lib/cart/components/Cartheader.jsx new file mode 100644 index 00000000..1760360d --- /dev/null +++ b/src/lib/cart/components/Cartheader.jsx @@ -0,0 +1,127 @@ +import { useEffect, useState } from 'react' +import { getCartApi } from '../api/CartApi' +import currencyFormat from '@/core/utils/currencyFormat' +import Image from '@/core/components/elements/Image/Image' +import { createSlug } from '@/core/utils/slug' + +const { ShoppingCartIcon } = require('@heroicons/react/24/outline') +const { default: Link } = require('next/link') + +const Cardheader = (cartCount) => { + 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