/** * SchoolRow Component * Compact row-based school display for search results list view */ import type { School } from '@/lib/types'; import { formatPercentage, formatProgress, calculateTrend } from '@/lib/utils'; import { progressBand } from '@/lib/metrics'; import styles from './SchoolRow.module.css'; interface SchoolRowProps { school: School; isLocationSearch?: boolean; isInCompare?: boolean; onAddToCompare?: (school: School) => void; onRemoveFromCompare?: (urn: number) => void; } export function SchoolRow({ school, isLocationSearch, isInCompare = false, onAddToCompare, onRemoveFromCompare, }: SchoolRowProps) { const trend = calculateTrend(school.rwm_expected_pct, school.prev_rwm_expected_pct); const hasProgress = school.reading_progress != null || school.writing_progress != null || school.maths_progress != null; const handleCompareClick = () => { if (isInCompare) { onRemoveFromCompare?.(school.urn); } else { onAddToCompare?.(school); } }; return (
{/* Line 1: Name + score + actions */}
{school.school_name}
{school.rwm_expected_pct != null ? ( <> {formatPercentage(school.rwm_expected_pct, 0)} {school.prev_rwm_expected_pct != null && ( {trend === 'up' && ( )} {trend === 'down' && ( )} {trend === 'stable' && ( )} )} ) : ( )} R, W & M
View {(onAddToCompare || onRemoveFromCompare) && ( )}
{/* Line 2: Meta tags */}
{school.local_authority && {school.local_authority}} {school.school_type && {school.school_type}} {!isLocationSearch && school.religious_denomination && school.religious_denomination !== 'Does not apply' && ( {school.religious_denomination} )} {isLocationSearch && school.distance != null && ( {(school.distance / 1609.34).toFixed(1)} mi )}
{/* Line 3: Progress scores with plain-language bands */} {hasProgress && (
{school.reading_progress != null && ( Reading{' '} {formatProgress(school.reading_progress)} {progressBand(school.reading_progress)} )} {school.writing_progress != null && ( Writing{' '} {formatProgress(school.writing_progress)} {progressBand(school.writing_progress)} )} {school.maths_progress != null && ( Maths{' '} {formatProgress(school.maths_progress)} {progressBand(school.maths_progress)} )}
)}
); }