/** * SecondarySchoolRow Component * Three-line row for secondary school search results * * Line 1: School name · School type · Ofsted badge * Line 2: Attainment 8 (large) · ±LA avg delta · Eng & Maths 4+ · Pupils * Line 3: LA name · gender tag · sixth form tag · admissions tag · distance */ 'use client'; import type { School } from '@/lib/types'; import styles from './SecondarySchoolRow.module.css'; const OFSTED_LABELS: Record = { 1: 'Outstanding', 2: 'Good', 3: 'Req. Improvement', 4: 'Inadequate', }; function detectAdmissionsTag(school: School): string | null { const policy = school.admissions_policy?.toLowerCase() ?? ''; if (policy.includes('selective')) return 'Selective'; const denom = school.religious_denomination ?? ''; if (denom && denom !== 'Does not apply') return 'Faith priority'; return null; } function hasSixthForm(school: School): boolean { return school.age_range?.includes('18') ?? false; } 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 att8 = school.attainment_8_score ?? null; const laDelta = att8 != null && laAvgAttainment8 != null ? att8 - laAvgAttainment8 : null; const admissionsTag = detectAdmissionsTag(school); const sixthForm = hasSixthForm(school); const showGender = school.gender && school.gender.toLowerCase() !== 'mixed'; return (
{/* Left: three content lines */}
{/* Line 1: School name + type + Ofsted badge */}
{school.school_name} {school.school_type && ( {school.school_type} )} {school.ofsted_grade && ( {OFSTED_LABELS[school.ofsted_grade]} {school.ofsted_date && ( {' '}({new Date(school.ofsted_date).getFullYear()}) )} )}
{/* Line 2: KS4 stats */}
{att8 != null ? att8.toFixed(1) : '—'} Attainment 8 {laDelta != null && ( = 0 ? styles.deltaPositive : styles.deltaNegative}`}> {laDelta >= 0 ? '+' : ''}{laDelta.toFixed(1)} vs LA avg )} {school.english_maths_standard_pass_pct != null && ( {school.english_maths_standard_pass_pct.toFixed(0)}% Eng & Maths 4+ )} {school.total_pupils != null && ( {school.total_pupils.toLocaleString()} pupils )}
{/* Line 3: Location + tags */}
{school.local_authority && ( {school.local_authority} )} {showGender && ( {school.gender} )} {sixthForm && ( Sixth form )} {admissionsTag && ( {admissionsTag} )} {isLocationSearch && school.distance != null && ( {school.distance.toFixed(1)} mi )}
{/* Right: actions */}
View {(onAddToCompare || onRemoveFromCompare) && ( )}
); }