import { NavLink } from 'react-router-dom'; import { useTonight } from '../../hooks/useTonight'; import { useWeather, useForecast } from '../../hooks/useWeather'; import MoonPhaseIcon from '../sky/MoonPhaseIcon'; import GoNogo from '../weather/GoNogo'; const SEEING_LABELS: Record = { 1: '0.5″', 2: '0.75″', 3: '1.0″', 4: '1.25″', 5: '1.5″', 6: '2.0″', 7: '2.5″', 8: '>3″', }; const TRANSP_LABELS: Record = { 1: 'Excellent', 2: 'Good', 3: 'Good', 4: 'Average', 5: 'Average', 6: 'Poor', 7: 'Poor', 8: 'Bad', }; const navItems = [ { path: '/dashboard', label: 'Dashboard', icon: '⬡' }, { path: '/targets', label: 'Targets', icon: '✦' }, { path: '/calendar', label: 'Calendar', icon: '◫' }, { path: '/stats', label: 'Statistics', icon: '▤' }, { path: '/gallery', label: 'Gallery', icon: '⬚' }, { path: '/solar-system', label: 'Solar System', icon: '◉' }, { path: '/settings', label: 'Settings', icon: '⚙' }, ]; function fmtTime(utc?: string): string { if (!utc) return '—'; return new Date(utc).toLocaleTimeString('fr-FR', { hour: '2-digit', minute: '2-digit', timeZone: 'Europe/Paris', }); } export default function Sidebar() { const { data: tonight } = useTonight(); const { data: weather } = useWeather(); const { data: forecast } = useForecast(); // First forecast slot = current/nearest 3-hour window const slot = (forecast as { dataseries?: { seeing?: number; transparency?: number; cloudcover?: number }[] })?.dataseries?.[0]; const darkStart = tonight?.true_dark_start_utc; const darkEnd = tonight?.true_dark_end_utc; const darkStr = darkStart && darkEnd ? `${fmtTime(darkStart)}–${fmtTime(darkEnd)}` : '—'; const dewMargin = weather?.temp_c != null && weather?.dew_point_c != null ? (weather.temp_c - weather.dew_point_c).toFixed(1) : null; const seeingMap: Record = { 1: '0.5″', 2: '0.75″', 3: '1.0″', 4: '1.25″', 5: '1.5″', 6: '2.0″', 7: '2.5″', 8: '>3″', }; return ( ); }