Add TFR warning banner for airspace restrictions
Fetches active Temporary Flight Restrictions from the FAA website, filters by configured state (LOCATION_STATE env var), and displays a red warning banner at the top of the dashboard when TFRs are present. Data is cached for 30 minutes and degrades gracefully if the FAA is unreachable. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
'use client'
|
||||
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { getCurrentWeather, getForecast, getHistorical } from '@/lib/api'
|
||||
import type { CurrentWeatherResponse, ForecastResponse, HistoricalResponse } from '@/lib/types'
|
||||
import { getCurrentWeather, getForecast, getHistorical, getTfrs } from '@/lib/api'
|
||||
import type { CurrentWeatherResponse, ForecastResponse, HistoricalResponse, TFRResponse } from '@/lib/types'
|
||||
|
||||
const STALE_TIME = 5 * 60 * 1000 // 5 minutes
|
||||
const REFETCH_INTERVAL = 5 * 60 * 1000 // 5 minutes
|
||||
@@ -35,3 +35,15 @@ export function useHistorical(date: string, lat?: number, lon?: number) {
|
||||
enabled: !!date,
|
||||
})
|
||||
}
|
||||
|
||||
const TFR_STALE_TIME = 30 * 60 * 1000 // 30 minutes
|
||||
const TFR_REFETCH_INTERVAL = 30 * 60 * 1000 // 30 minutes
|
||||
|
||||
export function useTfrs() {
|
||||
return useQuery<TFRResponse>({
|
||||
queryKey: ['airspace', 'tfrs'],
|
||||
queryFn: () => getTfrs(),
|
||||
staleTime: TFR_STALE_TIME,
|
||||
refetchInterval: TFR_REFETCH_INTERVAL,
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user