/** * HistorySection — results over time (chart plus historical table). * Primary pages; the secondary equivalent is SecondaryHistorySection (the two * were only 40% similar). Server component. */ import dynamic from 'next/dynamic'; import type { School, SchoolResult, NationalAverages } from '@/lib/types'; import { formatPercentage, formatProgress, formatAcademicYear } from '@/lib/utils'; import { Section, sectionStyles as styles } from './sectionShared'; const PerformanceChart = dynamic( () => import('../PerformanceChart').then((m) => m.PerformanceChart), { ssr: false }, ); const SatsChart = dynamic(() => import('../SatsChart'), { ssr: false }); export function HistorySection({ yearlyData, schoolInfo, nationalAvg, primaryAvg, secondaryAvg, isAllThrough, isPrimary, isSecondary, hasKS2Results, hasKS4Results, suppressKs2Comparison, suppressKs4Comparison, }: { yearlyData: SchoolResult[]; schoolInfo: School; nationalAvg: NationalAverages | null; primaryAvg: Record; secondaryAvg: Record; isAllThrough: boolean; isPrimary: boolean; isSecondary: boolean; hasKS2Results: boolean; hasKS4Results: boolean; suppressKs2Comparison: boolean; suppressKs4Comparison: boolean; }) { return (

Results Over Time

{isAllThrough ? ( // All-through: KS2 and KS4 trends are on different scales and have // different gap stories, so render them as two stacked charts // rather than crowding 8+ series onto one axis. <> {hasKS2Results && ( <>

Primary — KS2 SATs

)} {hasKS4Results && ( <>

Secondary — GCSEs

)} ) : (
)} {yearlyData.length > 1 && (
View raw year-by-year data
{isAllThrough ? ( <> ) : isSecondary ? ( <> ) : ( <> )} {yearlyData.map((result) => ( {isAllThrough ? ( <> ) : isSecondary ? ( <> ) : ( <> )} ))}
YearRWM (expected %) Exceeding (%) Attainment 8 Progress 8 English & Maths Grade 4+Attainment 8 Progress 8 English & Maths Grade 4+ English & Maths Grade 5+Reading, Writing & Maths (expected %) Exceeding expected (%) Reading Progress Writing Progress Maths Progress
{formatAcademicYear(result.year)}{result.rwm_expected_pct !== null ? formatPercentage(result.rwm_expected_pct) : '-'} {result.rwm_high_pct !== null ? formatPercentage(result.rwm_high_pct) : '-'} {result.attainment_8_score !== null ? result.attainment_8_score.toFixed(1) : '-'} {result.progress_8_score !== null ? formatProgress(result.progress_8_score) : '-'} {result.english_maths_standard_pass_pct !== null ? formatPercentage(result.english_maths_standard_pass_pct) : '-'}{result.attainment_8_score !== null ? result.attainment_8_score.toFixed(1) : '-'} {result.progress_8_score !== null ? formatProgress(result.progress_8_score) : '-'} {result.english_maths_standard_pass_pct !== null ? formatPercentage(result.english_maths_standard_pass_pct) : '-'} {result.english_maths_strong_pass_pct !== null ? formatPercentage(result.english_maths_strong_pass_pct) : '-'}{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) : '-'} {result.writing_progress !== null ? formatProgress(result.writing_progress) : '-'} {result.maths_progress !== null ? formatProgress(result.maths_progress) : '-'}
)}
); }