/** * WellbeingSection — SEN, gender split and local-area deprivation. * Secondary pages. Server component. */ import type { School, SchoolCensus, SchoolResult, SchoolDeprivation } from '@/lib/types'; import { formatPercentage } from '@/lib/utils'; import { MetricTooltip } from '../MetricTooltip'; import { Section, sectionStyles as styles } from './sectionShared'; // Moved with this section from SecondarySchoolDetailView, its only consumer. function deprivationDesc(decile: number) { if (decile <= 3) return `This school is in one of England's most deprived areas (decile ${decile}/10). Many pupils may face additional challenges at home.`; if (decile <= 7) return `This school is in an area with average levels of deprivation (decile ${decile}/10).`; return `This school is in one of England's less deprived areas (decile ${decile}/10).`; } export function WellbeingSection({ latestResults, census, schoolInfo, deprivation, hasDeprivation, }: { latestResults: SchoolResult | null; census: SchoolCensus | null; schoolInfo: School; deprivation: SchoolDeprivation | null; hasDeprivation: boolean; }) { return (

Wellbeing & Context

{/* SEN */} {(latestResults?.sen_support_pct != null || latestResults?.sen_ehcp_pct != null) && ( <>

Special Educational Needs (SEN)

{latestResults?.sen_support_pct != null && (
SEN support
{formatPercentage(latestResults.sen_support_pct)}
Without an EHCP
)} {latestResults?.sen_ehcp_pct != null && (
Pupils with EHCP
{formatPercentage(latestResults.sen_ehcp_pct)}
Education, Health and Care Plan
)} {(() => { const total = census?.total_pupils ?? schoolInfo.total_pupils ?? latestResults?.total_pupils ?? null; if (total == null) return null; const female = census?.female_pupils ?? null; const male = census?.male_pupils ?? null; const isMixed = schoolInfo.gender === 'Mixed' || schoolInfo.gender == null; const hasSplit = isMixed && female != null && male != null && female + male > 0; const sum = hasSplit ? female! + male! : 0; const girlsPct = hasSplit ? Math.round((female! / sum) * 100) : 0; const boysPct = hasSplit ? 100 - girlsPct : 0; return (
Total pupils
{total.toLocaleString()}
{hasSplit && ( <>
{girlsPct}% girls · {boysPct}% boys
)} {schoolInfo.capacity != null && !hasSplit && (
Capacity: {schoolInfo.capacity}
)}
); })()}
)} {/* Deprivation */} {hasDeprivation && deprivation && ( <>

Local Area Context

{Array.from({ length: 10 }, (_, i) => (
))}
Most deprived Least deprived

{deprivationDesc(deprivation.idaci_decile!)}

)}
); }