PR Checks / Frontend Typecheck + Tests (pull_request) Successful in 1m5s
PR Checks / Backend Smoke (pull_request) Successful in 8s
PR Checks / Build Backend (no push) (pull_request) Successful in 13s
PR Checks / Build Frontend (no push) (pull_request) Successful in 45s
PR Checks / Build Pipeline (no push) (pull_request) Successful in 11s
PR Checks / AI Code Review (Claude) (pull_request) Successful in 1m59s
The admissions card measured 1503px on a live school page — half the height of every section put together, and nearly three times the next largest — with its default view rendering as four tiles adrift in about 1080px of blank card. The cause was a layout trick meeting content it was never sized for. The admissions views are stacked in one grid cell so switching them never shifts layout, and the hidden ones keep their box: only visibility is dropped. That works while the views are comparable. The distance view added in #102 carries a chart, a table and a map, came to 1402px against the tile grid's 316px, and pinned every other view to its height — including the one that renders by default, which nobody had clicked. Rather than only unpinning it, the detail moves out. Every other topic on the page is a section with a nav entry, and "how close did we need to live, and would we have got in?" is a topic, not a variant reading of the intake figures. The headline number stays on the Admissions tile where the intake story is; the record behind it now lives in a Distance section directly below. admissions 1503px -> 554px distance new -> 743px (median section on the page is ~528px) Three further changes, each of which also makes the content better rather than only shorter: * The map renders on request. Before a postcode is entered it is a circle drawn round a school, and it costs a Leaflet bundle and 240px to say so; a successful check opens it automatically, which is the point at which it starts answering something. Map height 320px -> 240px. * The chart appears only at the four published years that let the summary state a direction. Below that we already refuse to call the series a trend, and a line through three points asserts one regardless of what the sentence beneath it admits. The table carries those years anyway, with the reasons a line cannot show. * Three caveat paragraphs become one. They said walking-route twice and made the same point about priorities in two voices. It now sits in CutoffDistanceDetail rather than inside the check, so it still renders for a school with coordinates missing, where there is a table but no map and no check. The new e2e guard asserts no section exceeds 2.5x the median section height. Measuring the card's internals cannot catch this: the tile grid is flex: 1, so it absorbs the stretch and every box still looks full. The first version of this test targeted an arbitrary primary, passed against the live bug, and proved nothing; pointed at a school that actually holds cut-off history it fails on staging with "#admissions is 1459px against a 526px median". Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WDvkyqqHABm4bmth2kjAxE
157 lines
5.7 KiB
TypeScript
157 lines
5.7 KiB
TypeScript
/**
|
|
* 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, SchoolAdmissionDistance, 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 { DistanceSection } from './DistanceSection';
|
|
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[];
|
|
admissionDistance: SchoolAdmissionDistance | null;
|
|
admissionDistanceHistory: SchoolAdmissionDistance[];
|
|
deprivation: SchoolDeprivation | null;
|
|
finance: SchoolFinance | null;
|
|
nationalAvg: NationalAverages | null;
|
|
flags: SchoolFlags;
|
|
}
|
|
|
|
export function PrimarySchoolSections({
|
|
schoolInfo, yearlyData, absenceData, ofsted, census,
|
|
admissions, admissionsHistory, admissionDistance, admissionDistanceHistory,
|
|
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 && (
|
|
<OfstedSection
|
|
ofsted={ofsted}
|
|
urn={schoolInfo.urn}
|
|
isReportCard={isReportCard}
|
|
ofstedInspectedDate={ofstedInspectedDate}
|
|
oeifAllSameGrade={oeifAllSameGrade}
|
|
oeifAreas={oeifAreas}
|
|
variant="primary"
|
|
/>
|
|
)}
|
|
|
|
{flags.hasAnyResults && flags.latestResults && (
|
|
<ResultsSection
|
|
latestResults={flags.latestResults}
|
|
schoolInfo={schoolInfo}
|
|
primaryAvg={primaryAvg}
|
|
secondaryAvg={secondaryAvg}
|
|
isAllThrough={flags.isAllThrough}
|
|
isSecondary={flags.isSecondary}
|
|
isSpecial={flags.isSpecial}
|
|
hasKS2Results={flags.hasKS2Results}
|
|
hasKS4Results={flags.hasKS4Results}
|
|
ks2Placeholder={flags.ks2Placeholder}
|
|
suppressKs2Comparison={flags.suppressKs2Comparison}
|
|
suppressKs4Comparison={flags.suppressKs4Comparison}
|
|
/>
|
|
)}
|
|
|
|
{/* Either source is enough to justify the section. The cut-off distance
|
|
and the EES admissions figures come from different places and a
|
|
minority of schools have one without the other — gating on admissions
|
|
alone would hide a published distance on those pages. */}
|
|
{(admissions || admissionDistance) && (
|
|
<AdmissionsSection
|
|
admissions={admissions}
|
|
admissionsHistory={admissionsHistory}
|
|
admissionDistance={admissionDistance}
|
|
isAllThrough={flags.isAllThrough}
|
|
/>
|
|
)}
|
|
|
|
{/* Its own section, directly after Admissions: it answers the question
|
|
the tile above raises. */}
|
|
<DistanceSection
|
|
admissionDistanceHistory={admissionDistanceHistory}
|
|
admissionsHistory={admissionsHistory}
|
|
schoolInfo={schoolInfo}
|
|
/>
|
|
|
|
{flags.hasInclusionData && (
|
|
<InclusionSection
|
|
latestResults={flags.latestResults}
|
|
census={census}
|
|
hasGenderSplit={flags.hasGenderSplit}
|
|
primaryAvg={primaryAvg}
|
|
/>
|
|
)}
|
|
|
|
{yearlyData.length > 0 && (
|
|
<HistorySection
|
|
yearlyData={yearlyData}
|
|
schoolInfo={schoolInfo}
|
|
nationalAvg={nationalAvg}
|
|
primaryAvg={primaryAvg}
|
|
secondaryAvg={secondaryAvg}
|
|
isAllThrough={flags.isAllThrough}
|
|
isPrimary={flags.isPrimary}
|
|
isSecondary={flags.isSecondary}
|
|
hasKS2Results={flags.hasKS2Results}
|
|
hasKS4Results={flags.hasKS4Results}
|
|
suppressKs2Comparison={flags.suppressKs2Comparison}
|
|
suppressKs4Comparison={flags.suppressKs4Comparison}
|
|
/>
|
|
)}
|
|
|
|
{flags.hasSchoolLife && (
|
|
<SchoolLifeSection absenceData={absenceData} primaryAvg={primaryAvg} />
|
|
)}
|
|
|
|
{flags.hasDeprivation && deprivation && (
|
|
<LocalAreaSection deprivation={deprivation} />
|
|
)}
|
|
|
|
{flags.hasFinance && finance && <FinancesSection finance={finance} />}
|
|
</>
|
|
);
|
|
}
|