/**
* SchoolCard Component
* Displays school information with metrics and actions
*/
import Link from 'next/link';
import type { School } from '@/lib/types';
import { formatPercentage, formatProgress, calculateTrend, getTrendColor } from '@/lib/utils';
import styles from './SchoolCard.module.css';
interface SchoolCardProps {
school: School;
onAddToCompare?: (school: School) => void;
onRemoveFromCompare?: (urn: number) => void;
showDistance?: boolean;
distance?: number;
isInCompare?: boolean;
}
export function SchoolCard({ school, onAddToCompare, onRemoveFromCompare, showDistance, distance, isInCompare = false }: SchoolCardProps) {
const trend = calculateTrend(school.rwm_expected_pct, school.prev_rwm_expected_pct);
const trendColor = getTrendColor(trend);
return (
{school.school_name}
{showDistance && distance !== undefined && (
{(distance / 1.60934).toFixed(1)} miles away
)}
{school.local_authority && (
{school.local_authority}
)}
{school.school_type && (
{school.school_type}
)}
{school.religious_denomination && school.religious_denomination !== 'Does not apply' && (
{school.religious_denomination}
)}
{(school.rwm_expected_pct !== null || school.reading_progress !== null) && (
{school.rwm_expected_pct !== null && (
RWM Expected
% meeting expected standard
{formatPercentage(school.rwm_expected_pct)}
{school.prev_rwm_expected_pct !== null && (
{trend === 'up' && (
)}
{trend === 'down' && (
)}
{trend === 'stable' && (
)}
)}
)}
{school.reading_progress !== null && (
Reading
progress score (0 = avg)
{formatProgress(school.reading_progress)}
)}
{school.writing_progress !== null && (
Writing
progress score (0 = avg)
{formatProgress(school.writing_progress)}
)}
{school.maths_progress !== null && (
Maths
progress score (0 = avg)
{formatProgress(school.maths_progress)}
)}
)}
View Details
{onAddToCompare && (
)}
);
}