Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | 2x 99x 25x 6x 33x 33x 33x 33x 33x 32x 29x 28x | /**
* EI-1187 — Teacher Classes header label helper.
*
* Returns the page-level Classes header label. Reflects the user's
* currently-selected semester filter so the header always shows the
* right context:
*
* - Filter = "All" (default) → `{currentYear}-{currentSemester}` —
* same as the pre-EI-1187 behavior (current real-world semester).
* - Filter = a specific semester (Fall / Spring / Summer 1 / Summer 2)
* → `{currentYear}-{selectedSemester}` — reflects what the user
* is actually viewing.
*
* This is the "global Classes-list semester header" gap from TC-1946
* that the original EI-1187 ship reconciled as per-class-only.
*
* Pure function — no React imports — so it's unit-testable in
* isolation.
*/
// Coerce strings + finite numbers (the caller passes `currentYear` from
// `getCurrentSemesterYear()` which returns `today.getFullYear()` — a NUMBER).
// Anything else (null, undefined, object, NaN, Infinity) normalizes to "".
const NORMALIZE = (v) => {
if (typeof v === "string") return v.trim();
if (typeof v === "number" && Number.isFinite(v)) return String(v);
return "";
};
export function classesHeaderLabel({ currentYear, currentSemester, selectedSemester }) {
const year = NORMALIZE(currentYear);
const fallback = NORMALIZE(currentSemester);
const selected = NORMALIZE(selectedSemester);
// Filter is "All" or empty → use current real-world semester.
// Otherwise → use the user's filter choice.
const semester = !selected || selected.toLowerCase() === "all" ? fallback : selected;
if (!year && !semester) return "";
if (!year) return semester;
if (!semester) return year;
return `${year}-${semester}`;
}
|