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:
2026-02-16 18:43:34 -08:00
parent 88787b2eb1
commit 4974780d89
11 changed files with 336 additions and 3 deletions

View File

@@ -1,12 +1,13 @@
'use client'
import { useCurrentWeather, useForecast, useHistorical } from '@/hooks/use-weather'
import { useCurrentWeather, useForecast, useHistorical, useTfrs } from '@/hooks/use-weather'
import { AssessmentBadge } from '@/components/weather/assessment-badge'
import { WindSpeedChart } from '@/components/weather/wind-speed-chart'
import { WindDirectionChart } from '@/components/weather/wind-direction-chart'
import { ThresholdControls } from '@/components/weather/threshold-controls'
import { RefreshCountdown } from '@/components/weather/refresh-countdown'
import { StaleDataBanner } from '@/components/weather/stale-data-banner'
import { TfrBanner } from '@/components/weather/tfr-banner'
import { Collapsible } from '@/components/ui/collapsible'
import { useQueryClient } from '@tanstack/react-query'
import { Loader2, AlertCircle } from 'lucide-react'
@@ -28,6 +29,9 @@ export default function DashboardPage() {
error: forecastError,
} = useForecast()
// Fetch TFR data
const { data: tfrData } = useTfrs()
// Fetch yesterday's data for comparison
const yesterday = format(subDays(new Date(), 1), 'yyyy-MM-dd')
const {
@@ -111,6 +115,11 @@ export default function DashboardPage() {
)}
</div>
{/* TFR Warning */}
{tfrData && tfrData.tfrs.length > 0 && (
<TfrBanner tfrs={tfrData.tfrs} />
)}
{/* Stale Data Warning */}
<StaleDataBanner lastUpdated={currentWeather.last_updated} />