2026-08-20 14:54:02 +01:00
|
|
|
/**
|
2026-08-20 18:44:57 +01:00
|
|
|
* DistanceSection — "How far away are you?"
|
2026-08-20 14:54:02 +01:00
|
|
|
*
|
2026-08-20 18:44:57 +01:00
|
|
|
* The section exists to answer one question a parent cannot answer from a
|
|
|
|
|
* number alone: whether their own address falls inside it. The figure itself is
|
|
|
|
|
* already on the Admissions tile above; this turns it into something they can
|
|
|
|
|
* act on.
|
2026-08-20 14:54:02 +01:00
|
|
|
*
|
2026-08-20 18:44:57 +01:00
|
|
|
* Scope note. This used to carry the full published record — chart, year table
|
|
|
|
|
* and a set of shrinking rings. Earlier years are now held back as a paid
|
|
|
|
|
* feature and no longer leave the API at all, so what remains is the latest
|
|
|
|
|
* year and the check against it. The pipeline is unchanged: every published
|
|
|
|
|
* year is still loaded into fact_admission_distance, so restoring history for
|
|
|
|
|
* entitled callers is a serving change rather than a re-collection.
|
2026-08-20 14:54:02 +01:00
|
|
|
*
|
|
|
|
|
* Server component; the map and postcode form carry their own client boundary.
|
|
|
|
|
*/
|
|
|
|
|
|
2026-08-20 18:44:57 +01:00
|
|
|
import type { School, SchoolAdmissionDistance } from '@/lib/types';
|
2026-08-20 14:54:02 +01:00
|
|
|
import { Section, sectionStyles as styles } from './sectionShared';
|
2026-08-20 18:44:57 +01:00
|
|
|
import { CutoffMapPanel } from './CutoffMapPanel';
|
2026-08-20 14:54:02 +01:00
|
|
|
|
|
|
|
|
export function DistanceSection({
|
2026-08-20 18:44:57 +01:00
|
|
|
admissionDistance,
|
2026-08-20 14:54:02 +01:00
|
|
|
schoolInfo,
|
|
|
|
|
}: {
|
2026-08-20 18:44:57 +01:00
|
|
|
admissionDistance: SchoolAdmissionDistance | null;
|
2026-08-20 14:54:02 +01:00
|
|
|
schoolInfo: School;
|
|
|
|
|
}) {
|
2026-08-20 18:44:57 +01:00
|
|
|
// Without a figure there is nothing to compare against, and without
|
|
|
|
|
// coordinates there is nothing to measure — CutoffMapPanel enforces the
|
|
|
|
|
// second, but the section must not render an empty card either way.
|
|
|
|
|
if (
|
|
|
|
|
admissionDistance?.distance_m == null
|
|
|
|
|
|| schoolInfo.latitude == null
|
|
|
|
|
|| schoolInfo.longitude == null
|
|
|
|
|
) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2026-08-20 14:54:02 +01:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Section id="distance">
|
2026-08-20 18:44:57 +01:00
|
|
|
<h2 className={styles.sectionTitle}>How far away are you?</h2>
|
2026-08-20 14:54:02 +01:00
|
|
|
<p className={styles.sectionSubtitle}>
|
2026-08-20 18:44:57 +01:00
|
|
|
Check your postcode against the furthest home offered a place in
|
|
|
|
|
September {admissionDistance.year}.
|
2026-08-20 14:54:02 +01:00
|
|
|
</p>
|
2026-08-20 18:44:57 +01:00
|
|
|
<CutoffMapPanel schoolInfo={schoolInfo} cutoff={admissionDistance} />
|
2026-08-20 14:54:02 +01:00
|
|
|
</Section>
|
|
|
|
|
);
|
|
|
|
|
}
|