/** * PrimarySchoolSections — the section sequence for primary and all-through * detail pages. Server component. * * All-through schools route here rather than to SecondarySchoolSections, * because this list renders BOTH the KS2 and KS4 blocks (ResultsSection and * HistorySection branch on isAllThrough); the secondary list is KS4-only and * would silently drop their SATs data. * * The render conditions here MUST match buildNavItems in lib/schoolSections, * or the sticky nav will link to sections that do not exist. */ import type { School, SchoolResult, AbsenceData, OfstedInspection, SchoolCensus, SchoolAdmissions, SchoolDeprivation, SchoolFinance, NationalAverages, } from '@/lib/types'; import { ofstedLegacyAreas } from '@/lib/utils'; import type { SchoolFlags } from '@/lib/schoolSections'; import { OfstedSection } from './OfstedSection'; import { ResultsSection } from './ResultsSection'; import { AdmissionsSection } from './AdmissionsSection'; import { InclusionSection } from './InclusionSection'; import { HistorySection } from './HistorySection'; import { SchoolLifeSection } from './SchoolLifeSection'; import { LocalAreaSection } from './LocalAreaSection'; import { FinancesSection } from './FinancesSection'; export interface PrimarySchoolSectionsProps { schoolInfo: School; yearlyData: SchoolResult[]; absenceData: AbsenceData | null; ofsted: OfstedInspection | null; census: SchoolCensus | null; admissions: SchoolAdmissions | null; admissionsHistory: SchoolAdmissions[]; deprivation: SchoolDeprivation | null; finance: SchoolFinance | null; nationalAvg: NationalAverages | null; flags: SchoolFlags; } export function PrimarySchoolSections({ schoolInfo, yearlyData, absenceData, ofsted, census, admissions, admissionsHistory, deprivation, finance, nationalAvg, flags, }: PrimarySchoolSectionsProps) { const primaryAvg = nationalAvg?.primary ?? {}; const secondaryAvg = nationalAvg?.secondary ?? {}; const isReportCard = !!(ofsted?.report_card && Object.keys(ofsted.report_card).length > 0); // Report cards are dated by their own inspection (rc_inspection_date), never // the legacy inspection_date (report cards exist only from Nov 2025). const ofstedInspectedDate = isReportCard ? ofsted?.rc_inspection_date ?? null : ofsted?.inspection_date ?? null; const oeifAreas = ofsted ? ofstedLegacyAreas(ofsted) : []; const oeifAllSameGrade = !!ofsted && !isReportCard && oeifAreas.length >= 3 && oeifAreas.every((a) => a.value === ofsted.overall_effectiveness); return ( <> {ofsted && ( )} {flags.hasAnyResults && flags.latestResults && ( )} {admissions && ( )} {flags.hasInclusionData && ( )} {yearlyData.length > 0 && ( )} {flags.hasSchoolLife && ( )} {flags.hasDeprivation && deprivation && ( )} {flags.hasFinance && finance && } ); }