From b1f50fe22d85ed6403dbb75faf7c83c76aa2315b Mon Sep 17 00:00:00 2001 From: Rajiv Sahal Date: Tue, 15 Apr 2025 22:24:21 +0530 Subject: [PATCH] feat: dry run behaviour for AvailabilitySettings atom (#20686) --- .../AvailabilitySettingsPlatformWrapper.tsx | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/packages/platform/atoms/availability/wrappers/AvailabilitySettingsPlatformWrapper.tsx b/packages/platform/atoms/availability/wrappers/AvailabilitySettingsPlatformWrapper.tsx index ca39fc3da2..6ae43160e3 100644 --- a/packages/platform/atoms/availability/wrappers/AvailabilitySettingsPlatformWrapper.tsx +++ b/packages/platform/atoms/availability/wrappers/AvailabilitySettingsPlatformWrapper.tsx @@ -36,6 +36,7 @@ type AvailabilitySettingsPlatformWrapperProps = { allowDelete?: boolean; allowSetToDefault?: boolean; disableToasts?: boolean; + isDryRun?: boolean; }; export const AvailabilitySettingsPlatformWrapper = ({ @@ -51,6 +52,7 @@ export const AvailabilitySettingsPlatformWrapper = ({ allowDelete, allowSetToDefault, disableToasts, + isDryRun = false, }: AvailabilitySettingsPlatformWrapperProps) => { const { isLoading, data: schedule } = useSchedule(id); const { data: schedules } = useSchedules(); @@ -124,10 +126,26 @@ export const AvailabilitySettingsPlatformWrapper = ({ { - atomSchedule.id && handleDelete(atomSchedule.id); + if (isDryRun) { + toast({ + description: "Schedule deleted successfully", + }); + } + + if (!isDryRun && atomSchedule.id) { + handleDelete(atomSchedule.id); + } }} handleSubmit={async (data) => { - atomSchedule.id && handleUpdate(atomSchedule.id, data); + if (isDryRun) { + toast({ + description: "Schedule updated successfully", + }); + } + + if (!isDryRun && atomSchedule.id) { + handleUpdate(atomSchedule.id, data); + } }} weekStart={me?.data?.weekStart || "Sunday"} timeFormat={timeFormat}