From 6de737bbf8b078843d39f27186b740daf163fac9 Mon Sep 17 00:00:00 2001 From: Sean Morley Date: Sun, 11 May 2025 11:50:29 -0400 Subject: [PATCH] Replace crypto.randomUUID with a unique ID generation method for visit objects and timezone selector instance --- frontend/src/lib/components/DateRangeCollapse.svelte | 7 +++++-- frontend/src/lib/components/TimezoneSelector.svelte | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/frontend/src/lib/components/DateRangeCollapse.svelte b/frontend/src/lib/components/DateRangeCollapse.svelte index 4161ad3..7473772 100644 --- a/frontend/src/lib/components/DateRangeCollapse.svelte +++ b/frontend/src/lib/components/DateRangeCollapse.svelte @@ -141,9 +141,12 @@ } function createVisitObject(): Visit | TransportationVisit { + // Generate a unique ID using built-in methods + const uniqueId = Date.now().toString(36) + Math.random().toString(36).substring(2); + if (type === 'transportation') { const transportVisit: TransportationVisit = { - id: crypto.randomUUID(), + id: uniqueId, start_date: utcStartDate ?? '', end_date: utcEndDate ?? utcStartDate ?? '', notes: note ?? '', @@ -153,7 +156,7 @@ return transportVisit; } else { const regularVisit: Visit = { - id: crypto.randomUUID(), + id: uniqueId, start_date: utcStartDate ?? '', end_date: utcEndDate ?? utcStartDate ?? '', notes: note ?? '', diff --git a/frontend/src/lib/components/TimezoneSelector.svelte b/frontend/src/lib/components/TimezoneSelector.svelte index b0e52fd..5603555 100644 --- a/frontend/src/lib/components/TimezoneSelector.svelte +++ b/frontend/src/lib/components/TimezoneSelector.svelte @@ -4,7 +4,8 @@ export let selectedTimezone: string = Intl.DateTimeFormat().resolvedOptions().timeZone; // Generate a unique ID for this component instance - const instanceId = `tz-selector-${crypto.randomUUID().substring(0, 8)}`; + const uniqueId = Date.now().toString(36) + Math.random().toString(36).substring(2); + const instanceId = `tz-selector-${uniqueId}`; let dropdownOpen = false; let searchQuery = '';