From be7497587a8772fff6504021fdb8db8c51ccc490 Mon Sep 17 00:00:00 2001 From: Kevin Wu Date: Mon, 3 Jun 2024 10:15:16 -0700 Subject: [PATCH] =?UTF-8?q?feat:=20=E2=9C=A8=20fix=20cancel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/routes/availability/[slug]/+page.svelte | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/routes/availability/[slug]/+page.svelte b/src/routes/availability/[slug]/+page.svelte index a4f78dd1..cf40fb3e 100644 --- a/src/routes/availability/[slug]/+page.svelte +++ b/src/routes/availability/[slug]/+page.svelte @@ -8,7 +8,6 @@ import { availabilityDates, availabilityTimeBlocks, - generateSampleDates, generateTimeBlocks, getTimeFromHourMinuteString, guestSession, @@ -17,6 +16,7 @@ } from "$lib/stores/availabilityStores"; import { endTime, startTime } from "$lib/stores/meetingSetupStores"; import type { HourMinuteString } from "$lib/types/chrono"; + import { ZotDate } from "$lib/utils/ZotDate"; import { getGeneralAvailability } from "$lib/utils/availability"; import { cn } from "$lib/utils/utils"; import CancelCircleOutline from "~icons/mdi/cancel-circle-outline"; @@ -44,8 +44,21 @@ }; const handleCancel = async () => { - $availabilityDates = - (await getGeneralAvailability(data, $guestSession)) ?? generateSampleDates(); + const generalAvailability = await getGeneralAvailability(data, $guestSession); + + if (!generalAvailability || generalAvailability.length === 0) { + const updatedAvailabilityDates = $availabilityDates.map((item) => { + return new ZotDate( + item.day, + item.isSelected, + item.availability.map(() => false), + ); + }); + + availabilityDates.set(updatedAvailabilityDates); + } else { + $availabilityDates = generalAvailability; + } $isEditingAvailability = !$isEditingAvailability; $isStateUnsaved = false;