diff --git a/frontend/src/lib/components/layout/BusinessHours.svelte b/frontend/src/lib/components/layout/BusinessHours.svelte index 9f12327..55e117c 100644 --- a/frontend/src/lib/components/layout/BusinessHours.svelte +++ b/frontend/src/lib/components/layout/BusinessHours.svelte @@ -47,6 +47,21 @@ hours: Array<{ weekday: number; startTime: string; endTime: string; isOpen: boolean }>; }; + let scheduledChangeDays = $derived( + scheduledChange + ? scheduledChange.hours.filter((h) => { + const current = defaultHours.find((dh) => dh.weekday === h.weekday); + if (!current) return true; + if (h.isOpen !== current.isOpen) return true; + // Normalize time strings before comparing — the current hours + // may include microsecond precision ("17:00:00.000000") from + // PostgreSQL's ::text cast, while staged hours are plain "17:00". + const norm = (t: string) => t.replace(/\.\d+$/, '').replace(/^(\d{2}:\d{2}).*$/, '$1'); + return norm(h.startTime) !== norm(current.startTime) || norm(h.endTime) !== norm(current.endTime); + }) + : [] + ); + let loading = $state(true); let error = $state(false); @@ -290,10 +305,10 @@ {/if} - {#if scheduledChange} + {#if scheduledChange && scheduledChangeDays.length > 0}
- Opening hours will change from + {scheduledChangeDays.length === 7 ? 'Opening hours will change from' : 'These opening hours will change from'} {new Date(scheduledChange.effective_date + 'T00:00:00').toLocaleDateString('en-GB', { day: 'numeric', month: 'short', @@ -301,7 +316,7 @@ timeZone: 'UTC' })}
- {#each scheduledChange.hours as h} + {#each scheduledChangeDays as h (h.weekday)}