summaryrefslogtreecommitdiff
path: root/src/lib/product
diff options
context:
space:
mode:
authorHATEC\SPVDEV001 <tri.susilo@altama.co.id>2023-11-18 11:33:28 +0700
committerHATEC\SPVDEV001 <tri.susilo@altama.co.id>2023-11-18 11:33:28 +0700
commit87a004c0fcf256e1e92653767a630c01ad21ad5a (patch)
tree8f9cce02324cb24c1fc4358afc7ae7bd32367bee /src/lib/product
parent75bb1fe75ef4c173a4dddadf871cf47638286136 (diff)
add brand link di page search
Diffstat (limited to 'src/lib/product')
-rw-r--r--src/lib/product/components/ProductSearch.jsx17
1 files changed, 11 insertions, 6 deletions
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>
)}