diff options
| author | trisusilo <tri.susilo@altama.co.id> | 2023-10-16 06:16:50 +0000 |
|---|---|---|
| committer | trisusilo <tri.susilo@altama.co.id> | 2023-10-16 06:16:50 +0000 |
| commit | 2ad2f4d39d9b6c3caaedffef7c5c506126c6ee43 (patch) | |
| tree | a74836260403ff8a1664dcc5664dea1844376a59 /src | |
| parent | 8eef74c25930b532d55229f130befdad6eb0ea56 (diff) | |
| parent | 954be13467b02889414db600fee8e8b7b76cc2aa (diff) | |
Merged in CR/UI (pull request #100)
active price range
Diffstat (limited to 'src')
| -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> |
