Skip to content

Commit

Permalink
feat: Update filters for product listing page
Browse files Browse the repository at this point in the history
- Replace dollar sign with rupee sign in price filter
- Fix rating filter to correctly filter products based on rating value
- Ensure filters accept and handle integer values correctly
- Improve filter styling and structure
  • Loading branch information
techy4shri committed Aug 7, 2024
1 parent e770ae5 commit d1ec47e
Showing 1 changed file with 31 additions and 12 deletions.
43 changes: 31 additions & 12 deletions src/User/components/Popular_Categories/Filters.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,30 @@ function Filters({
<FilterSection
title="Category"
options={[
"electronics",
"jewelery",
"beauty",
"skin-care",
"grocery",
"men's clothing",
"women's clothing",
"sunglasses",
"home decor"
"beauty", //added all the categories
"fragrances",
"furniture",
"groceries",
"home-decoration",
"kitchen-accessories",
"laptops",
"mens-shirts",
"mens-shoes",
"mens-watches",
"mobile-accessories",
"motorcycle",
"skin-care",
"smartphones",
"sports-accessories",
"sunglasses",
"tablets",
"tops",
"vehicle",
"womens-bags",
"womens-dresses",
"womens-jewellery",
"womens-shoes",
"womens-watches"
]}
onChange={(e) => setCategoryFilter(e.target.value)}
/>
Expand All @@ -51,8 +66,12 @@ function Filters({
{/* Filter section for Rating */}
<FilterSection
title="Rating"
options={["1", "2", "3", "4"]}
onChange={(e) => setRatingFilter(parseInt(e.target.value))}
options={["1", "2", "3", "4", "5"]}
onChange={(e) => {
const value = parseInt(e.target.value, 10); //converting into int from decimal
setRatingFilter(isNaN(value) ? 0.00 : value); //applying condition for rating or higher
}
}
/>
</div>
</aside>
Expand All @@ -68,7 +87,7 @@ function FilterSection({ title, options, onChange }) {
<option value="">All</option>
{options.map((option) => (
<option key={option} value={option}>
{title === "Price" ? `Under $${option}` : option}
{title === "Price" ? `Under ${option}` : option}
</option>
))}
</select>
Expand Down

0 comments on commit d1ec47e

Please sign in to comment.