/** * SecondarySchoolSections — the section sequence for secondary detail pages. * Server component. * * Wrapped in `.secondaryScope`, which activates the secondary-only style * overrides in schoolSections.module.css. Those rules target class names the * primary page also uses (.card, .sectionTitle, .metricCard …), so scoping is * what keeps them from restyling primary pages. * * The render conditions here MUST match buildSecondaryNavItems 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 { SecondaryFlags } from '@/lib/schoolSections'; import { OfstedSection } from './OfstedSection'; import { GcseSection } from './GcseSection'; import { SecondaryAdmissionsSection } from './SecondaryAdmissionsSection'; import { SecondaryHistorySection } from './SecondaryHistorySection'; import { WellbeingSection } from './WellbeingSection'; import { FinancesSection } from './FinancesSection'; import styles from './schoolSections.module.css'; export interface SecondarySchoolSectionsProps { schoolInfo: School; yearlyData: SchoolResult[]; absenceData: AbsenceData | null; ofsted: OfstedInspection | null; census: SchoolCensus | null; admissions: SchoolAdmissions | null; deprivation: SchoolDeprivation | null; finance: SchoolFinance | null; nationalAvg: NationalAverages | null; flags: SecondaryFlags; } export function SecondarySchoolSections({ schoolInfo, yearlyData, ofsted, census, admissions, deprivation, finance, nationalAvg, flags, }: SecondarySchoolSectionsProps) { const secondaryAvg = nationalAvg?.secondary ?? {}; const isReportCard = !!(ofsted?.report_card && Object.keys(ofsted.report_card).length > 0); 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 (