Fix filters API response structure
Backend returns filters directly at top level, not wrapped in 'filters' property. Update FiltersResponse type and page components to match actual API response. Fixes empty dropdowns for school types and local authorities. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -48,7 +48,7 @@ export default async function HomePage({ searchParams }: HomePageProps) {
|
|||||||
return (
|
return (
|
||||||
<HomeView
|
<HomeView
|
||||||
initialSchools={schoolsData}
|
initialSchools={schoolsData}
|
||||||
filters={filtersData?.filters || { local_authorities: [], school_types: [], years: [] }}
|
filters={filtersData || { local_authorities: [], school_types: [], years: [] }}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ export default async function RankingsPage({ searchParams }: RankingsPageProps)
|
|||||||
return (
|
return (
|
||||||
<RankingsView
|
<RankingsView
|
||||||
rankings={rankingsResponse?.rankings || []}
|
rankings={rankingsResponse?.rankings || []}
|
||||||
filters={filtersResponse?.filters || { local_authorities: [], school_types: [], years: [] }}
|
filters={filtersResponse || { local_authorities: [], school_types: [], years: [] }}
|
||||||
metrics={metricsArray}
|
metrics={metricsArray}
|
||||||
selectedMetric={metric}
|
selectedMetric={metric}
|
||||||
selectedArea={local_authority}
|
selectedArea={local_authority}
|
||||||
|
|||||||
@@ -182,9 +182,8 @@ export interface Filters {
|
|||||||
years: number[];
|
years: number[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface FiltersResponse {
|
// Backend returns filters directly, not wrapped
|
||||||
filters: Filters;
|
export type FiltersResponse = Filters;
|
||||||
}
|
|
||||||
|
|
||||||
export interface MetricDefinition {
|
export interface MetricDefinition {
|
||||||
key: string;
|
key: string;
|
||||||
|
|||||||
Reference in New Issue
Block a user