summaryrefslogtreecommitdiff
path: root/src/lib/product
diff options
context:
space:
mode:
authorRafi Zadanly <zadanlyr@gmail.com>2024-01-31 09:03:22 +0700
committerRafi Zadanly <zadanlyr@gmail.com>2024-01-31 09:03:22 +0700
commitb8764138241116e0c741a7786364f5630080720c (patch)
treecaf4396671469bc6ac992c9b741fe3f8701c986e /src/lib/product
parent3f849355048e5c280a35a5747577e5296b90e9fd (diff)
parent0550b0dbe9b8e369cfe211b78ab0de49a6e1f49d (diff)
Merge branch 'release' into feature/all-promotion
Diffstat (limited to 'src/lib/product')
-rw-r--r--src/lib/product/components/ProductCard.jsx10
-rw-r--r--src/lib/product/components/ProductSearch.jsx2
2 files changed, 9 insertions, 3 deletions
diff --git a/src/lib/product/components/ProductCard.jsx b/src/lib/product/components/ProductCard.jsx
index fa555bcf..1cec0804 100644
--- a/src/lib/product/components/ProductCard.jsx
+++ b/src/lib/product/components/ProductCard.jsx
@@ -6,6 +6,7 @@ import { createSlug } from '@/core/utils/slug'
import whatsappUrl from '@/core/utils/whatsappUrl'
import ImageNext from 'next/image'
import { useRouter } from 'next/router'
+import { useMemo } from 'react'
const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => {
const router = useRouter()
@@ -16,6 +17,11 @@ const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => {
url: createSlug('/shop/product/', product.name, product.id, true)
})
+ const image = useMemo(() => {
+ if (product.image) return product.image + '?ratio=square'
+ return '/images/noimage.jpeg'
+ }, [product.image])
+
if (variant == 'vertical') {
return (
<div className='rounded shadow-sm border border-gray_r-4 bg-white h-[300px] md:h-[350px]'>
@@ -24,7 +30,7 @@ const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => {
className='border-b border-gray_r-4 relative'
>
<Image
- src={product?.image}
+ src={image}
alt={product?.name}
className='w-full object-contain object-center h-36 sm:h-48'
/>
@@ -150,7 +156,7 @@ const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => {
className='relative'
>
<Image
- src={product?.image}
+ src={image}
alt={product?.name}
className='w-full object-contain object-center h-36'
/>
diff --git a/src/lib/product/components/ProductSearch.jsx b/src/lib/product/components/ProductSearch.jsx
index ed4365a8..90e93aa0 100644
--- a/src/lib/product/components/ProductSearch.jsx
+++ b/src/lib/product/components/ProductSearch.jsx
@@ -105,7 +105,7 @@ const ProductSearch = ({
setIsBrand(null);
}
};
- if (router.pathname.includes('search')) {
+ if (router.pathname.includes('search') && q !== '*') {
checkIfBrand();
}
}, [q]);