From cd1c649d0f461e38c777fc71eb4a8a124b086614 Mon Sep 17 00:00:00 2001 From: Tudor Date: Fri, 27 Mar 2026 18:30:37 +0000 Subject: [PATCH] fix(frontend): format 6-digit EES academic year codes correctly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit formatAcademicYear now handles both 4-digit (2023→2023/24) and 6-digit EES codes (202526→2025/26). Applied to all year displays: SATs, phonics, admissions, finances, and the yearly results table. Co-Authored-By: Claude Sonnet 4.6 --- nextjs-app/components/SchoolDetailView.tsx | 12 ++++++------ nextjs-app/lib/utils.ts | 8 +++++++- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/nextjs-app/components/SchoolDetailView.tsx b/nextjs-app/components/SchoolDetailView.tsx index 7021297..23ea2ac 100644 --- a/nextjs-app/components/SchoolDetailView.tsx +++ b/nextjs-app/components/SchoolDetailView.tsx @@ -15,7 +15,7 @@ import type { SchoolAdmissions, SenDetail, Phonics, SchoolDeprivation, SchoolFinance, } from '@/lib/types'; -import { formatPercentage, formatProgress } from '@/lib/utils'; +import { formatPercentage, formatProgress, formatAcademicYear } from '@/lib/utils'; import styles from './SchoolDetailView.module.css'; const OFSTED_LABELS: Record = { @@ -331,7 +331,7 @@ export function SchoolDetailView({ {/* SATs Results (merged with Subject Breakdown) */} {latestResults && (
-

SATs Results ({latestResults.year})

+

SATs Results ({formatAcademicYear(latestResults.year)})

End-of-primary-school tests taken by Year 6 pupils. National averages shown for comparison.

@@ -458,7 +458,7 @@ export function SchoolDetailView({ {/* Year 1 Phonics */} {hasPhonics && phonics && (
-

Year 1 Phonics ({phonics.year})

+

Year 1 Phonics ({formatAcademicYear(phonics.year)})

Phonics is a key early reading skill. Children are tested at the end of Year 1.

@@ -511,7 +511,7 @@ export function SchoolDetailView({ {/* How Hard to Get In */} {admissions && (
-

How Hard to Get Into This School ({admissions.year})

+

How Hard to Get Into This School ({formatAcademicYear(admissions.year)})

{admissions.published_admission_number != null && (
@@ -631,7 +631,7 @@ export function SchoolDetailView({ {/* Finances */} {hasFinance && finance && (
-

School Finances ({finance.year})

+

School Finances ({formatAcademicYear(finance.year)})

Per-pupil spending shows how much the school has to spend on each child's education.

@@ -685,7 +685,7 @@ export function SchoolDetailView({ {yearlyData.map((result) => ( - {result.year} + {formatAcademicYear(result.year)} {result.rwm_expected_pct !== null ? formatPercentage(result.rwm_expected_pct) : '-'} {result.rwm_high_pct !== null ? formatPercentage(result.rwm_high_pct) : '-'} {result.reading_progress !== null ? formatProgress(result.reading_progress) : '-'} diff --git a/nextjs-app/lib/utils.ts b/nextjs-app/lib/utils.ts index 409606a..823b7ce 100644 --- a/nextjs-app/lib/utils.ts +++ b/nextjs-app/lib/utils.ts @@ -338,9 +338,15 @@ export function parseQueryString(search: string): Record { // ============================================================================ /** - * Format academic year (e.g., 2023 -> "2023/24") + * Format academic year. + * Handles both 4-digit start years (2023 → "2023/24") and + * 6-digit EES codes (202526 → "2025/26"). */ export function formatAcademicYear(year: number): string { + const s = year.toString(); + if (s.length === 6) { + return `${s.slice(0, 4)}/${s.slice(4)}`; + } const nextYear = (year + 1).toString().slice(-2); return `${year}/${nextYear}`; }