@@ -269,7 +269,8 @@ const state = {
269269 zoneData : null , // Zone data from API (name, code, enabled, at_capacity, slots_available, slots_max)
270270 nearestZone : null , // Nearest zone data if outside all zones (name, code, distance_km)
271271 gpsError : null , // GPS error message if any (e.g., "gps_stale", "gps_inaccurate")
272- preflightGps : null // GPS fix for preflight check { lat, lon, accuracy, timestamp }
272+ preflightGps : null , // GPS fix for preflight check { lat, lon, accuracy, timestamp }
273+ apiError : null // API error message if API call fails
273274 }
274275} ;
275276
@@ -1158,6 +1159,15 @@ function updateConnectButtonState() {
11581159 return ;
11591160 }
11601161
1162+ // Check API error BEFORE checking zone status
1163+ if ( zs . apiError ) {
1164+ connectBtn . disabled = true ;
1165+ setConnStatus ( "Unavailable" , STATUS_COLORS . error ) ;
1166+ setDynamicStatus ( `Zone check failed: ${ zs . apiError } ` , STATUS_COLORS . error ) ;
1167+ debugLog ( `[GEOFENCE] API error: ${ zs . apiError } - Connect disabled` ) ;
1168+ return ;
1169+ }
1170+
11611171 // Check zone status conditions
11621172 if ( zs . gpsError ) {
11631173 connectBtn . disabled = true ;
@@ -1271,6 +1281,7 @@ async function checkZoneStatus() {
12711281
12721282 state . zoneStatus . isChecking = true ;
12731283 state . zoneStatus . gpsError = null ;
1284+ state . zoneStatus . apiError = null ;
12741285 updateZoneStatusUI ( ) ;
12751286
12761287 try {
@@ -1321,7 +1332,7 @@ async function checkZoneStatus() {
13211332
13221333 } catch ( error ) {
13231334 debugError ( `[GEOFENCE] Zone status check failed: ${ error . message } ` ) ;
1324- state . zoneStatus . gpsError = null ;
1335+ state . zoneStatus . apiError = error . message ;
13251336 state . zoneStatus . inZone = false ;
13261337 state . zoneStatus . zoneData = null ;
13271338 state . zoneStatus . nearestZone = null ;
0 commit comments