diff options
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/product/components/Product/ProductDesktop.jsx | 6 | ||||
| -rw-r--r-- | src/lib/product/components/Product/ProductMobile.jsx | 2 | ||||
| -rw-r--r-- | src/lib/product/components/ProductCard.jsx | 31 | ||||
| -rw-r--r-- | src/lib/product/components/ProductSearch.jsx | 17 |
4 files changed, 39 insertions, 17 deletions
diff --git a/src/lib/product/components/Product/ProductDesktop.jsx b/src/lib/product/components/Product/ProductDesktop.jsx index a8cca416..5f034c09 100644 --- a/src/lib/product/components/Product/ProductDesktop.jsx +++ b/src/lib/product/components/Product/ProductDesktop.jsx @@ -441,11 +441,11 @@ const ProductDesktop = ({ products, wishlist, toggleWishlist }) => { {sellingProductFormat(product?.qtySold) + ' Terjual'} </div> )} - {lowestPrice?.isFlashsale && lowestPrice?.price.discountPercentage > 0 ? ( + {product?.flashSale?.id && lowestPrice?.price.discountPercentage > 0 ? ( <> <div className='flex gap-x-1 items-center mt-2'> <div className='badge-solid-red text-caption-1'> - {lowestPrice?.price?.discountPercentage}% + {Math.floor(lowestPrice?.price?.discountPercentage)}% </div> <div className='text-gray_r-9 line-through text-caption-1'> {currencyFormat(lowestPrice?.price?.price)} @@ -584,7 +584,7 @@ const ProductDesktop = ({ products, wishlist, toggleWishlist }) => { <> <div className='flex items-center gap-x-1 justify-center'> <div className='badge-solid-red text-caption-1'> - {variant?.price?.discountPercentage}% + {Math.floor(variant?.price?.discountPercentage)}% </div> <div className='line-through text-caption-1 text-gray_r-11'> {currencyFormat(variant?.price?.price)} diff --git a/src/lib/product/components/Product/ProductMobile.jsx b/src/lib/product/components/Product/ProductMobile.jsx index ef2c0002..e23e2fb9 100644 --- a/src/lib/product/components/Product/ProductMobile.jsx +++ b/src/lib/product/components/Product/ProductMobile.jsx @@ -260,7 +260,7 @@ const ProductMobile = ({ product, wishlist, toggleWishlist }) => { {activeVariant.isFlashsale && activeVariant?.price?.discountPercentage > 0 ? ( <> <div className='flex gap-x-1 items-center'> - <div className='badge-solid-red'>{activeVariant?.price?.discountPercentage}%</div> + <div className='badge-solid-red'>{Math.floor(activeVariant?.price?.discountPercentage)}%</div> <div className='text-gray_r-11 line-through text-caption-1'> {currencyFormat(activeVariant?.price?.price)} </div> diff --git a/src/lib/product/components/ProductCard.jsx b/src/lib/product/components/ProductCard.jsx index 9500a3fd..fa555bcf 100644 --- a/src/lib/product/components/ProductCard.jsx +++ b/src/lib/product/components/ProductCard.jsx @@ -12,6 +12,7 @@ const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => { const callForPriceWhatsapp = whatsappUrl('product', { name: product.name, + manufacture: product.manufacture?.name, url: createSlug('/shop/product/', product.name, product.id, true) }) @@ -41,7 +42,7 @@ const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => { <div className='flex gap-x-1 items-center p-2 justify-center'> <div className='bg-yellow-400 rounded-lg p-1 h-6 w-19 flex items-center justify-center '> <span className='text-sm font-bold text-black'> - {product?.lowestPrice.discountPercentage}% + {Math.floor(product?.lowestPrice.discountPercentage)}% </span> </div> <div className='bg-red-600 border border-solid border-yellow-400 p-2 rounded-full h-6 flex w-fit items-center justify-center gap-x-2'> @@ -102,7 +103,9 @@ const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => { {product?.lowestPrice.priceDiscount > 0 ? ( currencyFormat(product?.lowestPrice.priceDiscount) ) : ( - <a href={callForPriceWhatsapp}>Call for Inquiry</a> + <a rel='noopener noreferrer' target='_blank' href={callForPriceWhatsapp}> + Call for Inquiry + </a> )} </div> </> @@ -117,7 +120,9 @@ const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => { </div> </> ) : ( - <a href={callForPriceWhatsapp}>Call for Inquiry</a> + <a rel='noopener noreferrer' target='_blank' href={callForPriceWhatsapp}> + Call for Inquiry + </a> )} </div> )} @@ -125,7 +130,11 @@ const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => { <div className='flex w-full items-center gap-x-1 '> {product?.stockTotal > 0 && <div className='badge-solid-red'>Ready Stock</div>} {/* <div className='badge-gray'>{product?.stockTotal > 5 ? '> 5' : '< 5'}</div> */} - {product?.qtySold > 0 && <div className='text-gray_r-9 text-[11px]'>{sellingProductFormat(product?.qtySold) + ' Terjual'}</div>} + {product?.qtySold > 0 && ( + <div className='text-gray_r-9 text-[11px]'> + {sellingProductFormat(product?.qtySold) + ' Terjual'} + </div> + )} </div> </div> </div> @@ -205,7 +214,9 @@ const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => { {product?.lowestPrice?.priceDiscount > 0 ? ( currencyFormat(product?.lowestPrice?.priceDiscount) ) : ( - <a href={callForPriceWhatsapp}>Call for Inquiry</a> + <a rel='noopener noreferrer' target='_blank' href={callForPriceWhatsapp}> + Call for Inquiry + </a> )} </div> </> @@ -220,7 +231,9 @@ const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => { </div> </> ) : ( - <a href={callForPriceWhatsapp}>Call for Inquiry</a> + <a rel='noopener noreferrer' target='_blank' href={callForPriceWhatsapp}> + Call for Inquiry + </a> )} </div> )} @@ -228,7 +241,11 @@ const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => { <div className='flex w-full items-center gap-x-1 '> {product?.stockTotal > 0 && <div className='badge-solid-red'>Ready Stock</div>} {/* <div className='badge-gray'>{product?.stockTotal > 5 ? '> 5' : '< 5'}</div> */} - {product?.qtySold > 0 && <div className='text-gray_r-9 text-[11px]'>{sellingProductFormat(product?.qtySold) + ' Terjual'}</div>} + {product?.qtySold > 0 && ( + <div className='text-gray_r-9 text-[11px]'> + {sellingProductFormat(product?.qtySold) + ' Terjual'} + </div> + )} </div> </div> </div> diff --git a/src/lib/product/components/ProductSearch.jsx b/src/lib/product/components/ProductSearch.jsx index a4e9ecbb..29bb987e 100644 --- a/src/lib/product/components/ProductSearch.jsx +++ b/src/lib/product/components/ProductSearch.jsx @@ -20,6 +20,7 @@ import odooApi from '@/core/api/odooApi' import { formatCurrency } from '@/core/utils/formatValue' import axios from 'axios' import Skeleton from 'react-loading-skeleton' +import { createSlug } from '@/core/utils/slug' const ProductSearch = ({ query, prefixUrl, defaultBrand = null, brand = null }) => { const router = useRouter() @@ -87,13 +88,16 @@ const ProductSearch = ({ query, prefixUrl, defaultBrand = null, brand = null }) const brand = await axios( `${process.env.NEXT_PUBLIC_SELF_HOST}/api/shop/brands?params=search&q=${search}` ) + console.log('ini brand', brand) if (brand.data.length > 0) { setIsBrand(brand?.data[0]) } else { setIsBrand(null) } } - checkIfBrand() + if (router.pathname.includes('search')) { + checkIfBrand() + } }, [q]) const brands = [] @@ -362,11 +366,12 @@ const ProductSearch = ({ query, prefixUrl, defaultBrand = null, brand = null }) {isBrand && isBrand.logo && ( <div className='mb-3'> <h1 className='text-2xl mb-2 font-semibold'>Brand Pencarian {q}</h1> - <Image - src={isBrand?.logo} - alt='' - className='object-cover object-center h-[100px]' - /> + <Link + href={createSlug('/shop/brands/', isBrand.name, isBrand.id)} + className='inline' + > + <Image src={isBrand?.logo} alt='' className='object-cover object-center h-24' /> + </Link> </div> )} |
