From 21a22d686e71d8eb470d158f93ba80e43b7b221f Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Fri, 2 Dec 2022 17:32:29 +0700 Subject: input range filter, sort by ready stock --- src/components/Filter.js | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) (limited to 'src/components/Filter.js') diff --git a/src/components/Filter.js b/src/components/Filter.js index d2a5bf1b..4727fb9d 100644 --- a/src/components/Filter.js +++ b/src/components/Filter.js @@ -29,8 +29,8 @@ const Filter = ({ let filterRoutePrefix = '?'; if (selectedBrand) filterRoute.push(`brand=${selectedBrand}`); if (selectedCategory) filterRoute.push(`category=${selectedCategory}`); - if (priceFrom > 0) filterRoute.push(`price_from=${priceFrom}`); - if (priceTo > 0) filterRoute.push(`price_to=${priceTo}`); + if (priceFrom) filterRoute.push(`price_from=${priceFrom}`); + if (priceTo) filterRoute.push(`price_to=${priceTo}`); if (orderBy) filterRoute.push(`order_by=${orderBy}`); if (defaultRoute.includes('?')) filterRoutePrefix = '&'; @@ -70,8 +70,8 @@ const Filter = ({ const reset = () => { setSelectedBrand(''); setSelectedCategory(''); - setPriceFrom(0); - setPriceTo(0); + setPriceFrom(''); + setPriceTo(''); setOrderBy(''); } @@ -92,13 +92,19 @@ const Filter = ({
+ {selectedBrand || selectedCategory || priceFrom || priceTo || orderBy ? ( + + ) : ''} {!disableFilter.includes('orderBy') ? (
-
- - - +
+ + + +
) : ''} @@ -128,20 +134,15 @@ const Filter = ({
- setPriceFrom(e.target.value)}/> + setPriceFrom(e.target.value)}/> - setPriceTo(e.target.value)}/> + setPriceTo(e.target.value)}/>
) : ''} - {selectedBrand || selectedCategory || priceFrom > 0 || priceTo > 0 || orderBy ? ( - - ) : ''}
) -- cgit v1.2.3