From 86a715473aca30e277c1857bbcb6e6e9283e13f4 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Wed, 7 Aug 2024 15:22:39 +0700 Subject: update all promo --- .../components/elements/Navbar/NavbarDesktop.jsx | 19 ++++--- .../flashSale/components/FlashSaleNonDisplay.jsx | 66 ++++++++++++++++++++++ 2 files changed, 76 insertions(+), 9 deletions(-) create mode 100644 src/lib/flashSale/components/FlashSaleNonDisplay.jsx (limited to 'src') diff --git a/src/core/components/elements/Navbar/NavbarDesktop.jsx b/src/core/components/elements/Navbar/NavbarDesktop.jsx index 78e7f54a..cc5ea611 100644 --- a/src/core/components/elements/Navbar/NavbarDesktop.jsx +++ b/src/core/components/elements/Navbar/NavbarDesktop.jsx @@ -255,6 +255,16 @@ const NavbarDesktop = () => { rel="noreferrer" >

Semua Promo

+ {showPopup && ( + penawaran terbatas + )} {/* {showPopup && router.pathname === '/' && (
@@ -263,15 +273,6 @@ const NavbarDesktop = () => {

)} */} - {showPopup && router.pathname === '/' && ( - penawaran terbatas - )} { + const [flashSales, setFlashSales] = useState(null); + const [isLoading, setIsLoading] = useState(true); + + useEffect(() => { + const loadFlashSales = async () => { + const dataFlashSales = await flashSaleApi(); + setFlashSales(dataFlashSales); + setIsLoading(false); + }; + loadFlashSales(); + }, []); + + if (isLoading) { + return ; + } + + return ( + flashSales?.length > 0 && ( +
+ {flashSales.map((flashSale, index) => ( +
+
+
+ Penawaran Terbatas +
+
+ +
+ +
+
+ ))} +
+ ) + ); +}; + +const FlashSaleProduct = ({ flashSaleId }) => { + const [products, setProducts] = useState(null); + + useEffect(() => { + const loadProducts = async () => { + const dataProducts = await productSearchApi({ + query: `fq=-flashsale_id_i:${flashSaleId}&fq=flashsale_price_f:[1 TO *]&limit=500&orderBy=flashsale_discount_f desc`, + operation: 'AND', + }); + setProducts(dataProducts.response); + }; + loadProducts(); + }, [flashSaleId]); + + return ; +}; + +export default FlashSaleNonDisplay; -- cgit v1.2.3