From 942b4c3548891f25198140b80192e9190a403ee5 Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Tue, 1 Aug 2023 17:07:20 +0700 Subject: flash sale --- .../product/components/Product/ProductDesktop.jsx | 34 ++++++++++++++++++++-- src/lib/product/components/ProductCard.jsx | 7 +++++ src/lib/product/components/ProductSimilar.jsx | 3 +- 3 files changed, 40 insertions(+), 4 deletions(-) (limited to 'src/lib/product/components') diff --git a/src/lib/product/components/Product/ProductDesktop.jsx b/src/lib/product/components/Product/ProductDesktop.jsx index 7e1d0d3b..e13e2ab1 100644 --- a/src/lib/product/components/Product/ProductDesktop.jsx +++ b/src/lib/product/components/Product/ProductDesktop.jsx @@ -18,8 +18,10 @@ import odooApi from '@/core/api/odooApi' import { Button, Spinner } from 'flowbite-react' import PromotionType from '@/lib/promotinProgram/components/PromotionType' import useAuth from '@/core/hooks/useAuth' +import ImageNext from 'next/image' const ProductDesktop = ({ products, wishlist, toggleWishlist }) => { + console.log('ini product', products) const router = useRouter() const auth = useAuth() const { slug } = router.query @@ -96,7 +98,7 @@ const ProductDesktop = ({ products, wishlist, toggleWishlist }) => { router.push(`/login?next=/shop/product/${slug}`) return } - + const quantity = variantQuantityRefs.current[variantId].value if (!validQuantity(quantity)) return @@ -142,7 +144,8 @@ const ProductDesktop = ({ products, wishlist, toggleWishlist }) => { useEffect(() => { const loadProductSimilarInBrand = async () => { const productSimilarQuery = [product?.name, `fq=-product_id_i:${product.id}`].join('&') - const dataProductSimilar = await productSimilarApi({ query: productSimilarQuery }) + const source = 'right' + const dataProductSimilar = await productSimilarApi({ query: productSimilarQuery, source }) setProductSimilarInBrand(dataProductSimilar.products) } if (!productSimilarInBrand) loadProductSimilarInBrand() @@ -170,7 +173,22 @@ const ProductDesktop = ({ products, wishlist, toggleWishlist }) => {
-
+
+
+
+
+ 40% +
+
+ + FLASH SALE +
+
+
{product.name} {
{currencyFormat(lowestPrice?.price)}
+ {product.flashSale.remainingTime > 0 && ( +
+ + FLASH SALE +
+ )}
)}

diff --git a/src/lib/product/components/ProductCard.jsx b/src/lib/product/components/ProductCard.jsx index a8964310..c85a76e9 100644 --- a/src/lib/product/components/ProductCard.jsx +++ b/src/lib/product/components/ProductCard.jsx @@ -3,6 +3,7 @@ import Link from '@/core/components/elements/Link/Link' import currencyFormat from '@/core/utils/currencyFormat' import { createSlug } from '@/core/utils/slug' import whatsappUrl from '@/core/utils/whatsappUrl' +import ImageNext from 'next/image' const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => { const callForPriceWhatsapp = whatsappUrl('product', { @@ -101,6 +102,12 @@ const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => {

+ {product.flashSale.id > 0 && ( +
+ + FLASH SALE +
+ )} {product?.manufacture?.name ? ( { - const { productSimilar } = useProductSimilar({ query }) + const source = "bottom" + const { productSimilar } = useProductSimilar({ query, source }) if (productSimilar.isLoading) { return -- cgit v1.2.3 From 7f5b0518474f702b68ca459e5cb531212504472d Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Thu, 3 Aug 2023 14:22:27 +0700 Subject: flash sale --- .../product/components/Product/ProductDesktop.jsx | 55 ++++++++++++++-------- src/lib/product/components/ProductCard.jsx | 54 +++++++++++++++------ 2 files changed, 75 insertions(+), 34 deletions(-) (limited to 'src/lib/product/components') diff --git a/src/lib/product/components/Product/ProductDesktop.jsx b/src/lib/product/components/Product/ProductDesktop.jsx index e13e2ab1..5cbe8a8a 100644 --- a/src/lib/product/components/Product/ProductDesktop.jsx +++ b/src/lib/product/components/Product/ProductDesktop.jsx @@ -19,6 +19,8 @@ import { Button, Spinner } from 'flowbite-react' import PromotionType from '@/lib/promotinProgram/components/PromotionType' import useAuth from '@/core/hooks/useAuth' import ImageNext from 'next/image' +import CountDown2 from '@/core/components/elements/CountDown/CountDown2' +import CountDown from '@/core/components/elements/CountDown/CountDown' const ProductDesktop = ({ products, wishlist, toggleWishlist }) => { console.log('ini product', products) @@ -173,27 +175,42 @@ const ProductDesktop = ({ products, wishlist, toggleWishlist }) => {
-
-
-
-
- 40% -
-
- - FLASH SALE +
+
+ {product?.flashSale?.remainingTime > 0 && ( +
+
+
+ {product.lowestPrice.discountPercentage}% +
+
+ + {product.flashSale.tag || 'FLASH SALE'} +
+
+ +
+
-
+ )} + {product.name} +
+
+

+ Keterangan : Gambar atau foto berperan + sebagai ilustrasi produk. Kadang tidak sesuai dengan kondisi terbaru dengan + berbagai perubahan dan perbaikan. Hubungi tim sales kami untuk informasi yang + lebih baik perihal gambar di 021-2933 8828. +

- {product.name}
diff --git a/src/lib/product/components/ProductCard.jsx b/src/lib/product/components/ProductCard.jsx index c85a76e9..b38bb43c 100644 --- a/src/lib/product/components/ProductCard.jsx +++ b/src/lib/product/components/ProductCard.jsx @@ -1,11 +1,14 @@ +import CountDown2 from '@/core/components/elements/CountDown/CountDown2' import Image from '@/core/components/elements/Image/Image' import Link from '@/core/components/elements/Link/Link' import currencyFormat from '@/core/utils/currencyFormat' import { createSlug } from '@/core/utils/slug' import whatsappUrl from '@/core/utils/whatsappUrl' import ImageNext from 'next/image' +import Product from './Product/Product' const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => { + console.log('ini prodyct ', product) const callForPriceWhatsapp = whatsappUrl('product', { name: product.name, url: createSlug('/shop/product/', product.name, product.id, true) @@ -23,6 +26,23 @@ const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => { alt={product?.name} className='w-full object-contain object-center h-36 sm:h-48' /> + {product?.flashSale?.id > 0 && ( +
+
+
+ {product?.lowestPrice.discountPercentage}% +
+
+ + {product?.flashSale?.tag} +
+
+
+ )} {product.variantTotal > 1 && (
{product.variantTotal} Varian @@ -30,20 +50,20 @@ const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => { )}
- {product?.manufacture?.name ? ( - - {product.manufacture.name} - - ) : ( -
-
- )} + {product?.manufacture?.name ? ( + + {product.manufacture.name} + + ) : ( +
-
+ )} {
{product.flashSale.id > 0 && (
- + FLASH SALE
)} -- cgit v1.2.3 From ba70a6d4ca828b08be4b8a27d3abb3868d85668f Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Fri, 4 Aug 2023 09:34:45 +0700 Subject: fixing validasi variant qty --- src/lib/product/components/Product/ProductDesktop.jsx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/lib/product/components') diff --git a/src/lib/product/components/Product/ProductDesktop.jsx b/src/lib/product/components/Product/ProductDesktop.jsx index 7e1d0d3b..3b21db6b 100644 --- a/src/lib/product/components/Product/ProductDesktop.jsx +++ b/src/lib/product/components/Product/ProductDesktop.jsx @@ -54,9 +54,10 @@ const ProductDesktop = ({ products, wishlist, toggleWishlist }) => { const setVariantQuantityRef = (variantId) => (element) => { if (element) { let variantIndex = product.variants.findIndex((varian) => varian.id == variantId) - product.variants[variantIndex].quantity = element.value + product.variants[variantIndex].quantity = element?.value } variantQuantityRefs.current[variantId] = element + } const validQuantity = (quantity) => { @@ -106,6 +107,15 @@ const ProductDesktop = ({ products, wishlist, toggleWishlist }) => { setAddCartAlert(true) } + const handleQuantityChange = (variantId) => (event) => { + 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 + // Lakukan sesuatu jika nilai quantity diubah + } + }; + const handleBuy = (variant) => { const quantity = variantQuantityRefs.current[variant].value if (!validQuantity(quantity)) return @@ -579,7 +589,7 @@ const ProductDesktop = ({ products, wishlist, toggleWishlist }) => { type='number' className='form-input w-16 py-2 text-center bg-gray_r-1' ref={setVariantQuantityRef(variant.id)} - onChange={setVariantQuantityRef(variant.id)} + onChange={handleQuantityChange(variant.id)} defaultValue={1} /> -- cgit v1.2.3 From 47d81f5b23a96611db07f92203d03fc761a68db9 Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Fri, 4 Aug 2023 09:36:50 +0700 Subject: ketinggalan --- src/lib/product/components/Product/ProductDesktop.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/lib/product/components') diff --git a/src/lib/product/components/Product/ProductDesktop.jsx b/src/lib/product/components/Product/ProductDesktop.jsx index 3b21db6b..372ad3ba 100644 --- a/src/lib/product/components/Product/ProductDesktop.jsx +++ b/src/lib/product/components/Product/ProductDesktop.jsx @@ -422,7 +422,7 @@ const ProductDesktop = ({ products, wishlist, toggleWishlist }) => { type='number' className='form-input w-16 py-2 text-center bg-gray_r-1' ref={setVariantQuantityRef(product.variants[0].id)} - onChange={setVariantQuantityRef(product.variants[0].id)} + onChange={handleQuantityChange(product.variants[0].id)} defaultValue={1} /> - ) : selectedVariant ? activeVariant?.sla?.slaDate != '-' ? ( - - ):('-') : ( + {activeVariant?.sla?.slaDate} +
+
+ +
+ + ) : ( + '-' + ) + ) : ( '-' )} 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} + + ) : ( +
-
+ )} Date: Fri, 4 Aug 2023 13:36:47 +0700 Subject: add backgorund image mobile --- src/lib/product/components/Product/ProductMobile.jsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/lib/product/components') diff --git a/src/lib/product/components/Product/ProductMobile.jsx b/src/lib/product/components/Product/ProductMobile.jsx index f0264542..d25d0861 100644 --- a/src/lib/product/components/Product/ProductMobile.jsx +++ b/src/lib/product/components/Product/ProductMobile.jsx @@ -45,7 +45,9 @@ const ProductMobile = ({ product, wishlist, toggleWishlist }) => { useEffect(() => { const getBackgound = async () => { const get = await odooApi('GET', '/api/v1/banner?type=flash-sale-background-banner') - setBackgorundFlashSale(get[0].image) + if (get.length > 0) { + setBackgorundFlashSale(get[0].image) + } } getBackgound() }, []) @@ -171,7 +173,11 @@ const ProductMobile = ({ product, wishlist, toggleWishlist }) => { {product?.flashSale?.remainingTime > 0 && (
- +
-- cgit v1.2.3 From 16fed2e7d00252f5df3f9b5bdf0a5a2b2a094f76 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Tue, 8 Aug 2023 10:39:34 +0700 Subject: Improve home page performance --- src/lib/product/components/ProductCard.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/lib/product/components') diff --git a/src/lib/product/components/ProductCard.jsx b/src/lib/product/components/ProductCard.jsx index a8964310..51a369c4 100644 --- a/src/lib/product/components/ProductCard.jsx +++ b/src/lib/product/components/ProductCard.jsx @@ -12,7 +12,7 @@ const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => { if (variant == 'vertical') { return ( -
+
Date: Tue, 8 Aug 2023 10:44:25 +0700 Subject: Update product card height --- src/lib/product/components/ProductCard.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/lib/product/components') diff --git a/src/lib/product/components/ProductCard.jsx b/src/lib/product/components/ProductCard.jsx index 51a369c4..13fe07fd 100644 --- a/src/lib/product/components/ProductCard.jsx +++ b/src/lib/product/components/ProductCard.jsx @@ -12,7 +12,7 @@ const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => { if (variant == 'vertical') { return ( -
+
Date: Wed, 16 Aug 2023 16:26:07 +0700 Subject: Remove get flash sale background on product card --- src/lib/product/components/ProductCard.jsx | 13 ------------- 1 file changed, 13 deletions(-) (limited to 'src/lib/product/components') diff --git a/src/lib/product/components/ProductCard.jsx b/src/lib/product/components/ProductCard.jsx index 5b859905..36cd8d18 100644 --- a/src/lib/product/components/ProductCard.jsx +++ b/src/lib/product/components/ProductCard.jsx @@ -1,31 +1,18 @@ -import CountDown2 from '@/core/components/elements/CountDown/CountDown2' import Image from '@/core/components/elements/Image/Image' import Link from '@/core/components/elements/Link/Link' import currencyFormat from '@/core/utils/currencyFormat' import { createSlug } from '@/core/utils/slug' 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() - 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 ( -- cgit v1.2.3 From 35013fd66d8cbc78e07573112fc482fb7dec14e2 Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Thu, 31 Aug 2023 14:03:04 +0700 Subject: bugs fixing flash sale tag --- src/lib/product/components/ProductCard.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/lib/product/components') diff --git a/src/lib/product/components/ProductCard.jsx b/src/lib/product/components/ProductCard.jsx index 36cd8d18..66363ff2 100644 --- a/src/lib/product/components/ProductCard.jsx +++ b/src/lib/product/components/ProductCard.jsx @@ -45,7 +45,7 @@ const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => { height={5} /> - {product?.flashSale?.tag} + {product?.flashSale?.tag != "false" || product?.flashSale?.tag != product?.flashSale?.tag ? '' : 'FLASH SALE'}
@@ -138,7 +138,7 @@ const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => { width={15} height={10} /> - FLASH SALE + {product?.flashSale?.tag != "false" || product?.flashSale?.tag != product?.flashSale?.tag ? '' : 'FLASH SALE'}
)} {product?.manufacture?.name ? ( -- cgit v1.2.3 From 4c81d351a5d4ab54f8d08a94c0046b04bbc3a373 Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Thu, 31 Aug 2023 14:08:15 +0700 Subject: delete logs --- src/lib/product/components/Product/ProductDesktop.jsx | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/lib/product/components') diff --git a/src/lib/product/components/Product/ProductDesktop.jsx b/src/lib/product/components/Product/ProductDesktop.jsx index 187ab3c9..3b9296a8 100644 --- a/src/lib/product/components/Product/ProductDesktop.jsx +++ b/src/lib/product/components/Product/ProductDesktop.jsx @@ -59,8 +59,6 @@ const ProductDesktop = ({ products, wishlist, toggleWishlist }) => { getBackgound() }, []) - console.log('ini set', backgorundFlashSale) - const [informationTab, setInformationTab] = useState(informationTabOptions[0].value) const variantQuantityRefs = useRef([]) -- cgit v1.2.3 From 4cfc5bf25ba20b2a1a8ca140c785557d6c00cef6 Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Thu, 31 Aug 2023 14:19:58 +0700 Subject: fixing --- src/lib/product/components/ProductCard.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/lib/product/components') diff --git a/src/lib/product/components/ProductCard.jsx b/src/lib/product/components/ProductCard.jsx index 66363ff2..2c849bd6 100644 --- a/src/lib/product/components/ProductCard.jsx +++ b/src/lib/product/components/ProductCard.jsx @@ -45,7 +45,7 @@ const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => { height={5} /> - {product?.flashSale?.tag != "false" || product?.flashSale?.tag != product?.flashSale?.tag ? '' : 'FLASH SALE'} + {product?.flashSale?.tag != "false" || product?.flashSale?.tag != product?.flashSale?.tag ? product?.flashSale?.tag : 'FLASH SALE'}
@@ -138,7 +138,7 @@ const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => { width={15} height={10} /> - {product?.flashSale?.tag != "false" || product?.flashSale?.tag != product?.flashSale?.tag ? '' : 'FLASH SALE'} + {product?.flashSale?.tag != "false" || product?.flashSale?.tag != product?.flashSale?.tag ? product?.flashSale?.tag : 'FLASH SALE'}
)} {product?.manufacture?.name ? ( -- cgit v1.2.3