'use client'; /** * CutoffMapPanel — "How far away are you?" * * Measures a postcode against the one cut-off we publish, and will draw that * cut-off as a ring around the school on request. * * It used to compare against every published year and show a set of shrinking * rings. Earlier years are now held back as a paid feature and no longer leave * the API, so this answers one question about one year — which makes the * verdict sharper to state, and puts more weight on qualifying it properly, * since there is no run of years left to soften a single close call. * * The map is not rendered until asked for: before a postcode is entered it is a * circle drawn round a school, and it costs a Leaflet bundle and 240px of * height to say that. A successful check opens it automatically, because that * is the point at which it starts answering something. * * The postcode never leaves the browser except to postcodes.io for a lat/long, * and nothing is stored — this is a client-side measurement, not a lookup * against the family. */ import { useState, type FormEvent } from 'react'; import dynamic from 'next/dynamic'; import type { School, SchoolAdmissionDistance } from '@/lib/types'; import { geocodePostcode, calculateDistance } from '@/lib/api'; import { isValidPostcode } from '@/lib/utils'; import { compareToCutoff, CUTOFF_CHECK_CAVEAT, type CutoffCheckResult, type CutoffVerdict, } from './lastDistanceOffered'; import styles from './schoolSections.module.css'; const CutoffMap = dynamic(() => import('../LeafletCutoffMapInner'), { ssr: false, loading: () =>