Skip to content

Fix: Implement product sorting and improve dropdown functionality#122

Merged
Alexandrbig1 merged 2 commits into
OpenCodeChicago:mainfrom
AparAgarwal:fix/backend-sorting-and-styles
Oct 11, 2025
Merged

Fix: Implement product sorting and improve dropdown functionality#122
Alexandrbig1 merged 2 commits into
OpenCodeChicago:mainfrom
AparAgarwal:fix/backend-sorting-and-styles

Conversation

@AparAgarwal

Copy link
Copy Markdown
Contributor

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:

  • Refactored the getProducts API function to support a sort parameter, which triggers a backend endpoint for sorted results. The function now also normalizes the API response for both array and object data.
  • Updated the Redux fetch action in Products.jsx to always include a backend sort key, defaulting to 'feature', and mapped UI sort selections to backend-supported sort keys.

Client-Side Code Simplification:

  • Removed all client-side sorting logic from the Products page; 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:

  • Improved the sort dropdown to remain open during page scroll (per UX requirements), only closing when clicking outside or the close button. Added a close ("X") button and smooth open/close transitions. The dropdown is now more accessible and visually refined.

Product Card UI Enhancement:

  • Updated the product rating display to support fractional (partial) stars, showing more accurate ratings visually with partially filled stars.

Minor UI Consistency:

  • Added cursor-pointer to 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.

@AparAgarwal

Copy link
Copy Markdown
Contributor Author

@AparAgarwal

Copy link
Copy Markdown
Contributor Author

@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.
Thanks!

@AparAgarwal AparAgarwal force-pushed the fix/backend-sorting-and-styles branch from 88ee9a4 to d7252cb Compare October 11, 2025 03:16
@AparAgarwal AparAgarwal force-pushed the fix/backend-sorting-and-styles branch from d7252cb to 8c81c40 Compare October 11, 2025 03:17

@Alexandrbig1 Alexandrbig1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@Alexandrbig1 Alexandrbig1 added frontend Tasks related to the frontend (React, Vite, TailwindCSS, UI components, pages) hacktoberfest Special issue for Hacktoberfest hacktoberfest-2025 Special issue for Hacktoberfest 2025 hacktoberfest-accepted This label indicates that a contribution has been accepted and counts toward Hacktoberfest rewards. axios Promise-based HTTP client react React components & UI logic tailwind Tailwind CSS & styling labels Oct 11, 2025
@Alexandrbig1 Alexandrbig1 added this to the Hacktoberfest 2025 milestone Oct 11, 2025
@Alexandrbig1 Alexandrbig1 merged commit 86732b2 into OpenCodeChicago:main Oct 11, 2025
2 checks passed
@Alexandrbig1

Copy link
Copy Markdown
Contributor

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.
Thanks!

@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.

@AparAgarwal

Copy link
Copy Markdown
Contributor Author

@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 AparAgarwal deleted the fix/backend-sorting-and-styles branch October 12, 2025 10:06
@Alexandrbig1

Copy link
Copy Markdown
Contributor

@AparAgarwal, sounds good! If backend issues arise, reintroducing a client-side fallback is a good plan. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

axios Promise-based HTTP client frontend Tasks related to the frontend (React, Vite, TailwindCSS, UI components, pages) hacktoberfest Special issue for Hacktoberfest hacktoberfest-2025 Special issue for Hacktoberfest 2025 hacktoberfest-accepted This label indicates that a contribution has been accepted and counts toward Hacktoberfest rewards. react React components & UI logic tailwind Tailwind CSS & styling

Development

Successfully merging this pull request may close these issues.

Implement Sorting for Products API Implement Sort Functionality on All Products Page

2 participants