Skip to content

FAC-WEB fix: scope student courses page to current term#157

Merged
y4nder merged 1 commit into
developfrom
fac-web-student-current-term
Apr 25, 2026
Merged

FAC-WEB fix: scope student courses page to current term#157
y4nder merged 1 commit into
developfrom
fac-web-student-current-term

Conversation

@y4nder

@y4nder y4nder commented Apr 25, 2026

Copy link
Copy Markdown
Member

Summary

GET /enrollments/me returns 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 /semesters now returns startDate/endDate per term, so we can resolve the current academic term client-side without any backend change, then filter enrollments by matching semester.id.

What changed

  • features/enrollments/lib/resolve-current-semester.ts — pure helper. Picks the semester where startDate <= now < endDate; falls back to the most recent by startDate DESC so between-term windows still render the student's last known term instead of going blank.
  • features/enrollments/hooks/use-current-student-term.ts — orchestrates useMe → 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.tsSemesterOptionDto gains startDate: 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 — filters enrolledCourses by currentSemester.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 — clean
  • bun run lint — clean
  • bun run build — all routes built including /student/courses
  • Manual local verification as a student

Notes

  • No backend change in this PR — we consume the startDate/endDate FAC-146 added and match by semester.id client-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 a semesterId? query param + campus-scoped default to GET /enrollments/me in api.faculytics.
  • Unchanged: Faculty / Dean / Chairperson / Campus Head dashboards — they already have a working semester switcher.

Closes #156

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

vercel Bot commented Apr 25, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
app-faculytics Ready Ready Preview, Comment Apr 25, 2026 2:44am

@y4nder y4nder self-assigned this Apr 25, 2026
@y4nder y4nder merged commit 16b4189 into develop Apr 25, 2026
3 checks passed
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.
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.

FAC-WEB fix: students see enrollments from all semesters (scope /enrollments/me to current term)

1 participant