- Migrate from vanilla JavaScript SPA to Next.js 16 with App Router - Add server-side rendering for all pages (Home, Compare, Rankings) - Create individual school pages with dynamic routing (/school/[urn]) - Implement Chart.js and Leaflet map integrations - Add comprehensive SEO with sitemap, robots.txt, and JSON-LD - Set up Docker multi-service architecture (PostgreSQL, FastAPI, Next.js) - Update CI/CD pipeline to build both backend and frontend images - Fix Dockerfile to include devDependencies for TypeScript compilation - Add Jest testing configuration - Implement performance optimizations (code splitting, caching) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
29 lines
610 B
TypeScript
29 lines
610 B
TypeScript
/**
|
|
* 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 ? Object.values(data.metrics) : [],
|
|
getMetric: (key: string) => data?.metrics?.[key],
|
|
isLoading,
|
|
error,
|
|
};
|
|
}
|