chore: drop unused SWR hooks and dependency

useSchools, useFilters, useMetrics and useSchoolDetails were imported by
nothing and were the only consumers of swr. All data fetching goes through
lib/api.ts on the server.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Tudor
2026-08-02 21:39:59 +01:00
co-authored by Claude Opus 5
parent 752eb07310
commit 4c229aec6e
6 changed files with 2 additions and 155 deletions
-29
View File
@@ -1,29 +0,0 @@
/**
* Custom hook for fetching filter options with SWR
*/
'use client';
import useSWR from 'swr';
import { fetcher } from '@/lib/api';
import type { FiltersResponse } from '@/lib/types';
export function useFilters() {
const { data, error, isLoading } = useSWR<FiltersResponse>(
'/filters',
fetcher,
{
revalidateOnFocus: false,
dedupingInterval: 60000, // 1 minute
}
);
return {
filters: data,
localAuthorities: data?.local_authorities || [],
schoolTypes: data?.school_types || [],
years: data?.years || [],
isLoading,
error,
};
}
-28
View File
@@ -1,28 +0,0 @@
/**
* Custom hook for fetching metric definitions with SWR
*/
'use client';
import useSWR from 'swr';
import { fetcher } from '@/lib/api';
import type { MetricsResponse } from '@/lib/types';
export function useMetrics() {
const { data, error, isLoading } = useSWR<MetricsResponse>(
'/metrics',
fetcher,
{
revalidateOnFocus: false,
dedupingInterval: 60000, // 1 minute
}
);
return {
metrics: data?.metrics || [],
metricsList: data?.metrics || [],
getMetric: (key: string) => data?.metrics?.find(m => m.key === key),
isLoading,
error,
};
}
-28
View File
@@ -1,28 +0,0 @@
/**
* Custom hook for fetching school details with SWR
*/
'use client';
import useSWR from 'swr';
import { fetcher } from '@/lib/api';
import type { SchoolDetailsResponse } from '@/lib/types';
export function useSchoolDetails(urn: number | null) {
const { data, error, isLoading, mutate } = useSWR<SchoolDetailsResponse>(
urn ? `/schools/${urn}` : null,
fetcher,
{
revalidateOnFocus: false,
dedupingInterval: 30000, // 30 seconds
}
);
return {
schoolInfo: data?.school_info,
yearlyData: data?.yearly_data || [],
isLoading,
error,
mutate,
};
}
-46
View File
@@ -1,46 +0,0 @@
/**
* Custom hook for fetching schools with SWR
*/
'use client';
import useSWR from 'swr';
import { fetcher } from '@/lib/api';
import type { SchoolsResponse, SchoolSearchParams } from '@/lib/types';
export function useSchools(params: SchoolSearchParams = {}, shouldFetch: boolean = true) {
const queryParams = new URLSearchParams();
Object.entries(params).forEach(([key, value]) => {
if (value !== undefined && value !== null && value !== '') {
queryParams.set(key, String(value));
}
});
const queryString = queryParams.toString();
const url = `/schools${queryString ? `?${queryString}` : ''}`;
const { data, error, isLoading, mutate } = useSWR<SchoolsResponse>(
shouldFetch ? url : null,
fetcher,
{
revalidateOnFocus: false,
dedupingInterval: 5000, // 5 seconds
}
);
return {
schools: data?.schools || [],
pagination: data ? {
page: data.page,
page_size: data.page_size,
total: data.total,
total_pages: data.total_pages,
} : null,
searchMode: data?.search_mode,
locationInfo: data?.location_info,
isLoading,
error,
mutate,
};
}