Skip to content

fix: scope mentors page default view to the open cycle's type (#304) - #305

Merged
dricazenck merged 3 commits into
mainfrom
fix/304-mentors-scope-to-open-cycle
Sep 14, 2026
Merged

dricazenck merged 3 commits into
mainfrom
fix/304-mentors-scope-to-open-cycle

Conversation

@yingliu-data

Copy link
Copy Markdown
Contributor

Summary

Fixes #304 — the public mentors page showed mentors who don't belong to the currently open cycle (e.g. a long-term-only mentor, or a mentor with the wrong month's availability, during an Ad-Hoc cycle).

The page loaded the unscoped default list: selectedMentorshipType defaulted to '' and the fetch only sent mentorshipTypes when present in the URL, so the initial request had no type filter and the backend returned all active mentors. The backend already scopes correctly by type and month when the filter is passed, and already returns the open cycle in the response:

"openCycle": { "mentorshipType": "Ad-Hoc", "active": true }

This change uses that: on first load, when the user hasn't explicitly chosen a type, it defaults the mentorship-type filter to openCycle.mentorshipType, which triggers the backend's existing type + month scoping. Applied once via a ref so an explicit "All" selection is preserved.

Only the client can make this decision, since both "default view" and "user chose All" send no mentorshipTypes param — hence a frontend fix rather than a backend default.

Testing

Verified locally end-to-end against the running backend:

  • Ad-Hoc cycle (July): default view auto-applies ?mentorshipTypes=Ad-Hoc and lists only mentors with July ad-hoc availability; a long-term-only mentor is correctly hidden.
  • Long-Term cycle: default view auto-applies ?mentorshipTypes=Long-Term and lists only long-term mentors; an ad-hoc-only mentor is hidden.
  • "All" filter still shows every active mentor.
  • Selecting a specific type still works.

eslint (0 errors), prettier --check, and tsc --noEmit all pass on the changed file.

On first load, default the mentorship-type filter to the open cycle's
type (from the API's openCycle field) so an ad-hoc cycle lists only
ad-hoc mentors and a long-term cycle only long-term mentors. The
backend then applies the full type + month scoping. Applied once via a
ref so an explicit "All" selection is preserved.

Closes #304
@sonarqubecloud

sonarqubecloud Bot commented Jul 4, 2026

Copy link
Copy Markdown

@yingliu-data

Copy link
Copy Markdown
Contributor Author

it's a flaky/environmental E2E failure, not caused by the #304 change,
request manual merge.

@dricazenck
dricazenck self-requested a review September 14, 2026 22:43
@sonarqubecloud

Copy link
Copy Markdown

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

LGTM! 🚀

Summary of Review

  • Default Scoping: On initial page load without active type filters, dynamically scopes mentorshipTypes to the active openCycle.mentorshipType returned by the backend, correctly restricting the default list to mentors available in the open cycle and month.
  • Preserving "All" Filter: Using didApplyCycleDefaultRef ensures the default is applied only on initial load, allowing users to explicitly choose "All" or clear filters without being overridden.
  • Deep Linking / Direct URLs: Direct URLs with explicit query parameters (e.g. ?mentorshipTypes=...) remain untouched.

Thanks for the fix, @yingliu-data!

@dricazenck
dricazenck merged commit 2e9298a into main Sep 14, 2026
4 checks passed
@dricazenck
dricazenck deleted the fix/304-mentors-scope-to-open-cycle branch September 14, 2026 22:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: Public mentors page shows mentors outside the open cycle (default view not scoped to cycle type/month)

3 participants