From b7792d0d0affdfc257fb75856b69b4dbdf58f344 Mon Sep 17 00:00:00 2001 From: Lauris Skraucis Date: Mon, 21 Oct 2024 12:03:52 +0200 Subject: [PATCH] feat: AvailabilitySettings atom toggle toasts (#17216) --- .../AvailabilitySettingsPlatformWrapper.tsx | 34 ++++++++++++------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/packages/platform/atoms/availability/wrappers/AvailabilitySettingsPlatformWrapper.tsx b/packages/platform/atoms/availability/wrappers/AvailabilitySettingsPlatformWrapper.tsx index cad2cda278..ca39fc3da2 100644 --- a/packages/platform/atoms/availability/wrappers/AvailabilitySettingsPlatformWrapper.tsx +++ b/packages/platform/atoms/availability/wrappers/AvailabilitySettingsPlatformWrapper.tsx @@ -35,6 +35,7 @@ type AvailabilitySettingsPlatformWrapperProps = { onBeforeUpdate?: (updateBody: UpdateScheduleInput_2024_06_11) => boolean | Promise; allowDelete?: boolean; allowSetToDefault?: boolean; + disableToasts?: boolean; }; export const AvailabilitySettingsPlatformWrapper = ({ @@ -49,6 +50,7 @@ export const AvailabilitySettingsPlatformWrapper = ({ onBeforeUpdate, allowDelete, allowSetToDefault, + disableToasts, }: AvailabilitySettingsPlatformWrapperProps) => { const { isLoading, data: schedule } = useSchedule(id); const { data: schedules } = useSchedules(); @@ -60,30 +62,38 @@ export const AvailabilitySettingsPlatformWrapper = ({ const { mutate: deleteSchedule, isPending: isDeletionInProgress } = useDeleteSchedule({ onSuccess: (res) => { onDeleteSuccess?.(res); - toast({ - description: "Schedule deleted successfully", - }); + if (!disableToasts) { + toast({ + description: "Schedule deleted successfully", + }); + } }, onError: (err) => { onDeleteError?.(err); - toast({ - description: "Could not delete schedule", - }); + if (!disableToasts) { + toast({ + description: "Could not delete schedule", + }); + } }, }); const { mutate: updateSchedule, isPending: isSavingInProgress } = useUpdateSchedule({ onSuccess: (res) => { onUpdateSuccess?.(res); - toast({ - description: "Schedule updated successfully", - }); + if (!disableToasts) { + toast({ + description: "Schedule updated successfully", + }); + } }, onError: (err) => { onUpdateError?.(err); - toast({ - description: "Could not update schedule", - }); + if (!disableToasts) { + toast({ + description: "Could not update schedule", + }); + } }, });