feat: dry run behaviour for AvailabilitySettings atom (#20686)

This commit is contained in:
Rajiv Sahal
2025-04-15 22:24:21 +05:30
committed by GitHub
parent ce995c39f2
commit b1f50fe22d
@@ -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 = ({
<AvailabilitySettings
disableEditableHeading={disableEditableHeading}
handleDelete={() => {
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}