From de61c739202db29270d4ffd9215091f0219aba8c Mon Sep 17 00:00:00 2001
From: "HATEC\\SPVDEV001" <tri.susilo@altama.co.id>
Date: Wed, 11 Oct 2023 14:37:47 +0700
Subject: filter di web mobile

---
 src/lib/product/components/ProductSearch.jsx | 38 ++++++++++++++++++++--------
 1 file changed, 27 insertions(+), 11 deletions(-)

(limited to 'src/lib/product/components/ProductSearch.jsx')

diff --git a/src/lib/product/components/ProductSearch.jsx b/src/lib/product/components/ProductSearch.jsx
index c79e355e..ef4580d6 100644
--- a/src/lib/product/components/ProductSearch.jsx
+++ b/src/lib/product/components/ProductSearch.jsx
@@ -28,10 +28,7 @@ const ProductSearch = ({ query, prefixUrl, defaultBrand = null }) => {
   const popup = useActive()
   const numRows = [30, 50, 80, 100]
 
-  console.log('ini product search', productSearch.data)
-  const pageCount = Math.ceil(
-    productSearch.data?.response.numFound / limit
-  )
+  const pageCount = Math.ceil(productSearch.data?.response.numFound / limit)
   const productStart = productSearch.data?.responseHeader.params.start
   const productRows = limit
   const productFound = productSearch.data?.response.numFound
@@ -104,7 +101,7 @@ const ProductSearch = ({ query, prefixUrl, defaultBrand = null }) => {
   const handleOrderBy = (e) => {
     let params = {
       ...router.query,
-      orderBy: e.target.value,
+      orderBy: e.target.value
     }
     params = _.pickBy(params, _.identity)
     params = toQuery(params)
@@ -114,7 +111,7 @@ const ProductSearch = ({ query, prefixUrl, defaultBrand = null }) => {
   const handleLimit = (e) => {
     let params = {
       ...router.query,
-      limit: e.target.value,
+      limit: e.target.value
     }
     params = _.pickBy(params, _.identity)
     params = toQuery(params)
@@ -153,9 +150,9 @@ const ProductSearch = ({ query, prefixUrl, defaultBrand = null }) => {
                 {pageCount > 1 ? (
                   <>
                     {productStart + 1}-
-                    {productStart + productRows > productFound
+                    {parseInt(productStart) + parseInt(productRows) > productFound
                       ? productFound
-                      : productStart + productRows}
+                      : parseInt(productStart) + parseInt(productRows)}
                     &nbsp;dari&nbsp;
                   </>
                 ) : (
@@ -175,9 +172,28 @@ const ProductSearch = ({ query, prefixUrl, defaultBrand = null }) => {
           </div>
 
           {productFound > 0 && (
-            <button className='btn-light mb-6 py-2 px-5' onClick={popup.activate}>
-              Filter
-            </button>
+            <div className='flex items-center gap-x-2 mb-5 justify-between'>
+              <div>
+                <button className='btn-light py-2 px-5 h-[40px]' onClick={popup.activate}>
+                  Filter
+                </button>
+              </div>
+              <div className=''>
+                <select
+                  name='limit'
+                  className='form-input w-24'
+                  value={router.query?.limit || ''}
+                  onChange={(e) => handleLimit(e)}
+                >
+                  {numRows.map((option, index) => (
+                    <option key={index} value={option}>
+                      {' '}
+                      {option}{' '}
+                    </option>
+                  ))}
+                </select>
+              </div>
+            </div>
           )}
 
           <div className='grid grid-cols-2 gap-3'>
-- 
cgit v1.2.3

