2026-08-02 21:39:21 +01:00
|
|
|
/**
|
|
|
|
|
* 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,
|
2026-08-15 22:48:30 +01:00
|
|
|
SchoolAdmissions, SchoolAdmissionDistance, SchoolDeprivation, SchoolFinance, NationalAverages,
|
2026-08-02 21:39:21 +01:00
|
|
|
} 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';
|
2026-08-20 14:54:02 +01:00
|
|
|
import { DistanceSection } from './DistanceSection';
|
2026-08-02 21:39:21 +01:00
|
|
|
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;
|
2026-08-16 13:42:06 +01:00
|
|
|
/** Needed to tell a year with no published cut-off apart from a year the
|
|
|
|
|
* school simply was not oversubscribed. */
|
|
|
|
|
admissionsHistory: SchoolAdmissions[];
|
2026-08-15 22:48:30 +01:00
|
|
|
admissionDistance: SchoolAdmissionDistance | null;
|
2026-08-16 13:42:06 +01:00
|
|
|
admissionDistanceHistory: SchoolAdmissionDistance[];
|
2026-08-02 21:39:21 +01:00
|
|
|
deprivation: SchoolDeprivation | null;
|
|
|
|
|
finance: SchoolFinance | null;
|
|
|
|
|
nationalAvg: NationalAverages | null;
|
|
|
|
|
flags: SecondaryFlags;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function SecondarySchoolSections({
|
|
|
|
|
schoolInfo, yearlyData, ofsted, census,
|
2026-08-16 13:42:06 +01:00
|
|
|
admissions, admissionsHistory, admissionDistance, admissionDistanceHistory,
|
|
|
|
|
deprivation, finance, nationalAvg, flags,
|
2026-08-02 21:39:21 +01:00
|
|
|
}: 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 (
|
|
|
|
|
<div className={styles.secondaryScope}>
|
|
|
|
|
{ofsted && (
|
|
|
|
|
<OfstedSection
|
|
|
|
|
ofsted={ofsted}
|
|
|
|
|
urn={schoolInfo.urn}
|
|
|
|
|
isReportCard={isReportCard}
|
|
|
|
|
ofstedInspectedDate={ofstedInspectedDate}
|
|
|
|
|
oeifAllSameGrade={oeifAllSameGrade}
|
|
|
|
|
oeifAreas={oeifAreas}
|
|
|
|
|
variant="secondary"
|
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
{flags.hasResults && flags.latestResults && (
|
|
|
|
|
<GcseSection
|
|
|
|
|
latestResults={flags.latestResults}
|
|
|
|
|
schoolInfo={schoolInfo}
|
|
|
|
|
secondaryAvg={secondaryAvg}
|
|
|
|
|
p8Suspended={flags.p8Suspended}
|
|
|
|
|
suppressComparison={flags.suppressComparison}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
|
2026-08-15 22:48:30 +01:00
|
|
|
{/* See PrimarySchoolSections: distance and EES admissions are independent
|
|
|
|
|
sources, so either one warrants the section. */}
|
|
|
|
|
{(admissions || admissionDistance) && (
|
2026-08-02 21:39:21 +01:00
|
|
|
<SecondaryAdmissionsSection
|
|
|
|
|
admissions={admissions}
|
2026-08-15 22:48:30 +01:00
|
|
|
admissionDistance={admissionDistance}
|
2026-08-16 13:42:06 +01:00
|
|
|
admissionsHistory={admissionsHistory}
|
2026-08-02 21:39:21 +01:00
|
|
|
schoolInfo={schoolInfo}
|
|
|
|
|
hasSixthForm={flags.hasSixthForm}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
|
2026-08-20 14:54:02 +01:00
|
|
|
{/* See PrimarySchoolSections — same placement, same reason. */}
|
|
|
|
|
<DistanceSection
|
|
|
|
|
admissionDistanceHistory={admissionDistanceHistory}
|
|
|
|
|
admissionsHistory={admissionsHistory}
|
|
|
|
|
schoolInfo={schoolInfo}
|
|
|
|
|
/>
|
|
|
|
|
|
2026-08-02 21:39:21 +01:00
|
|
|
{yearlyData.length > 1 && (
|
|
|
|
|
<SecondaryHistorySection
|
|
|
|
|
yearlyData={yearlyData}
|
|
|
|
|
schoolInfo={schoolInfo}
|
|
|
|
|
nationalAvg={nationalAvg}
|
|
|
|
|
secondaryAvg={secondaryAvg}
|
|
|
|
|
suppressComparison={flags.suppressComparison}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
{flags.hasWellbeing && (
|
|
|
|
|
<WellbeingSection
|
|
|
|
|
latestResults={flags.latestResults}
|
|
|
|
|
census={census}
|
|
|
|
|
schoolInfo={schoolInfo}
|
|
|
|
|
deprivation={deprivation}
|
|
|
|
|
hasDeprivation={flags.hasDeprivation}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
{flags.hasFinance && finance && (
|
|
|
|
|
<FinancesSection finance={finance} showPremises />
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|