/** * 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, SchoolAdmissionDistance, SchoolDeprivation, SchoolFinance, NationalAverages, SchoolDestinations, } from '@/lib/types'; import { ofstedLegacyAreas } from '@/lib/utils'; import type { SecondaryFlags } from '@/lib/schoolSections'; import { OfstedSection } from './OfstedSection'; import { GcseSection } from './GcseSection'; import { DestinationsSection } from './DestinationsSection'; import { Post16DestinationsSection } from './Post16DestinationsSection'; import { SecondaryAdmissionsSection } from './SecondaryAdmissionsSection'; import { DistanceSection } from './DistanceSection'; 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; /** Needed to tell a year with no published cut-off apart from a year the * school simply was not oversubscribed. */ admissionsHistory: SchoolAdmissions[]; /** Absent — not null — while the admission_distance flag is off. The two * mean different things to the reader and must stay distinguishable: * see SecondaryAdmissionsSection, which words the absence. */ admissionDistance: SchoolAdmissionDistance | null | undefined; deprivation: SchoolDeprivation | null; finance: SchoolFinance | null; nationalAvg: NationalAverages | null; destinations: SchoolDestinations | null; flags: SecondaryFlags; } export function SecondarySchoolSections({ schoolInfo, yearlyData, ofsted, census, admissions, admissionsHistory, admissionDistance, deprivation, finance, nationalAvg, destinations, 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 (
{ofsted && ( )} {flags.hasResults && flags.latestResults && ( )} {/* Destinations follow attainment: they answer "and then what happened", which only lands once the results are in view. */} {flags.hasKs4Destinations && destinations?.ks4 && ( )} {/* Sixth-form schools only. Absent, not placeheld, for a school with no post-16 provision — the question simply does not apply there. */} {flags.hasKs5Destinations && destinations?.ks5 && ( )} {/* See PrimarySchoolSections: distance and EES admissions are independent sources, so either one warrants the section. */} {(admissions || admissionDistance) && ( )} {/* See PrimarySchoolSections — same placement, same reason. */} {yearlyData.length > 1 && ( )} {flags.hasWellbeing && ( )} {flags.hasFinance && finance && ( )}
); }