Skip to content

Commit

Permalink
feat: ✨ fix cancel
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinWu098 committed Jun 3, 2024
1 parent fb1c5eb commit be74975
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/routes/availability/[slug]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import {
availabilityDates,
availabilityTimeBlocks,
generateSampleDates,
generateTimeBlocks,
getTimeFromHourMinuteString,
guestSession,
Expand All @@ -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";
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit be74975

Please sign in to comment.