Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ✨ fix cancel for non-members #114

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading