2026-03-23 22:32:33 +00:00
|
|
|
/**
|
|
|
|
|
* SchoolRow Component
|
2026-03-29 08:57:06 +01:00
|
|
|
* Four-line row for primary school search results
|
2026-03-24 09:27:22 +00:00
|
|
|
*
|
2026-03-29 08:57:06 +01:00
|
|
|
* Line 1: School name · Ofsted badge
|
|
|
|
|
* Line 2: School type · Age range · Denomination · Gender
|
|
|
|
|
* Line 3: R,W&M % · Progress score · Pupil count
|
|
|
|
|
* Line 4: Local authority · Distance
|
2026-03-23 22:32:33 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import type { School } from '@/lib/types';
|
2026-03-29 12:41:28 +01:00
|
|
|
import { formatPercentage, formatProgress, calculateTrend, schoolUrl } from '@/lib/utils';
|
2026-03-23 22:32:33 +00:00
|
|
|
import { progressBand } from '@/lib/metrics';
|
|
|
|
|
import styles from './SchoolRow.module.css';
|
|
|
|
|
|
feat(data): integrate 9 UK government data sources via Kestra
Adds a full data integration pipeline for enriching school profiles with
supplementary data from Ofsted, GIAS, EES, IDACI, and FBIT.
Backend:
- Bump SCHEMA_VERSION to 3; add 8 new DB tables (ofsted_inspections,
ofsted_parent_view, school_census, admissions, sen_detail, phonics,
school_deprivation, school_finance) plus GIAS columns on schools
- Expose all supplementary data via GET /api/schools/{urn}
- Enrich school list responses with ofsted_grade + ofsted_date
Integrator (new service):
- FastAPI HTTP microservice; Kestra calls POST /run/{source}
- 9 source modules: ofsted, gias, parent_view, census, admissions,
sen_detail, phonics, idaci, finance
- 9 Kestra flow YAMLs with scheduled triggers and 3× retry
Frontend:
- SchoolRow: colour-coded Ofsted badge (Outstanding/Good/RI/Inadequate)
- SchoolDetailView: 7 new sections — Ofsted sub-judgements, Parent View
survey bars, Admissions, Pupils & Inclusion / SEN, Phonics, Deprivation
Context, Finances
- types.ts: 8 new interfaces + extended School/SchoolDetailsResponse
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-24 11:44:04 +00:00
|
|
|
const OFSTED_LABELS: Record<number, string> = {
|
|
|
|
|
1: 'Outstanding',
|
|
|
|
|
2: 'Good',
|
|
|
|
|
3: 'Req. Improvement',
|
|
|
|
|
4: 'Inadequate',
|
|
|
|
|
};
|
|
|
|
|
|
2026-03-23 22:32:33 +00:00
|
|
|
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);
|
|
|
|
|
|
2026-03-24 09:27:22 +00:00
|
|
|
// Use reading progress as representative; fall back to writing, then maths
|
|
|
|
|
const progressScore =
|
|
|
|
|
school.reading_progress ?? school.writing_progress ?? school.maths_progress ?? null;
|
2026-03-23 22:32:33 +00:00
|
|
|
|
|
|
|
|
const handleCompareClick = () => {
|
|
|
|
|
if (isInCompare) {
|
|
|
|
|
onRemoveFromCompare?.(school.urn);
|
|
|
|
|
} else {
|
|
|
|
|
onAddToCompare?.(school);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2026-03-29 08:57:06 +01:00
|
|
|
const showGender = school.gender && school.gender.toLowerCase() !== 'mixed';
|
|
|
|
|
const showDenomination =
|
|
|
|
|
school.religious_denomination &&
|
|
|
|
|
school.religious_denomination !== 'Does not apply';
|
|
|
|
|
|
2026-03-23 22:32:33 +00:00
|
|
|
return (
|
|
|
|
|
<div className={`${styles.row} ${isInCompare ? styles.rowInCompare : ''}`}>
|
2026-03-29 08:57:06 +01:00
|
|
|
{/* Left: four content lines */}
|
2026-03-24 09:27:22 +00:00
|
|
|
<div className={styles.rowContent}>
|
2026-03-23 22:32:33 +00:00
|
|
|
|
2026-03-29 08:57:06 +01:00
|
|
|
{/* Line 1: School name + Ofsted badge */}
|
2026-03-24 09:27:22 +00:00
|
|
|
<div className={styles.line1}>
|
2026-03-29 12:41:28 +01:00
|
|
|
<a href={{schoolUrl(school.urn, school.school_name)}} className={styles.schoolName}>
|
2026-03-24 09:27:22 +00:00
|
|
|
{school.school_name}
|
|
|
|
|
</a>
|
feat(data): integrate 9 UK government data sources via Kestra
Adds a full data integration pipeline for enriching school profiles with
supplementary data from Ofsted, GIAS, EES, IDACI, and FBIT.
Backend:
- Bump SCHEMA_VERSION to 3; add 8 new DB tables (ofsted_inspections,
ofsted_parent_view, school_census, admissions, sen_detail, phonics,
school_deprivation, school_finance) plus GIAS columns on schools
- Expose all supplementary data via GET /api/schools/{urn}
- Enrich school list responses with ofsted_grade + ofsted_date
Integrator (new service):
- FastAPI HTTP microservice; Kestra calls POST /run/{source}
- 9 source modules: ofsted, gias, parent_view, census, admissions,
sen_detail, phonics, idaci, finance
- 9 Kestra flow YAMLs with scheduled triggers and 3× retry
Frontend:
- SchoolRow: colour-coded Ofsted badge (Outstanding/Good/RI/Inadequate)
- SchoolDetailView: 7 new sections — Ofsted sub-judgements, Parent View
survey bars, Admissions, Pupils & Inclusion / SEN, Phonics, Deprivation
Context, Finances
- types.ts: 8 new interfaces + extended School/SchoolDetailsResponse
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-24 11:44:04 +00:00
|
|
|
{school.ofsted_grade && (
|
|
|
|
|
<span className={`${styles.ofstedBadge} ${styles[`ofsted${school.ofsted_grade}`]}`}>
|
|
|
|
|
{OFSTED_LABELS[school.ofsted_grade]}
|
2026-03-29 08:57:06 +01:00
|
|
|
{school.ofsted_date && (
|
|
|
|
|
<span className={styles.ofstedDate}>
|
|
|
|
|
{' '}({new Date(school.ofsted_date).getFullYear()})
|
|
|
|
|
</span>
|
|
|
|
|
)}
|
feat(data): integrate 9 UK government data sources via Kestra
Adds a full data integration pipeline for enriching school profiles with
supplementary data from Ofsted, GIAS, EES, IDACI, and FBIT.
Backend:
- Bump SCHEMA_VERSION to 3; add 8 new DB tables (ofsted_inspections,
ofsted_parent_view, school_census, admissions, sen_detail, phonics,
school_deprivation, school_finance) plus GIAS columns on schools
- Expose all supplementary data via GET /api/schools/{urn}
- Enrich school list responses with ofsted_grade + ofsted_date
Integrator (new service):
- FastAPI HTTP microservice; Kestra calls POST /run/{source}
- 9 source modules: ofsted, gias, parent_view, census, admissions,
sen_detail, phonics, idaci, finance
- 9 Kestra flow YAMLs with scheduled triggers and 3× retry
Frontend:
- SchoolRow: colour-coded Ofsted badge (Outstanding/Good/RI/Inadequate)
- SchoolDetailView: 7 new sections — Ofsted sub-judgements, Parent View
survey bars, Admissions, Pupils & Inclusion / SEN, Phonics, Deprivation
Context, Finances
- types.ts: 8 new interfaces + extended School/SchoolDetailsResponse
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-24 11:44:04 +00:00
|
|
|
</span>
|
|
|
|
|
)}
|
2026-03-24 09:27:22 +00:00
|
|
|
</div>
|
2026-03-23 22:32:33 +00:00
|
|
|
|
2026-03-29 08:57:06 +01:00
|
|
|
{/* Line 2: Context tags */}
|
2026-03-24 09:27:22 +00:00
|
|
|
<div className={styles.line2}>
|
2026-03-29 08:57:06 +01:00
|
|
|
{school.school_type && <span>{school.school_type}</span>}
|
|
|
|
|
{school.age_range && <span>{school.age_range}</span>}
|
|
|
|
|
{showDenomination && <span>{school.religious_denomination}</span>}
|
|
|
|
|
{showGender && <span>{school.gender}</span>}
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{/* Line 3: Key stats */}
|
|
|
|
|
<div className={styles.line3}>
|
2026-03-24 09:27:22 +00:00
|
|
|
{school.rwm_expected_pct != null ? (
|
|
|
|
|
<span className={styles.stat}>
|
|
|
|
|
<strong className={styles.statValue}>
|
|
|
|
|
{formatPercentage(school.rwm_expected_pct, 0)}
|
|
|
|
|
</strong>
|
|
|
|
|
{school.prev_rwm_expected_pct != null && (
|
|
|
|
|
<span
|
|
|
|
|
className={`${styles.trend} ${styles[`trend${trend.charAt(0).toUpperCase() + trend.slice(1)}`]}`}
|
|
|
|
|
title={`Previous year: ${formatPercentage(school.prev_rwm_expected_pct)}`}
|
|
|
|
|
>
|
|
|
|
|
{trend === 'up' && (
|
2026-03-25 20:28:03 +00:00
|
|
|
<svg viewBox="0 0 16 16" fill="none" width="9" height="9" aria-label="Trend up">
|
2026-03-24 09:27:22 +00:00
|
|
|
<path d="M8 3L14 10H2L8 3Z" fill="currentColor" />
|
|
|
|
|
</svg>
|
|
|
|
|
)}
|
|
|
|
|
{trend === 'down' && (
|
2026-03-25 20:28:03 +00:00
|
|
|
<svg viewBox="0 0 16 16" fill="none" width="9" height="9" aria-label="Trend down">
|
2026-03-24 09:27:22 +00:00
|
|
|
<path d="M8 13L2 6H14L8 13Z" fill="currentColor" />
|
|
|
|
|
</svg>
|
|
|
|
|
)}
|
|
|
|
|
{trend === 'stable' && (
|
2026-03-25 20:28:03 +00:00
|
|
|
<svg viewBox="0 0 16 16" fill="none" width="9" height="9" aria-label="Trend stable">
|
2026-03-24 09:27:22 +00:00
|
|
|
<rect x="2" y="7" width="12" height="2" rx="1" fill="currentColor" />
|
|
|
|
|
</svg>
|
|
|
|
|
)}
|
|
|
|
|
</span>
|
|
|
|
|
)}
|
|
|
|
|
<span className={styles.statLabel}>R, W & M</span>
|
|
|
|
|
</span>
|
|
|
|
|
) : (
|
|
|
|
|
<span className={styles.stat}>
|
|
|
|
|
<strong className={styles.statValue}>—</strong>
|
|
|
|
|
<span className={styles.statLabel}>R, W & M</span>
|
|
|
|
|
</span>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
{progressScore != null && (
|
|
|
|
|
<span className={styles.stat}>
|
|
|
|
|
<strong className={styles.statValue}>{formatProgress(progressScore)}</strong>
|
|
|
|
|
<span className={styles.statLabel}>
|
|
|
|
|
progress · {progressBand(progressScore)}
|
|
|
|
|
</span>
|
|
|
|
|
</span>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
{school.total_pupils != null && (
|
|
|
|
|
<span className={styles.stat}>
|
|
|
|
|
<strong className={styles.statValue}>{school.total_pupils.toLocaleString()}</strong>
|
|
|
|
|
<span className={styles.statLabel}>pupils</span>
|
|
|
|
|
</span>
|
|
|
|
|
)}
|
2026-03-23 22:32:33 +00:00
|
|
|
</div>
|
|
|
|
|
|
2026-03-29 08:57:06 +01:00
|
|
|
{/* Line 4: Location + distance */}
|
|
|
|
|
<div className={styles.line4}>
|
2026-03-24 09:27:22 +00:00
|
|
|
{school.local_authority && (
|
|
|
|
|
<span>{school.local_authority}</span>
|
|
|
|
|
)}
|
2026-03-23 22:32:33 +00:00
|
|
|
{isLocationSearch && school.distance != null && (
|
|
|
|
|
<span className={styles.distanceBadge}>
|
2026-03-23 22:39:50 +00:00
|
|
|
{school.distance.toFixed(1)} mi
|
2026-03-23 22:32:33 +00:00
|
|
|
</span>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
|
2026-03-24 09:27:22 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{/* Right: actions, vertically centred */}
|
|
|
|
|
<div className={styles.rowActions}>
|
2026-03-29 12:41:28 +01:00
|
|
|
<a href={{schoolUrl(school.urn, school.school_name)}} className="btn btn-tertiary btn-sm">
|
2026-03-24 09:27:22 +00:00
|
|
|
View
|
|
|
|
|
</a>
|
|
|
|
|
{(onAddToCompare || onRemoveFromCompare) && (
|
|
|
|
|
<button
|
|
|
|
|
onClick={handleCompareClick}
|
2026-03-25 20:28:03 +00:00
|
|
|
className={isInCompare ? 'btn btn-active btn-sm' : 'btn btn-secondary btn-sm'}
|
2026-03-24 09:27:22 +00:00
|
|
|
>
|
2026-03-25 20:28:03 +00:00
|
|
|
{isInCompare ? '✓ Comparing' : '+ Compare'}
|
2026-03-24 09:27:22 +00:00
|
|
|
</button>
|
2026-03-23 22:32:33 +00:00
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|