PR Checks / Frontend Typecheck + Tests (pull_request) Canceled after 9s
PR Checks / Backend Smoke (pull_request) Canceled after 0s
PR Checks / Build Backend (no push) (pull_request) Canceled after 0s
PR Checks / Build Frontend (no push) (pull_request) Canceled after 0s
PR Checks / Build Pipeline (no push) (pull_request) Canceled after 0s
PR Checks / AI Code Review (Claude) (pull_request) Canceled after 0s
GIAS phase 6 is "16 plus", and PHASE_GROUPS deliberately files it in the secondary group. The payload helper decided the same question with `"secondary" in phase_text`, which that value does not satisfy — so a sixth-form college was handed the primary bucket and offered infant schools as its peers, with the KS2 metric key to label them. No crash; just a page confidently showing the wrong schools. The decision now lives in similar_schools.is_secondary_phase, beside the PHASE_GROUPS bucket it selects from, so the two cannot drift again. A test pins them together. The same binary assumption had a second output. computeSchoolFlags tests for the substring too, so a 16-plus school renders the primary template, and the composer was labelling the section from the template: "Other primary schools near <sixth form college>" above a row of secondaries. The section now derives its noun from the school's own phase, which also removes the duplicated wording from both composers. A 16-plus school's candidates span the whole secondary group, so no single noun fits and it gets the honest general one. Reported in review on #150. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
159 lines
6.0 KiB
TypeScript
159 lines
6.0 KiB
TypeScript
/**
|
|
* 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, SimilarSchool,
|
|
} 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 { SimilarSchoolsSection } from './SimilarSchoolsSection';
|
|
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;
|
|
/** Nearby schools of a comparable intake. Absent on an older API build. */
|
|
similarSchools?: SimilarSchool[];
|
|
flags: SecondaryFlags;
|
|
}
|
|
|
|
export function SecondarySchoolSections({
|
|
schoolInfo, yearlyData, ofsted, census,
|
|
admissions, admissionsHistory, admissionDistance,
|
|
deprivation, finance, nationalAvg, destinations, similarSchools, 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 (
|
|
<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}
|
|
/>
|
|
)}
|
|
|
|
{/* Destinations follow attainment: they answer "and then what happened",
|
|
which only lands once the results are in view. */}
|
|
{flags.hasKs4Destinations && destinations?.ks4 && (
|
|
<DestinationsSection destinations={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 && (
|
|
<Post16DestinationsSection destinations={destinations.ks5} />
|
|
)}
|
|
|
|
{/* See PrimarySchoolSections: distance and EES admissions are independent
|
|
sources, so either one warrants the section. */}
|
|
{(admissions || admissionDistance) && (
|
|
<SecondaryAdmissionsSection
|
|
admissions={admissions}
|
|
admissionDistance={admissionDistance}
|
|
admissionsHistory={admissionsHistory}
|
|
schoolInfo={schoolInfo}
|
|
/>
|
|
)}
|
|
|
|
{/* See PrimarySchoolSections — same placement, same reason. */}
|
|
<DistanceSection admissionDistance={admissionDistance} schoolInfo={schoolInfo} />
|
|
|
|
{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 />
|
|
)}
|
|
|
|
{/* Last: it is where the reader goes next, not part of this school. */}
|
|
<SimilarSchoolsSection
|
|
urn={schoolInfo.urn}
|
|
schoolName={schoolInfo.school_name}
|
|
phase={schoolInfo.phase}
|
|
thisMetricValue={flags.latestResults?.attainment_8_score ?? null}
|
|
similar={similarSchools}
|
|
/>
|
|
</div>
|
|
);
|
|
}
|