diff options
| author | HATEC\SPVDEV001 <tri.susilo@altama.co.id> | 2023-10-11 14:37:47 +0700 |
|---|---|---|
| committer | HATEC\SPVDEV001 <tri.susilo@altama.co.id> | 2023-10-11 14:37:47 +0700 |
| commit | de61c739202db29270d4ffd9215091f0219aba8c (patch) | |
| tree | 1a69ed2dcdb1ee939d051638934526b03107ff48 /src/lib/product/components/ProductSearch.jsx | |
| parent | f4fb8d1f93024cfe907a5783215cf9c939dd59bc (diff) | |
filter di web mobile
Diffstat (limited to 'src/lib/product/components/ProductSearch.jsx')
| -rw-r--r-- | src/lib/product/components/ProductSearch.jsx | 38 |
1 files changed, 27 insertions, 11 deletions
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)} dari </> ) : ( @@ -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'> |
