/** * SecondarySchoolRow Component * Four-line row for secondary school search results * * Line 1: School name · Ofsted badge * Line 2: School type · Age range · Gender · Sixth form · Admissions tag * 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 styles from './SecondarySchoolRow.module.css'; 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 { // GIAS OfficialSixthForm flag; missing (pipeline not yet re-run) => false. return school.has_sixth_form ?? 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 ofstedBadge = buildOfstedListBadge(school); const phase = getPhaseStyle(school.phase); const att8 = school.attainment_8_score; // Special schools / PRUs / AP: Attainment 8 vs the LA average isn't a fair // comparison (their pupils have SEND), so drop the delta and the number // rather than show them trailing "the average" by design. const att8Comparable = att8 != null && att8 !== 0 && !isSpecialSchool(school); const laDelta = att8Comparable && laAvgAttainment8 != null ? (att8 as number) - laAvgAttainment8 : null; const admissionsTag = detectAdmissionsTag(school); const sixthForm = hasSixthForm(school); const showGender = school.gender && school.gender.toLowerCase() !== 'mixed'; return (