FAC-WEB fix: scope student courses page to current term#157
Merged
Conversation
GET /enrollments/me returns every semester the student has ever been
enrolled in. Before S12526 backfill each student had exactly one term
of data, so listing everything was fine — but once past semesters land
alongside the current one, the Courses page would render duplicate
entries and the "enrolled in N courses this semester" copy becomes a
lie.
Resolve the current academic term client-side (no backend change
needed — FAC-146 exposed startDate/endDate on GET /semesters) and
filter the enrollments list to matching semester.id.
- resolveCurrentSemester(): picks the semester where startDate <= now
< endDate, falls back to the most recent by startDate DESC so the
page isn't blank between terms.
- useCurrentStudentTerm(): chains useMe + useSemesterOptions to
resolve the student's current term; returns a discriminated union
so the page can handle loading / error / no-campus / no-semester /
ready cleanly.
- Subtitle now shows the actual term label ("Semester 2, AY 2025-2026").
- SemesterOptionDto type extended with startDate/endDate to match
the FAC-146 API response.
Closes #156.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
5 tasks
y4nder
added a commit
that referenced
this pull request
Apr 25, 2026
GET /enrollments/me returns every semester the student has ever been
enrolled in. Before S12526 backfill each student had exactly one term
of data, so listing everything was fine — but once past semesters land
alongside the current one, the Courses page would render duplicate
entries and the "enrolled in N courses this semester" copy becomes a
lie.
Resolve the current academic term client-side (no backend change
needed — FAC-146 exposed startDate/endDate on GET /semesters) and
filter the enrollments list to matching semester.id.
- resolveCurrentSemester(): picks the semester where startDate <= now
< endDate, falls back to the most recent by startDate DESC so the
page isn't blank between terms.
- useCurrentStudentTerm(): chains useMe + useSemesterOptions to
resolve the student's current term; returns a discriminated union
so the page can handle loading / error / no-campus / no-semester /
ready cleanly.
- Subtitle now shows the actual term label ("Semester 2, AY 2025-2026").
- SemesterOptionDto type extended with startDate/endDate to match
the FAC-146 API response.
Closes #156.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
GET /enrollments/mereturns every enrollment the student has ever had. Before S12526 backfill each student had data for exactly one term, so listing everything was fine — but once past semesters live alongside the current one, the Courses page would render duplicate entries and the "enrolled in N courses this semester" subtitle becomes factually wrong.FAC-146 on the API unblocked a pure-frontend fix:
GET /semestersnow returnsstartDate/endDateper term, so we can resolve the current academic term client-side without any backend change, then filter enrollments by matchingsemester.id.What changed
features/enrollments/lib/resolve-current-semester.ts— pure helper. Picks the semester wherestartDate <= now < endDate; falls back to the most recent bystartDate DESCso between-term windows still render the student's last known term instead of going blank.features/enrollments/hooks/use-current-student-term.ts— orchestratesuseMe → useSemesterOptions(campusId) → resolveCurrentSemester. Returns a discriminated union (loading | error | no-campus | no-semester | ready) so the page can handle every state explicitly.features/faculty-analytics/types/index.ts—SemesterOptionDtogainsstartDate: string+endDate?: string, matching the FAC-146 API response.features/enrollments/index.ts— re-exports the new hook and helper.app/(dashboard)/student/courses/page.tsx— filtersenrolledCoursesbycurrentSemester.id, and the subtitle now shows the real term label (e.g. "You are currently enrolled in 4 courses for Semester 2, AY 2025-2026.").Test plan
bun run typecheck— cleanbun run lint— cleanbun run build— all routes built including/student/coursesNotes
startDate/endDateFAC-146 added and match bysemester.idclient-side. For realistic enrollment sizes (≤20 rows) the overhead of returning + filtering is negligible. If we ever need server-side scoping for efficiency or stricter data isolation, it's a straightforward follow-up: add asemesterId?query param + campus-scoped default toGET /enrollments/mein api.faculytics.Closes #156