'use client' import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card' import { Slider } from '@/components/ui/slider' import { CompassSelector } from '@/components/ui/compass-selector' import { useThresholdStore } from '@/store/threshold-store' import { useEffect } from 'react' interface ThresholdControlsProps { className?: string } export function ThresholdControls({ className }: ThresholdControlsProps) { const { speedMin, speedMax, dirCenter, dirRange, setSpeedRange, setDirCenter, setDirRange, initFromURL, } = useThresholdStore() // Initialize from URL on mount useEffect(() => { initFromURL() // eslint-disable-next-line react-hooks/exhaustive-deps }, []) return ( Threshold Controls {/* Wind Speed Range */}
setSpeedRange(values[0], values[1])} min={0} max={30} step={0.5} minStepsBetweenThumbs={1} className="min-h-[44px] py-4" aria-label="Wind speed range threshold" />
{speedMin} mph {speedMax} mph
{/* Wind Direction Center */}
{/* Wind Direction Range */}
±{dirRange}°
setDirRange(values[0])} min={5} max={90} step={5} className="min-h-[44px] py-4" aria-label="Wind direction range threshold" />
Acceptable range: {(dirCenter - dirRange + 360) % 360}° to {(dirCenter + dirRange) % 360}°

Thresholds are saved to URL and applied to charts automatically.

) } // Helper function to convert degrees to compass direction function getCompassDirection(degrees: number): string { const directions = ['N', 'NNE', 'NE', 'ENE', 'E', 'ESE', 'SE', 'SSE', 'S', 'SSW', 'SW', 'WSW', 'W', 'WNW', 'NW', 'NNW'] const index = Math.round(degrees / 22.5) % 16 return directions[index] }