diff --git a/src/components/ArrivalDeparture.svelte b/src/components/ArrivalDeparture.svelte index e304046..f337f1f 100644 --- a/src/components/ArrivalDeparture.svelte +++ b/src/components/ArrivalDeparture.svelte @@ -1,16 +1,11 @@ - +
+

+ {routeShortName} - {tripHeadsign} +

+

+ {formatTime(scheduledArrivalTime)} - + + {getArrivalStatus(predictedArrivalTime, scheduledArrivalTime).text} + +

+
+
+

+ {calculateTimeToReach(predictedArrivalTime, scheduledArrivalTime)} +

+
diff --git a/src/components/containers/AccordionItem.svelte b/src/components/containers/AccordionItem.svelte index 34c2f42..64de63b 100644 --- a/src/components/containers/AccordionItem.svelte +++ b/src/components/containers/AccordionItem.svelte @@ -1,16 +1,19 @@
-
+
-
-
-
-

- {selectedTripDetails.routeShortName} - {selectedTripDetails.tripHeadsign} -

-

- {new Date(selectedTripDetails.scheduledArrivalTime).toLocaleTimeString([], { - hour: '2-digit', - minute: '2-digit' - })} - - - {selectedTripDetails.arrivalStatus.text} - -

-
-

- {selectedTripDetails.timeToReach} -

-
-
- -
-
- - diff --git a/src/components/oba/TripDetailsPane.svelte b/src/components/oba/TripDetailsPane.svelte index 7703c69..a751601 100644 --- a/src/components/oba/TripDetailsPane.svelte +++ b/src/components/oba/TripDetailsPane.svelte @@ -91,9 +91,9 @@
{#each tripDetails.schedule.stopTimes as tripStop, index} -
+
{#if index === busPosition} - import ArrivalDeparture from '../ArrivalDeparture.svelte'; - import TripDetailsModal from '../navigation/TripDetailsModal.svelte'; + import ArrivalDeparture from '$components/ArrivalDeparture.svelte'; + import TripDetailsPane from '$components/oba/TripDetailsPane.svelte'; import LoadingSpinner from '$components/LoadingSpinner.svelte'; + import Accordion from '$components/containers/SingleSelectAccordion.svelte'; + import AccordionItem from '$components/containers/AccordionItem.svelte'; import { onDestroy, onMount } from 'svelte'; import { createEventDispatcher } from 'svelte'; import '$lib/i18n.js'; - import { t } from 'svelte-i18n'; - - import { isLoading } from 'svelte-i18n'; + import { isLoading, t } from 'svelte-i18n'; export let stop; export let arrivalsAndDeparturesResponse = null; @@ -17,8 +17,6 @@ let loading = false; let error; - let showTripDetails = false; - let selectedTripDetails = null; let interval = null; let initialDataLoaded = false; @@ -72,22 +70,11 @@ return _routeShortNames; } - function handleShowTripDetails(event) { - selectedTripDetails = { - ...event.detail, - routeShortName: event.detail.routeShortName, - tripHeadsign: event.detail.tripHeadsign, - scheduledArrivalTime: event.detail.scheduledArrivalTime - }; - showTripDetails = true; - dispatch('tripSelected', selectedTripDetails); - dispatch('updateRouteMap', { show: true }); - } - - function handleCloseTripDetailModal() { - showTripDetails = false; - dispatch('tripSelected', null); - dispatch('updateRouteMap', { show: false }); + function handleAccordionSelectionChanged(event) { + const data = event.detail.activeData; // this is the ArrivalDeparture object plumbed into the AccordionItem + const show = !!data; + dispatch('tripSelected', data); + dispatch('updateRouteMap', { show }); } @@ -128,28 +115,18 @@

{$t('no_arrivals_or_departures_in_next_30_minutes')}

{:else} -
-
- {#each arrivalsAndDepartures.arrivalsAndDepartures as arrival} - - {/each} -
-
+ + {#each arrivalsAndDepartures.arrivalsAndDepartures as arrival} + + + + + + + {/each} + {/if}
{/if} - - {#if showTripDetails} - - {/if}
{/if} diff --git a/src/routes/stops/[stopID]/schedule/+page.svelte b/src/routes/stops/[stopID]/schedule/+page.svelte index a116741..216f432 100644 --- a/src/routes/stops/[stopID]/schedule/+page.svelte +++ b/src/routes/stops/[stopID]/schedule/+page.svelte @@ -30,7 +30,11 @@ $: if (selectedDate && selectedDate !== prevSelectedDate) { const formattedDate = selectedDate.toISOString().split('T')[0]; prevSelectedDate = selectedDate; - fetchScheduleForStop(stopId, formattedDate); + + // we get an error if we try to fetch data on the server + if (typeof window !== 'undefined') { + fetchScheduleForStop(stopId, formattedDate); + } } async function fetchScheduleForStop(stopId, date) {