/** * SecondarySchoolRow Component * Four-line row for secondary school search results * * Line 1: School name · Ofsted badge * Line 2: Phase · Type · Age range · the school page's flags (lib/schoolFacts) * Line 3: Attainment 8 (large) · ±LA avg delta · Pupils * Line 4: LA name · distance */ 'use client'; import type { School } from '@/lib/types'; import { buildOfstedListBadge, getPhaseStyle, schoolUrl, formatAgeRange, isProposedToClose, isSpecialSchool } from '@/lib/utils'; import { schoolFlags, schoolTypeLabel } from '@/lib/schoolFacts'; import styles from './SecondarySchoolRow.module.css'; interface SecondarySchoolRowProps { school: School; isLocationSearch?: boolean; isInCompare?: boolean; onAddToCompare?: (school: School) => void; onRemoveFromCompare?: (urn: number) => void; laAvgAttainment8?: number | null; } export function SecondarySchoolRow({ school, isLocationSearch, isInCompare = false, onAddToCompare, onRemoveFromCompare, laAvgAttainment8, }: SecondarySchoolRowProps) { const handleCompareClick = () => { if (isInCompare) { onRemoveFromCompare?.(school.urn); } else { onAddToCompare?.(school); } }; const ofstedBadge = buildOfstedListBadge(school); const phase = getPhaseStyle(school.phase); const att8 = school.attainment_8_score; // The school's own Attainment 8 is a same-school figure — shown whenever it // exists (special schools included; their type tag on line 2 gives context). // Only the vs-LA-average delta, a benchmark comparison, is dropped for // special schools / PRUs / AP, whose pupils aren't measured against it fairly. const laDelta = att8 != null && !isSpecialSchool(school) && laAvgAttainment8 != null ? att8 - laAvgAttainment8 : null; const typeLabel = schoolTypeLabel(school); const flags = schoolFlags(school); return (