/** * SchoolRow Component * Four-line row for primary school search results * * Line 1: School name · Ofsted badge (framework-aware) * Line 2: School type · Age range · Denomination · Gender * Line 3: Reading, Writing & Maths % · trend arrow · vs-national delta · Pupils * Line 4: Local authority · Distance */ import type { School } from '@/lib/types'; import { formatPercentage, calculateTrend, getPhaseStyle, schoolUrl, buildOfstedListBadge, formatAgeRange, isProposedToClose, isSpecialSchool } from '@/lib/utils'; import styles from './SchoolRow.module.css'; interface SchoolRowProps { school: School; isLocationSearch?: boolean; isInCompare?: boolean; onAddToCompare?: (school: School) => void; onRemoveFromCompare?: (urn: number) => void; nationalAvgRwm?: number | null; } export function SchoolRow({ school, isLocationSearch, isInCompare = false, onAddToCompare, onRemoveFromCompare, nationalAvgRwm, }: SchoolRowProps) { const trend = calculateTrend(school.rwm_expected_pct, school.prev_rwm_expected_pct); const phase = getPhaseStyle(school.phase); const ofstedBadge = buildOfstedListBadge(school); const showGender = school.gender && school.gender.toLowerCase() !== 'mixed'; const showDenomination = school.religious_denomination && school.religious_denomination !== 'Does not apply'; // Special schools / PRUs / AP: the mainstream RWM measure and its England // comparison aren't a fair judgement (their pupils have SEND), so a "0% · // −62 vs national" row misrepresents them. Also guard a placeholder all-zero // row (every subject 0 — a special/suppressed signature), matching // SchoolDetailView's ks2Placeholder. A genuine 0% combined (some pupils met // individual subjects but not all three) is NOT all-zero, so it stays // comparable and shows its real figure. const rwmPlaceholder = school.rwm_expected_pct === 0 && (school.reading_expected_pct ?? 0) === 0 && (school.writing_expected_pct ?? 0) === 0 && (school.maths_expected_pct ?? 0) === 0; const rwmComparable = school.rwm_expected_pct != null && !rwmPlaceholder && !isSpecialSchool(school); // vs-national delta const rwmDelta = rwmComparable && nationalAvgRwm != null ? Math.round((school.rwm_expected_pct as number) - nationalAvgRwm) : null; const handleCompareClick = () => { if (isInCompare) { onRemoveFromCompare?.(school.urn); } else { onAddToCompare?.(school); } }; return (