diff options
| author | HATEC\SPVDEV001 <tri.susilo@altama.co.id> | 2023-10-16 11:28:13 +0700 |
|---|---|---|
| committer | HATEC\SPVDEV001 <tri.susilo@altama.co.id> | 2023-10-16 11:28:13 +0700 |
| commit | ca445ab4e089b98fb67b004a6cb4a8968f471ae4 (patch) | |
| tree | c9420c1e9ae87ec16b58ac11fa2d24118b41d494 /src/lib | |
| parent | 43e59b8c7f8b742e5781a8a8b991afcf9aabb90e (diff) | |
active price range
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/product/components/ProductFilterDesktop.jsx | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/lib/product/components/ProductFilterDesktop.jsx b/src/lib/product/components/ProductFilterDesktop.jsx index e84d6526..6118ed6b 100644 --- a/src/lib/product/components/ProductFilterDesktop.jsx +++ b/src/lib/product/components/ProductFilterDesktop.jsx @@ -29,6 +29,7 @@ const ProductFilterDesktop = ({ brands, categories, prefixUrl, defaultBrand = nu const [priceTo, setPriceTo] = useState(query?.priceTo) const [stock, setStock] = useState(query?.stock) const [activeRange, setActiveRange] = useState(null) + const [activeIndeces, setActiveIndeces] = useState([]) const priceRange = [ { @@ -49,6 +50,10 @@ const ProductFilterDesktop = ({ brands, categories, prefixUrl, defaultBrand = nu } ] + const indexRange = priceRange.findIndex((range) => { + return range.priceFrom === parseInt(priceFrom) && range.priceTo == parseInt(priceTo) + }) + const handleCategoriesChange = (event) => { const value = event.target.value const isChecked = event.target.checked @@ -108,6 +113,26 @@ const ProductFilterDesktop = ({ brands, categories, prefixUrl, defaultBrand = nu } } + /*const handleIndexAccordion = async () => { + if (brandValues) { + await setActiveIndeces([...activeIndeces, 0]) + } + if (categoryValues) { + await setActiveIndeces([...activeIndeces, !router.pathname.includes('brands') ? 1 : 0]) + } + if (priceRange) { + await setActiveIndeces([...activeIndeces, !router.pathname.includes('brands') ? 2 : 1]) + } + if (stock) { + await setActiveIndeces([...activeIndeces, !router.pathname.includes('brands') ? 3 : 2]) + } + }*/ + + useEffect(() => { + setActiveRange(indexRange) + }, []) + + return ( <> <Accordion defaultIndex={[0]} allowMultiple> |
