From 2385cb0852d77a35a12fa898a99c479b640e699b Mon Sep 17 00:00:00 2001 From: Ahmedhossamdev Date: Wed, 20 Nov 2024 16:59:04 -0800 Subject: [PATCH] feat: Enhance scheduleAccordionItem with improved table structure and conditional rendering for AM/PM availability --- .../scheduleAccordionItem.svelte | 112 ++++++++++-------- 1 file changed, 62 insertions(+), 50 deletions(-) diff --git a/src/components/schedule-for-stop/scheduleAccordionItem.svelte b/src/components/schedule-for-stop/scheduleAccordionItem.svelte index ba697af..d0a8446 100644 --- a/src/components/schedule-for-stop/scheduleAccordionItem.svelte +++ b/src/components/schedule-for-stop/scheduleAccordionItem.svelte @@ -13,7 +13,7 @@ function formatHour(hour) { const hourInt = +hour; - if (hourInt === 0) return 12; + if (hourInt === 0) return '12'; if (hourInt > 12) return hourInt - 12; return hourInt; } @@ -39,63 +39,75 @@ {schedule.tripHeadsign} - - - - - - - - - - - - {#if renderScheduleTable(schedule).amTimes.length === 0} +
+
HourMinutes
AM
+ - + + - {:else} - {#each renderScheduleTable(schedule).amTimes as [hour, times]} + + + + + + {#if renderScheduleTable(schedule).amTimes.length === 0} - - - {/each} - {/if} + {:else} + {#each renderScheduleTable(schedule).amTimes as [hour, times]} + + + + + {/each} + {/if} - - - - {#if renderScheduleTable(schedule).pmTimes.length === 0} - - + + - {:else} - {#each renderScheduleTable(schedule).pmTimes as [hour, times]} + {#if renderScheduleTable(schedule).pmTimes.length === 0} - - - {/each} - {/if} - -
No AM schedules availableHourMinutes
AM
{formatHour(hour)}:00 - {#each times as stopTime, index (index)} - - {extractMinutes(stopTime.arrivalTime)} - {index < times.length - 1 ? ', ' : ''} - - {/each} + + No AM schedules available
+ {formatHour(hour)} AM + + {#each times as stopTime, index (index)} + + {extractMinutes(stopTime.arrivalTime)} + {index < times.length - 1 ? ', ' : ''} + + {/each} +
PM
No PM schedules available
PM
{formatHour(hour)}:00 - {#each times as stopTime, index (index)} - - {extractMinutes(stopTime.arrivalTime)} - {index < times.length - 1 ? ', ' : ''} - - {/each} + + No PM schedules available
+ {:else} + {#each renderScheduleTable(schedule).pmTimes as [hour, times]} + + + {formatHour(hour)} PM + + + {#each times as stopTime, index (index)} + + {extractMinutes(stopTime.arrivalTime)} + {index < times.length - 1 ? ', ' : ''} + + {/each} + + + {/each} + {/if} + + +