/** * OfstedSection — shared between the primary and secondary detail pages. * * The headline is the school's current Ofsted status (backend: * fact_ofsted_latest): the report card; or the overall grade still in force, * with the inspection that awarded or confirmed it; or "No overall grade". * A later visit that is not the grade's source gets its own line. Both pages * render the same branches, so neither drops an area judgement (audit M2). * Rule: docs/superpowers/specs/2026-10-05-ofsted-current-status-design.md * * Server component. */ import { ofstedDisplay } from '@/lib/compareLogic'; import { formatOfstedDate, gradeSourceLine, latestVisitLine, showLatestVisitLine } from '@/lib/ofstedStatus'; import type { OfstedInspection } from '@/lib/types'; import { Section, sectionStyles as styles } from './sectionShared'; const OFSTED_LABELS: Record = { 1: 'Outstanding', 2: 'Good', 3: 'Requires Improvement', 4: 'Inadequate', }; const RC_LABELS: Record = { 1: 'Exceptional', 2: 'Strong', 3: 'Expected standard', 4: 'Needs attention', 5: 'Urgent improvement', }; const RC_CATEGORIES = [ { key: 'rc_inclusion' as const, label: 'Inclusion' }, { key: 'rc_curriculum_teaching' as const, label: 'Curriculum & Teaching' }, { key: 'rc_achievement' as const, label: 'Achievement' }, { key: 'rc_attendance_behaviour' as const, label: 'Attendance & Behaviour' }, { key: 'rc_personal_development' as const, label: 'Personal Development' }, { key: 'rc_leadership_governance' as const, label: 'Leadership & Governance' }, { key: 'rc_early_years' as const, label: 'Early Years' }, { key: 'rc_sixth_form' as const, label: 'Sixth Form' }, ]; export interface OfstedSectionProps { ofsted: OfstedInspection; urn: number; isReportCard: boolean; ofstedInspectedDate: string | null; oeifAllSameGrade: boolean; oeifAreas: { label: string; value: number }[]; } export function OfstedSection({ ofsted, urn, isReportCard, ofstedInspectedDate, oeifAllSameGrade, oeifAreas, }: OfstedSectionProps) { const display = ofstedDisplay(ofsted); return (

{isReportCard ? 'Ofsted Report Card' : 'Ofsted Rating'} {ofstedInspectedDate && ( Inspected {new Date(ofstedInspectedDate).toLocaleDateString('en-GB', { day: 'numeric', month: 'long', year: 'numeric' })} )} Ofsted reports ↗

{isReportCard ? ( /* ── New Report Card layout ── */ <>

From November 2025, Ofsted replaced single overall grades with Report Cards rating schools across several areas.

{ofsted.rc_safeguarding_met != null && (
Safeguarding
{ofsted.rc_safeguarding_met ? 'Met' : 'Not met'}
)} {RC_CATEGORIES.map(({ key, label }) => { const value = ofsted[key] as number | null; return value != null ? (
{label}
{RC_LABELS[value]}
) : null; })}
) : ( <>
{display.kind === 'graded' || display.kind === 'confirmed' ? ( <> {display.gradeLabel} {ofsted.previous_overall != null && ofsted.previous_overall !== display.grade && ( Previously: {OFSTED_LABELS[ofsted.previous_overall]} )} ) : ( No overall grade )}

{ofsted.current_grade ? gradeSourceLine(ofsted.current_grade) : 'Ofsted stopped giving overall grades in September 2024.'}

{showLatestVisitLine(ofsted) && ofsted.latest_visit && (

Latest visit: {latestVisitLine(ofsted.latest_visit)}

)} {oeifAllSameGrade && (display.kind === 'graded' || display.kind === 'confirmed') ? (

Rated {display.gradeLabel} across all inspected areas: Quality of Teaching, Behaviour, Pupils' Development and Leadership.

) : oeifAreas.length > 0 ? ( <> {ofsted.inspection_date && ofsted.inspection_date !== ofsted.latest_visit?.date && (

Area judgements from the graded inspection, {formatOfstedDate(ofsted.inspection_date)}.

)}
{oeifAreas.map(({ label, value }) => (
{label}
{OFSTED_LABELS[value]}
))}
) : null} )}
); }