2026-02-02 20:34:35 +00:00
|
|
|
/**
|
|
|
|
|
* Home Page (SSR)
|
|
|
|
|
* Main landing page with school search and browsing
|
|
|
|
|
*/
|
|
|
|
|
|
2026-03-23 21:31:28 +00:00
|
|
|
import { fetchSchools, fetchFilters, fetchDataInfo } from '@/lib/api';
|
2026-02-02 20:34:35 +00:00
|
|
|
import { HomeView } from '@/components/HomeView';
|
|
|
|
|
|
|
|
|
|
interface HomePageProps {
|
2026-02-02 22:09:17 +00:00
|
|
|
searchParams: Promise<{
|
2026-02-02 20:34:35 +00:00
|
|
|
search?: string;
|
|
|
|
|
local_authority?: string;
|
|
|
|
|
school_type?: string;
|
feat: add secondary school support with KS4 data and metric tooltips
- Backend: replace INNER JOIN ks2 with UNION ALL (ks2 + ks4) so primary
and secondary schools both appear in the main DataFrame
- Backend: add /api/national-averages endpoint computing means from live
data, replacing the hardcoded NATIONAL_AVG constant on the frontend
- Backend: add phase filter param to /api/schools; return phases from
/api/filters; fix hardcoded "phase": "Primary" in school detail endpoint
- Backend: add KS4 metric definitions (Attainment 8, Progress 8, EBacc,
English & Maths pass rates) to METRIC_DEFINITIONS and RANKING_COLUMNS
- Frontend: SchoolDetailView is now phase-aware — secondary schools show
a GCSE Results section (Att8, P8, E&M, EBacc) instead of SATs; phonics
tab hidden for secondary; admissions says Year 7 instead of Year 3;
history table shows KS4 columns; chart datasets switch for secondary
- Frontend: new MetricTooltip component (CSS-only ⓘ icon) backed by
METRIC_EXPLANATIONS — added to RWM, GPS, SEN, EAL, IDACI, progress
scores and all KS4 metrics throughout SchoolDetailView and SchoolCard
- Frontend: METRIC_EXPLANATIONS extended with KS4 terms (Attainment 8,
Progress 8, EBacc) and previously missing terms (SEN, EHCP, EAL, IDACI)
- Frontend: SchoolCard expands "RWM" to "Reading, Writing & Maths" and
shows Attainment 8 / English & Maths Grade 4+ for secondary schools
- Frontend: FilterBar adds Phase dropdown (Primary / Secondary / All-through)
- Frontend: HomeView hero copy updated; compact list shows phase-aware metric
- Global metadata updated to remove "primary only" framing
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-28 14:59:40 +00:00
|
|
|
phase?: string;
|
2026-02-02 20:34:35 +00:00
|
|
|
page?: string;
|
|
|
|
|
postcode?: string;
|
|
|
|
|
radius?: string;
|
2026-03-30 10:10:28 +01:00
|
|
|
sort?: string;
|
2026-02-02 22:09:17 +00:00
|
|
|
}>;
|
2026-02-02 20:34:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const metadata = {
|
|
|
|
|
title: 'Home',
|
feat: add secondary school support with KS4 data and metric tooltips
- Backend: replace INNER JOIN ks2 with UNION ALL (ks2 + ks4) so primary
and secondary schools both appear in the main DataFrame
- Backend: add /api/national-averages endpoint computing means from live
data, replacing the hardcoded NATIONAL_AVG constant on the frontend
- Backend: add phase filter param to /api/schools; return phases from
/api/filters; fix hardcoded "phase": "Primary" in school detail endpoint
- Backend: add KS4 metric definitions (Attainment 8, Progress 8, EBacc,
English & Maths pass rates) to METRIC_DEFINITIONS and RANKING_COLUMNS
- Frontend: SchoolDetailView is now phase-aware — secondary schools show
a GCSE Results section (Att8, P8, E&M, EBacc) instead of SATs; phonics
tab hidden for secondary; admissions says Year 7 instead of Year 3;
history table shows KS4 columns; chart datasets switch for secondary
- Frontend: new MetricTooltip component (CSS-only ⓘ icon) backed by
METRIC_EXPLANATIONS — added to RWM, GPS, SEN, EAL, IDACI, progress
scores and all KS4 metrics throughout SchoolDetailView and SchoolCard
- Frontend: METRIC_EXPLANATIONS extended with KS4 terms (Attainment 8,
Progress 8, EBacc) and previously missing terms (SEN, EHCP, EAL, IDACI)
- Frontend: SchoolCard expands "RWM" to "Reading, Writing & Maths" and
shows Attainment 8 / English & Maths Grade 4+ for secondary schools
- Frontend: FilterBar adds Phase dropdown (Primary / Secondary / All-through)
- Frontend: HomeView hero copy updated; compact list shows phase-aware metric
- Global metadata updated to remove "primary only" framing
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-28 14:59:40 +00:00
|
|
|
description: 'Search and compare school performance across England',
|
2026-02-02 20:34:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Force dynamic rendering (no static generation at build time)
|
|
|
|
|
export const dynamic = 'force-dynamic';
|
|
|
|
|
|
|
|
|
|
export default async function HomePage({ searchParams }: HomePageProps) {
|
2026-02-02 22:09:17 +00:00
|
|
|
// Await search params (Next.js 15 requirement)
|
|
|
|
|
const params = await searchParams;
|
|
|
|
|
|
2026-02-02 20:34:35 +00:00
|
|
|
// Parse search params
|
2026-02-02 22:09:17 +00:00
|
|
|
const page = parseInt(params.page || '1');
|
2026-02-02 22:21:55 +00:00
|
|
|
const radius = params.radius ? parseFloat(params.radius) : undefined;
|
|
|
|
|
|
|
|
|
|
// Check if user has performed a search
|
|
|
|
|
const hasSearchParams = !!(
|
|
|
|
|
params.search ||
|
|
|
|
|
params.local_authority ||
|
|
|
|
|
params.school_type ||
|
feat: add secondary school support with KS4 data and metric tooltips
- Backend: replace INNER JOIN ks2 with UNION ALL (ks2 + ks4) so primary
and secondary schools both appear in the main DataFrame
- Backend: add /api/national-averages endpoint computing means from live
data, replacing the hardcoded NATIONAL_AVG constant on the frontend
- Backend: add phase filter param to /api/schools; return phases from
/api/filters; fix hardcoded "phase": "Primary" in school detail endpoint
- Backend: add KS4 metric definitions (Attainment 8, Progress 8, EBacc,
English & Maths pass rates) to METRIC_DEFINITIONS and RANKING_COLUMNS
- Frontend: SchoolDetailView is now phase-aware — secondary schools show
a GCSE Results section (Att8, P8, E&M, EBacc) instead of SATs; phonics
tab hidden for secondary; admissions says Year 7 instead of Year 3;
history table shows KS4 columns; chart datasets switch for secondary
- Frontend: new MetricTooltip component (CSS-only ⓘ icon) backed by
METRIC_EXPLANATIONS — added to RWM, GPS, SEN, EAL, IDACI, progress
scores and all KS4 metrics throughout SchoolDetailView and SchoolCard
- Frontend: METRIC_EXPLANATIONS extended with KS4 terms (Attainment 8,
Progress 8, EBacc) and previously missing terms (SEN, EHCP, EAL, IDACI)
- Frontend: SchoolCard expands "RWM" to "Reading, Writing & Maths" and
shows Attainment 8 / English & Maths Grade 4+ for secondary schools
- Frontend: FilterBar adds Phase dropdown (Primary / Secondary / All-through)
- Frontend: HomeView hero copy updated; compact list shows phase-aware metric
- Global metadata updated to remove "primary only" framing
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-28 14:59:40 +00:00
|
|
|
params.phase ||
|
2026-02-02 22:21:55 +00:00
|
|
|
params.postcode
|
|
|
|
|
);
|
2026-02-02 20:34:35 +00:00
|
|
|
|
2026-02-02 21:28:50 +00:00
|
|
|
// Fetch data on server with error handling
|
|
|
|
|
try {
|
2026-03-23 21:31:28 +00:00
|
|
|
const [filtersData, dataInfo] = await Promise.all([fetchFilters(), fetchDataInfo().catch(() => null)]);
|
2026-02-02 22:21:55 +00:00
|
|
|
|
|
|
|
|
// Only fetch schools if there are search parameters
|
|
|
|
|
let schoolsData;
|
|
|
|
|
if (hasSearchParams) {
|
|
|
|
|
schoolsData = await fetchSchools({
|
2026-02-02 22:09:17 +00:00
|
|
|
search: params.search,
|
|
|
|
|
local_authority: params.local_authority,
|
|
|
|
|
school_type: params.school_type,
|
feat: add secondary school support with KS4 data and metric tooltips
- Backend: replace INNER JOIN ks2 with UNION ALL (ks2 + ks4) so primary
and secondary schools both appear in the main DataFrame
- Backend: add /api/national-averages endpoint computing means from live
data, replacing the hardcoded NATIONAL_AVG constant on the frontend
- Backend: add phase filter param to /api/schools; return phases from
/api/filters; fix hardcoded "phase": "Primary" in school detail endpoint
- Backend: add KS4 metric definitions (Attainment 8, Progress 8, EBacc,
English & Maths pass rates) to METRIC_DEFINITIONS and RANKING_COLUMNS
- Frontend: SchoolDetailView is now phase-aware — secondary schools show
a GCSE Results section (Att8, P8, E&M, EBacc) instead of SATs; phonics
tab hidden for secondary; admissions says Year 7 instead of Year 3;
history table shows KS4 columns; chart datasets switch for secondary
- Frontend: new MetricTooltip component (CSS-only ⓘ icon) backed by
METRIC_EXPLANATIONS — added to RWM, GPS, SEN, EAL, IDACI, progress
scores and all KS4 metrics throughout SchoolDetailView and SchoolCard
- Frontend: METRIC_EXPLANATIONS extended with KS4 terms (Attainment 8,
Progress 8, EBacc) and previously missing terms (SEN, EHCP, EAL, IDACI)
- Frontend: SchoolCard expands "RWM" to "Reading, Writing & Maths" and
shows Attainment 8 / English & Maths Grade 4+ for secondary schools
- Frontend: FilterBar adds Phase dropdown (Primary / Secondary / All-through)
- Frontend: HomeView hero copy updated; compact list shows phase-aware metric
- Global metadata updated to remove "primary only" framing
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-28 14:59:40 +00:00
|
|
|
phase: params.phase,
|
2026-02-02 22:09:17 +00:00
|
|
|
postcode: params.postcode,
|
2026-02-02 21:28:50 +00:00
|
|
|
radius,
|
|
|
|
|
page,
|
|
|
|
|
page_size: 50,
|
2026-02-02 22:21:55 +00:00
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
// Empty state by default
|
|
|
|
|
schoolsData = { schools: [], page: 1, page_size: 50, total: 0, total_pages: 0 };
|
|
|
|
|
}
|
2026-02-02 21:28:50 +00:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<HomeView
|
|
|
|
|
initialSchools={schoolsData}
|
2026-03-28 22:36:00 +00:00
|
|
|
filters={filtersData || { local_authorities: [], school_types: [], years: [], phases: [], genders: [], admissions_policies: [] }}
|
2026-03-23 21:31:28 +00:00
|
|
|
totalSchools={dataInfo?.total_schools ?? null}
|
2026-02-02 21:28:50 +00:00
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('Error fetching data for home page:', error);
|
|
|
|
|
|
|
|
|
|
// Return error state with empty data
|
|
|
|
|
return (
|
|
|
|
|
<HomeView
|
2026-02-02 21:34:24 +00:00
|
|
|
initialSchools={{ schools: [], page: 1, page_size: 50, total: 0, total_pages: 0 }}
|
2026-03-28 22:36:00 +00:00
|
|
|
filters={{ local_authorities: [], school_types: [], years: [], phases: [], genders: [], admissions_policies: [] }}
|
2026-03-23 21:31:28 +00:00
|
|
|
totalSchools={null}
|
2026-02-02 21:28:50 +00:00
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
}
|
2026-02-02 20:34:35 +00:00
|
|
|
}
|