summaryrefslogtreecommitdiff
path: root/src/lib/product/components/ProductSearch.jsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/product/components/ProductSearch.jsx')
-rw-r--r--src/lib/product/components/ProductSearch.jsx12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/lib/product/components/ProductSearch.jsx b/src/lib/product/components/ProductSearch.jsx
index fd75d587..9d59b305 100644
--- a/src/lib/product/components/ProductSearch.jsx
+++ b/src/lib/product/components/ProductSearch.jsx
@@ -23,8 +23,9 @@ const ProductSearch = ({ query, prefixUrl, defaultBrand = null }) => {
const { page = 1 } = query
const [q, setQ] = useState(query?.q || '*')
const [limit, setLimit] = useState(query?.limit || 30)
+ const [orderBy, setOrderBy] = useState(router.query?.orderBy || 'popular')
if (defaultBrand) query.brand = defaultBrand.toLowerCase()
- const { productSearch } = useProductSearch({ query: { ...query, q, limit } })
+ const { productSearch } = useProductSearch({ query: { ...query, q, limit, orderBy } })
const [products, setProducts] = useState(null)
const [spellings, setSpellings] = useState(null)
const [bannerPromotionHeader, setBannerPromotionHeader] = useState(null)
@@ -70,11 +71,11 @@ const ProductSearch = ({ query, prefixUrl, defaultBrand = null }) => {
const brands = []
for (
let i = 0;
- i < productSearch.data?.facetCounts?.facetFields?.manufactureName.length;
+ i < productSearch.data?.facetCounts?.facetFields?.manufactureNameS.length;
i += 2
) {
- const brand = productSearch.data?.facetCounts?.facetFields?.manufactureName[i]
- const qty = productSearch.data?.facetCounts?.facetFields?.manufactureName[i + 1]
+ const brand = productSearch.data?.facetCounts?.facetFields?.manufactureNameS[i]
+ const qty = productSearch.data?.facetCounts?.facetFields?.manufactureNameS[i + 1]
if (qty > 0) {
brands.push({ brand, qty })
}
@@ -303,10 +304,9 @@ const ProductSearch = ({ query, prefixUrl, defaultBrand = null }) => {
<select
name='urutan'
className='form-input mt-2'
- value={router.query?.orderBy || ''}
+ value={orderBy}
onChange={(e) => handleOrderBy(e)}
>
- <option value=''>Urutkan</option>
{orderOptions.map((option, index) => (
<option key={index} value={option.value}>
{' '}