11import { useState , useEffect , useCallback } from 'react' ;
22import type { ReactElement } from 'react' ;
3- import {
4- Zap ,
5- Eye ,
6- CloudRain ,
7- CloudSnow ,
8- Sun ,
9- Cloud ,
10- ChevronRight
11- } from 'lucide-react' ;
3+ import { Zap , Eye , CloudRain , CloudSnow , Sun , Cloud , ChevronRight } from 'lucide-react' ;
124
135interface RoadApiResponse {
146 roads : {
@@ -53,8 +45,8 @@ interface RepeaterInfo {
5345}
5446
5547const repeaters : RepeaterInfo [ ] = [
56- { name : " Murphys" , frequency : " 462.725" , status : 'up ' } ,
57- { name : " Arnold Summit" , frequency : " 462.725" , status : 'up' }
48+ { name : ' Murphys' , frequency : ' 462.725' , status : 'down ' } ,
49+ { name : ' Arnold Summit' , frequency : ' 462.725' , status : 'up' } ,
5850] ;
5951
6052const getWeatherIcon = ( iconCode : string ) : ReactElement => {
@@ -81,15 +73,13 @@ const getWeatherIcon = (iconCode: string): ReactElement => {
8173 return iconMap [ iconCode ] || < Cloud className = "h-4 w-4 text-gray-500" /> ;
8274} ;
8375
84-
8576export default function CurrentConditions ( ) {
8677 const [ roadData , setRoadData ] = useState < RoadApiResponse | null > ( null ) ;
8778 const [ weatherData , setWeatherData ] = useState < WeatherApiResponse | null > ( null ) ;
8879 const [ loading , setLoading ] = useState ( true ) ;
8980
9081 const fetchData = useCallback ( async ( ) => {
9182 try {
92-
9383 const [ roadsResponse , weatherResponse ] = await Promise . all ( [
9484 fetch ( 'https://info.ersn.net/api/v1/roads' , {
9585 method : 'GET' ,
@@ -98,7 +88,7 @@ export default function CurrentConditions() {
9888 fetch ( 'https://info.ersn.net/api/v1/weather' , {
9989 method : 'GET' ,
10090 mode : 'cors' ,
101- } )
91+ } ) ,
10292 ] ) ;
10393
10494 if ( ! roadsResponse . ok || ! weatherResponse . ok ) {
@@ -133,7 +123,8 @@ export default function CurrentConditions() {
133123 const getRoadStatusColor = ( road : any ) => {
134124 if ( road . status ?. toLowerCase ( ) === 'closed' ) return 'text-red-700' ;
135125 if ( road . delayMinutes > 15 ) return 'text-red-700' ;
136- if ( road . delayMinutes > 0 || ( road . chainControl && road . chainControl . toLowerCase ( ) !== 'none' ) ) return 'text-yellow-700' ;
126+ if ( road . delayMinutes > 0 || ( road . chainControl && road . chainControl . toLowerCase ( ) !== 'none' ) )
127+ return 'text-yellow-700' ;
137128 return 'text-green-700' ;
138129 } ;
139130
@@ -159,9 +150,7 @@ export default function CurrentConditions() {
159150 < div className = "flex items-center space-x-3 mb-4" >
160151 < Zap className = "h-6 w-6 text-stone-700" />
161152 < h3 className = "text-xl font-serif text-stone-800" > Current Conditions</ h3 >
162- < span className = "text-xs text-stone-500 bg-stone-100 px-2 py-1 rounded" >
163- Live
164- </ span >
153+ < span className = "text-xs text-stone-500 bg-stone-100 px-2 py-1 rounded" > Live</ span >
165154 </ div >
166155
167156 < div className = "flex-1 flex flex-col" >
@@ -180,10 +169,11 @@ export default function CurrentConditions() {
180169 ) ;
181170 }
182171
183- const roadsWithIssues = roadData . roads . filter ( road =>
184- road . status ?. toLowerCase ( ) === 'closed' ||
185- road . delayMinutes > 0 ||
186- ( road . chainControl && road . chainControl . toLowerCase ( ) !== 'none' )
172+ const roadsWithIssues = roadData . roads . filter (
173+ ( road ) =>
174+ road . status ?. toLowerCase ( ) === 'closed' ||
175+ road . delayMinutes > 0 ||
176+ ( road . chainControl && road . chainControl . toLowerCase ( ) !== 'none' ) ,
187177 ) ;
188178
189179 if ( roadsWithIssues . length === 0 ) {
@@ -221,7 +211,7 @@ export default function CurrentConditions() {
221211 < div className = "flex items-center space-x-1 flex-shrink-0" >
222212 { getWeatherIcon ( location . weatherIcon ) }
223213 < span className = "font-medium text-stone-700" >
224- { Math . round ( location . temperatureCelsius * 9 / 5 + 32 ) } °F
214+ { Math . round ( ( location . temperatureCelsius * 9 ) / 5 + 32 ) } °F
225215 </ span >
226216 </ div >
227217 </ div >
@@ -241,7 +231,9 @@ export default function CurrentConditions() {
241231 { repeaters . map ( ( repeater ) => (
242232 < div key = { repeater . name } className = "flex justify-between items-center" >
243233 < span className = "text-stone-600" > { repeater . name } :</ span >
244- < span className = { `font-medium ${ repeater . status === 'up' ? 'text-green-700' : 'text-red-700' } ` } >
234+ < span
235+ className = { `font-medium ${ repeater . status === 'up' ? 'text-green-700' : 'text-red-700' } ` }
236+ >
245237 { repeater . status === 'up' ? 'Up' : 'Down' }
246238 </ span >
247239 </ div >
@@ -259,8 +251,7 @@ export default function CurrentConditions() {
259251 < ChevronRight className = "h-4 w-4" />
260252 </ a >
261253 </ div >
262-
263254 </ div >
264255 </ div >
265256 ) ;
266- }
257+ }
0 commit comments