/** * AdmissionsSection — primary detail pages. * * Not shared with the secondary page: the two versions were only 14% similar * (this one carries the year/trend toggle and the offer-rate chart; the * secondary one is a much simpler panel). See SecondaryAdmissionsSection. * * Server component. The year/trend toggle is delegated to the small * AdmissionsViewToggle client island, which receives both views as * server-rendered children. When there is only one year of offer data no * toggle renders at all, so such pages ship zero admissions JavaScript. */ import type { ReactNode } from 'react'; import type { SchoolAdmissions } from '@/lib/types'; import { formatAcademicYear, formatPercentage } from '@/lib/utils'; import { summariseAdmissions } from '@/lib/compareLogic'; import { Section, sectionStyles as styles } from './sectionShared'; import { AdmissionsViewToggle } from './AdmissionsViewToggle'; import { AdmissionsTrendChart } from './charts'; export function AdmissionsSection({ admissions, admissionsHistory, isAllThrough, }: { admissions: SchoolAdmissions; admissionsHistory: SchoolAdmissions[]; isAllThrough: boolean; }) { // Trend toggle only appears with ≥2 years carrying an offer rate. const admissionsOfferYears = admissionsHistory.filter((h) => h.first_preference_offer_pct != null).length; const showAdmissionsTrend = admissionsOfferYears >= 2; // Banded interpretation of the first-choice offer rate ("More than half of // first choices missed out" etc.) — the same banding the compare screen // uses, so a low offer rate reads as how severe it actually is. const admissionsSummary = summariseAdmissions(admissions); const title = <>Admissions{!showAdmissionsTrend && ` (${formatAcademicYear(admissions.year)})`}>; {/* All-through admissions data covers a single entry point (usually the Year 7 secondary intake), not reception — say so, or a parent could read these as the whole-school figures. */} const subtitle: ReactNode = isAllThrough && admissions.school_phase ? (
These figures are for {admissions.school_phase.toLowerCase()} entry {/secondary/i.test(admissions.school_phase) ? ' (Year 7)' : /primary/i.test(admissions.school_phase) ? ' (Reception)' : ''}.
) : null; const yearView = ( <>{admissionsSummary.chip.text}
)} > ); const trendView = ( <>This year ({formatAcademicYear(admissions.year)}),{' '} {admissions.first_preference_applications != null && ( <>{admissions.first_preference_applications} families put it first for > )} {admissions.places_offered != null && <>{admissions.places_offered} places>} {admissions.total_applications != null && ` — ${admissions.total_applications.toLocaleString()} applications in total`}.
> ); return (