summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHATEC\SPVDEV001 <tri.susilo@altama.co.id>2023-10-30 09:30:25 +0700
committerHATEC\SPVDEV001 <tri.susilo@altama.co.id>2023-10-30 09:30:25 +0700
commit0a1413aec32fddc433a34bf7d03d8681dedc266d (patch)
treef82cc8e49b0d83f3dc06816a0b447908371c64e8 /src
parent51726bd7e8e69535590d70327ebd340ffaf96abd (diff)
show brand logo in page search if search is brand
Diffstat (limited to 'src')
-rw-r--r--src/lib/product/components/ProductSearch.jsx9
-rw-r--r--src/pages/api/shop/brands.js4
2 files changed, 4 insertions, 9 deletions
diff --git a/src/lib/product/components/ProductSearch.jsx b/src/lib/product/components/ProductSearch.jsx
index 50936d9a..190d026b 100644
--- a/src/lib/product/components/ProductSearch.jsx
+++ b/src/lib/product/components/ProductSearch.jsx
@@ -86,13 +86,8 @@ const ProductSearch = ({ query, prefixUrl, defaultBrand = null, brand = null })
const brand = await axios(
`${process.env.NEXT_PUBLIC_SELF_HOST}/api/shop/brands?params=search&q=${q}`
)
- if (brand.data.length > 0) {
- brand.data.map((brand) => {
- if (brand.name.toLowerCase() === q.toLowerCase()) {
- setIsBrand(brand)
- }
- })
- }
+ setIsBrand(brand?.data[0])
+
}
checkIfBrand()
}, [q])
diff --git a/src/pages/api/shop/brands.js b/src/pages/api/shop/brands.js
index 85ebee56..2025da70 100644
--- a/src/pages/api/shop/brands.js
+++ b/src/pages/api/shop/brands.js
@@ -13,9 +13,9 @@ export default async function handler(req, res) {
params = 'level_s:prioritas'
break
case 'search':
- params = `{!func}strdist(name_s, "${req?.query?.q}",edit)`
+ params = `name_s:${req?.query?.q}`
sort = ''
- rows = 10
+ rows = 1
break;
default:
params = `name_s:${req.query.params}`