summaryrefslogtreecommitdiff
path: root/src/lib/product/components/Product/ProductDesktop.jsx
diff options
context:
space:
mode:
authorHATEC\SPVDEV001 <tri.susilo@altama.co.id>2023-08-04 13:24:58 +0700
committerHATEC\SPVDEV001 <tri.susilo@altama.co.id>2023-08-04 13:24:58 +0700
commitd9652e77733a24b329f8d849e700222f06c4331e (patch)
tree0d82019d45ac1be310dc37b50556249c72555dae /src/lib/product/components/Product/ProductDesktop.jsx
parent9010695979e4fb39a021901fa8b2b0be9efd3c77 (diff)
add image backgournd
Diffstat (limited to 'src/lib/product/components/Product/ProductDesktop.jsx')
-rw-r--r--src/lib/product/components/Product/ProductDesktop.jsx65
1 files changed, 44 insertions, 21 deletions
diff --git a/src/lib/product/components/Product/ProductDesktop.jsx b/src/lib/product/components/Product/ProductDesktop.jsx
index f6c998e2..187ab3c9 100644
--- a/src/lib/product/components/Product/ProductDesktop.jsx
+++ b/src/lib/product/components/Product/ProductDesktop.jsx
@@ -36,6 +36,7 @@ const ProductDesktop = ({ products, wishlist, toggleWishlist }) => {
const [promotionType, setPromotionType] = useState(false)
const [promotionActiveId, setPromotionActiveId] = useState(null)
const [selectVariantPromoActive, setSelectVariantPromoActive] = useState(null)
+ const [backgorundFlashSale, setBackgorundFlashSale] = useState(null)
const getLowestPrice = useCallback(() => {
const prices = product.variants.map((variant) => variant.price)
@@ -50,6 +51,16 @@ const ProductDesktop = ({ products, wishlist, toggleWishlist }) => {
setLowestPrice(lowest)
}, [getLowestPrice])
+ useEffect(() => {
+ const getBackgound = async () => {
+ const get = await odooApi('GET', '/api/v1/banner?type=flash-sale-background-banner')
+ setBackgorundFlashSale(get[0].image)
+ }
+ getBackgound()
+ }, [])
+
+ console.log('ini set', backgorundFlashSale)
+
const [informationTab, setInformationTab] = useState(informationTabOptions[0].value)
const variantQuantityRefs = useRef([])
@@ -60,7 +71,6 @@ const ProductDesktop = ({ products, wishlist, toggleWishlist }) => {
product.variants[variantIndex].quantity = element?.value
}
variantQuantityRefs.current[variantId] = element
-
}
const validQuantity = (quantity) => {
@@ -111,13 +121,13 @@ const ProductDesktop = ({ products, wishlist, toggleWishlist }) => {
}
const handleQuantityChange = (variantId) => (event) => {
- const { value } = event.target;
- const variantIndex = product.variants.findIndex((variant) => variant.id === variantId);
+ const { value } = event.target
+ const variantIndex = product.variants.findIndex((variant) => variant.id === variantId)
if (variantIndex !== -1) {
- product.variants[variantIndex].quantity = parseInt(value, 10); // Pastikan untuk mengubah ke tipe number jika diperlukan
+ product.variants[variantIndex].quantity = parseInt(value, 10) // Pastikan untuk mengubah ke tipe number jika diperlukan
// Lakukan sesuatu jika nilai quantity diubah
}
- };
+ }
const handleBuy = (variant) => {
const quantity = variantQuantityRefs.current[variant].value
@@ -187,21 +197,32 @@ const ProductDesktop = ({ products, wishlist, toggleWishlist }) => {
<div className='w-5/12'>
<div className='relative mb-2'>
{product?.flashSale?.remainingTime > 0 && (
- <div className='absolute bottom-0 bg-red-600 w-full h-15 grid'>
- <div className='flex gap-x-2 items-center p-2'>
- <div className='bg-yellow-400 rounded-full p-1 h-9 w-20 flex items-center justify-center '>
- <span className='text-lg font-bold'>{product.lowestPrice.discountPercentage}%</span>
- </div>
- <div className='bg-red-600 border border-solid border-yellow-400 rounded-full h-9 p-2 flex w-[50%] items-center justify-center gap-x-4'>
- <ImageNext
- src='/images/ICON_FLASH_SALE_WEBSITE_INDOTEKNIK.svg'
- width={17}
- height={10}
- />
- <span className='text-white text-lg font-semibold'>{product.flashSale.tag || 'FLASH SALE'}</span>
- </div>
- <div>
- <CountDown2 initialTime={product.flashSale.remainingTime} />
+ <div className={`absolute bottom-0 w-full`}>
+ <div className='absolute bottom-0 w-full h-full'>
+ <ImageNext src={backgorundFlashSale || '/images/GAMBAR-BG-FLASH-SALE.jpg'} width={1000} height={100} />
+ </div>
+ <div className='relative'>
+ <div className='flex gap-x-2 items-center p-2'>
+ <div className='bg-yellow-400 rounded-full p-1 h-9 w-20 flex items-center justify-center '>
+ <span className='text-lg font-bold'>
+ {product.lowestPrice.discountPercentage}%
+ </span>
+ </div>
+ <div
+ className={`bg-red-600 border border-solid border-yellow-400 rounded-full h-9 p-2 flex w-[50%] items-center justify-center gap-x-4`}
+ >
+ <ImageNext
+ src='/images/ICON_FLASH_SALE_WEBSITE_INDOTEKNIK.svg'
+ width={17}
+ height={10}
+ />
+ <span className='text-white text-lg font-semibold'>
+ {product.flashSale.tag || 'FLASH SALE'}
+ </span>
+ </div>
+ <div>
+ <CountDown2 initialTime={product.flashSale.remainingTime} />
+ </div>
</div>
</div>
</div>
@@ -426,7 +447,9 @@ const ProductDesktop = ({ products, wishlist, toggleWishlist }) => {
width={15}
height={10}
/>
- <span className='text-white text-xs font-semibold'>FLASH SALE</span>
+ <span className='text-white text-xs font-semibold'>
+ {product.flashSale.tag || 'FLASH SALE'}
+ </span>
</div>
)}
</div>