Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance Mentor Filter Functionality #226

Open
wants to merge 4 commits into
base: development
Choose a base branch
from

Conversation

rdwaynedehoedt
Copy link
Contributor

@rdwaynedehoedt rdwaynedehoedt commented Nov 28, 2024

Purpose

The purpose of this PR is to fix #223. This PR introduces a feature to filter mentors by country, available slots, and category, while also providing sorting functionality. It addresses the need for improved mentor filtering and sorting on the Mentor page.

Goals

  • Implement mentor filtering by country and available slots.

Approach

This feature was implemented by:

  1. Fetching mentors and their associated countries and available slots.
  2. Adding state for the selected filters (country, available slots, and category).
  3. Implementing checkboxes for users to filter mentors based on selected countries and available slots.
  4. Adding dynamic dropdowns that expand/collapse when clicking on filter options.
  5. Implementing the sorting function to sort mentors alphabetically by their first name.
  6. Ensuring the mentor list updates based on the selected filters using useEffect hooks.

The logic for available slots ensures that mentors with no available slots (after considering approved mentees) are excluded from the list unless selected by the user.

Screenshots

Screenshot 2024-11-28 at 23 13 35

Checklist

  • This PR doesn't commit any keys, passwords, tokens, usernames, or other secrets.
  • I have read and understood the development best practices guidelines (http://bit.ly/sef-best-practices)
  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation

Test environment

  • OS: macOS
  • Browser: Chrome

Learning

  • To implement the filtering and sorting functionality, I used React hooks such as useState, useEffect, and useInView for infinite scroll.
  • I researched and implemented the dynamic dropdown functionality using conditional rendering to ensure smooth user interaction.

setUniqueCountries([...new Set(countries)]);

const availableSlots = allMentors
.map((mentor) => {
Copy link
Member

Choose a reason for hiding this comment

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

can you check mentor.application object for the availableSlots and approvedMenteesCount. It should be there. @rdwaynedehoedt


if (selectedAvailableSlots.length > 0) {
allMentors = allMentors.filter((mentor) => {
const approvedMenteesCount = mentor?.mentees
Copy link
Member

Choose a reason for hiding this comment

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

Same here.

const handleSortAZ = () => {
const sorted = [...sortedMentors].sort((a, b) =>
a.application.firstName.localeCompare(b.application.firstName)
Copy link
Member

Choose a reason for hiding this comment

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

What's the issue here?

className="form-checkbox h-4 w-4 text-blue-500"
/>
<span className="text-gray-700">
{slots} Slots Available
Copy link
Member

Choose a reason for hiding this comment

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

Slots should be a slider like this,

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mentor Filtration
2 participants