|
1 | 1 | <script>
|
2 | 2 | import { page } from '$app/stores';
|
3 |
| - import LoadingSpinner from '$components/LoadingSpinner.svelte'; |
4 | 3 | import RouteScheduleTable from '$components/schedule-for-stop/RouteScheduleTable.svelte';
|
5 | 4 | import StopPageHeader from '$components/stops/StopPageHeader.svelte';
|
6 | 5 | import StandalonePage from '$components/StandalonePage.svelte';
|
|
9 | 8 | import AccordionItem from '$components/containers/AccordionItem.svelte';
|
10 | 9 | import { Datepicker } from 'flowbite-svelte';
|
11 | 10 | import { onMount } from 'svelte';
|
12 |
| - import { isLoading } from 'svelte-i18n'; |
13 | 11 | import { t } from 'svelte-i18n';
|
14 | 12 |
|
15 | 13 | let selectedDate = $state(new Date());
|
|
19 | 17 | let stopName = $state('');
|
20 | 18 | let stopId = $state('');
|
21 | 19 | let stopDirection = $state('');
|
22 |
| - let loading = $state(true); |
23 | 20 | let accordionComponent = $state();
|
24 | 21 | let allRoutesExpanded = $state(false);
|
25 | 22 |
|
|
29 | 26 |
|
30 | 27 | async function fetchScheduleForStop(stopId, date) {
|
31 | 28 | try {
|
32 |
| - loading = true; |
33 | 29 | emptySchedules = false;
|
34 | 30 | const response = await fetch(`/api/oba/schedule-for-stop/${stopId}?date=${date}`);
|
35 | 31 | if (!response.ok) throw new Error('Failed to fetch schedule for stop');
|
36 | 32 | const scheduleForStop = await response.json();
|
37 | 33 | handleScheduleForStopResponse(scheduleForStop.data);
|
38 | 34 | } catch (error) {
|
39 | 35 | console.error('Error fetching schedules:', error);
|
40 |
| - } finally { |
41 |
| - loading = false; |
42 | 36 | }
|
43 | 37 | }
|
44 | 38 |
|
|
140 | 134 | </svelte:head>
|
141 | 135 |
|
142 | 136 | <StandalonePage>
|
143 |
| - {#if loading || $isLoading} |
144 |
| - <LoadingSpinner /> |
145 |
| - {:else} |
146 |
| - <StopPageHeader {stopName} {stopId} {stopDirection} /> |
147 |
| -
|
148 |
| - <div class="flex flex-col"> |
149 |
| - <div class="flex flex-1 flex-col"> |
150 |
| - <h2 class="mb-4 text-2xl font-bold text-gray-800"> |
151 |
| - {$t('schedule_for_stop.route_schedules')} |
152 |
| - </h2> |
153 |
| -
|
154 |
| - <div class="mb-4 flex gap-4"> |
155 |
| - <div class="z-20 min-w-32 md:w-[30%]"> |
156 |
| - <Datepicker bind:value={selectedDate} inputClass="w-96" /> |
157 |
| - </div> |
158 |
| -
|
159 |
| - <div class="flex-1 text-right"> |
160 |
| - <button class="button" onclick={toggleAllRoutes}> |
161 |
| - {allRoutesExpanded |
162 |
| - ? $t('schedule_for_stop.collapse_all_routes') |
163 |
| - : $t('schedule_for_stop.show_all_routes')} |
164 |
| - </button> |
165 |
| - </div> |
| 137 | + <StopPageHeader {stopName} {stopId} {stopDirection} /> |
| 138 | +
|
| 139 | + <div class="flex flex-col"> |
| 140 | + <div class="flex flex-1 flex-col"> |
| 141 | + <h2 class="mb-4 text-2xl font-bold text-gray-800"> |
| 142 | + {$t('schedule_for_stop.route_schedules')} |
| 143 | + </h2> |
| 144 | +
|
| 145 | + <div class="mb-4 flex gap-4"> |
| 146 | + <div class="z-20 min-w-32 md:w-[30%]"> |
| 147 | + <Datepicker bind:value={selectedDate} inputClass="w-96" /> |
166 | 148 | </div>
|
167 | 149 |
|
168 |
| - <div |
169 |
| - class="flex-1 rounded-lg border border-gray-200 bg-white p-2 dark:border-gray-700 dark:bg-black" |
170 |
| - > |
171 |
| - {#if emptySchedules} |
172 |
| - <p class="text-center text-gray-700 dark:text-gray-400"> |
173 |
| - {$t('schedule_for_stop.no_schedules_available')} |
174 |
| - </p> |
175 |
| - {:else} |
176 |
| - <Accordion bind:this={accordionComponent}> |
177 |
| - {#each schedules as schedule} |
178 |
| - <AccordionItem> |
179 |
| - {#snippet header()} |
180 |
| - <span>{schedule.tripHeadsign}</span> |
181 |
| - {/snippet} |
182 |
| - <RouteScheduleTable {schedule} /> |
183 |
| - </AccordionItem> |
184 |
| - {/each} |
185 |
| - </Accordion> |
186 |
| - {/if} |
| 150 | + <div class="flex-1 text-right"> |
| 151 | + <button class="button" onclick={toggleAllRoutes}> |
| 152 | + {allRoutesExpanded |
| 153 | + ? $t('schedule_for_stop.collapse_all_routes') |
| 154 | + : $t('schedule_for_stop.show_all_routes')} |
| 155 | + </button> |
187 | 156 | </div>
|
188 | 157 | </div>
|
| 158 | +
|
| 159 | + <div |
| 160 | + class="flex-1 rounded-lg border border-gray-200 bg-white p-2 dark:border-gray-700 dark:bg-black" |
| 161 | + > |
| 162 | + {#if emptySchedules} |
| 163 | + <p class="text-center text-gray-700 dark:text-gray-400"> |
| 164 | + {$t('schedule_for_stop.no_schedules_available')} |
| 165 | + </p> |
| 166 | + {:else} |
| 167 | + <Accordion bind:this={accordionComponent}> |
| 168 | + {#each schedules as schedule} |
| 169 | + <AccordionItem> |
| 170 | + {#snippet header()} |
| 171 | + <span>{schedule.tripHeadsign}</span> |
| 172 | + {/snippet} |
| 173 | + <RouteScheduleTable {schedule} /> |
| 174 | + </AccordionItem> |
| 175 | + {/each} |
| 176 | + </Accordion> |
| 177 | + {/if} |
| 178 | + </div> |
189 | 179 | </div>
|
190 |
| - {/if} |
| 180 | + </div> |
191 | 181 | </StandalonePage>
|
0 commit comments