Fix: Implement product sorting and improve dropdown functionality#122
Conversation
|
@Alexandrbig1 I’ve removed the client-side filtering logic for the sake of code simplification. However, if needed, I can reintroduce it as a fallback in case of backend response errors. Please review the changes and let me know your thoughts. |
88ee9a4 to
d7252cb
Compare
d7252cb to
8c81c40
Compare
Alexandrbig1
left a comment
There was a problem hiding this comment.
Thank you for your contribution, and congrats on your PR being approved!
We’re excited to have your work as part of Open Code Chicago’s Hacktoberfest 2025 project.
@AparAgarwal, removing client-side filtering is fine for simplicity, but note that a backend error could leave no products. Reintroduce a client-side fallback if reliability matters. Otherwise, keep it removed. Please decide. |
Thanks for the clarification. Given the current priorities, I’ll keep the client-side filtering removed to keep the codebase simpler. If we encounter backend reliability issues or missing product data in the future, The client-side fallback can be reintroduced as needed. |
|
@AparAgarwal, sounds good! If backend issues arise, reintroducing a client-side fallback is a good plan. Thanks. |
This pull request refactors product sorting to be handled server-side instead of client-side, updates the product sorting API and UI, and improves several UI components for better user experience and accessibility. The most significant changes include moving sorting logic to the backend, updating the API and Redux actions to support this, improving the sort dropdown menu, and enhancing the product rating display.
Backend Sorting & API Integration:
getProductsAPI function to support asortparameter, which triggers a backend endpoint for sorted results. The function now also normalizes the API response for both array and object data.Products.jsxto always include a backend sort key, defaulting to'feature', and mapped UI sort selections to backend-supported sort keys.Client-Side Code Simplification:
Productspage; now, the displayed products are directly sliced from the filtered list, relying on the backend to provide the sorted data.Sort Dropdown UI/UX Improvements:
Product Card UI Enhancement:
Minor UI Consistency:
cursor-pointerto clickable elements for better visual feedback.These changes together ensure that product sorting is more efficient, accurate, and user-friendly, leveraging backend capabilities and improving the frontend experience.