From d9652e77733a24b329f8d849e700222f06c4331e Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Fri, 4 Aug 2023 13:24:58 +0700 Subject: add image backgournd --- src/lib/product/components/ProductCard.jsx | 74 +++++++++++++++++++----------- 1 file changed, 47 insertions(+), 27 deletions(-) (limited to 'src/lib/product/components/ProductCard.jsx') diff --git a/src/lib/product/components/ProductCard.jsx b/src/lib/product/components/ProductCard.jsx index 9e559358..d33516dd 100644 --- a/src/lib/product/components/ProductCard.jsx +++ b/src/lib/product/components/ProductCard.jsx @@ -7,14 +7,25 @@ import whatsappUrl from '@/core/utils/whatsappUrl' import ImageNext from 'next/image' import Product from './Product/Product' import { useRouter } from 'next/router' +import { useEffect, useState } from 'react' +import odooApi from '@/core/api/odooApi' const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => { const router = useRouter() - console.log('ini route', router) + + const [backgorundFlashSale, setBackgorundFlashSale] = useState(null) + const callForPriceWhatsapp = whatsappUrl('product', { name: product.name, url: createSlug('/shop/product/', product.name, product.id, true) }) + useEffect(() => { + const getBackgound = async () => { + const get = await odooApi('GET', '/api/v1/banner?type=flash-sale-background-banner') + setBackgorundFlashSale(get[0].image) + } + getBackgound() + }, []) if (variant == 'vertical') { return ( @@ -29,18 +40,27 @@ const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => { className='w-full object-contain object-center h-36 sm:h-48' /> {router.pathname != '/' && product?.flashSale?.id > 0 && ( -
-
-
- {product?.lowestPrice.discountPercentage}% -
-
- - {product?.flashSale?.tag} +
+
+ +
+
+
+
+ + {product?.lowestPrice.discountPercentage}% + +
+
+ + + {product?.flashSale?.tag} + +
@@ -52,20 +72,20 @@ const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => { )}
- {product?.manufacture?.name ? ( - - {product.manufacture.name} - - ) : ( -
-
- )} + {product?.manufacture?.name ? ( + + {product.manufacture.name} + + ) : ( +
-
+ )}