diff --git a/src/components/oba/TripDetailsPane.svelte b/src/components/oba/TripDetailsPane.svelte index 1c1b838..29ae899 100644 --- a/src/components/oba/TripDetailsPane.svelte +++ b/src/components/oba/TripDetailsPane.svelte @@ -45,7 +45,7 @@ } const response = await fetch(url); - if (!response) { + if (!response.ok) { error = 'Unable to fetch trip details'; return; } @@ -68,10 +68,15 @@ if (tripDetails.status?.closestStop) { currentStopIndex = tripDetails.schedule.stopTimes.findIndex( - (stop) => stop.stopId === tripDetails.status.closestStop.stopId + (stop) => stop.stopId === tripDetails.status.closestStop ); + } else { + currentStopIndex = -1; } + console.log('Current Stop Index:', currentStopIndex); + console.log('Closest Stop:', tripDetails.status?.closestStop); + calculateBusPosition(); } catch (err) { console.error('Error fetching trip details:', err);