feat: AvailabilitySettings atom toggle toasts (#17216)
This commit is contained in:
+22
-12
@@ -35,6 +35,7 @@ type AvailabilitySettingsPlatformWrapperProps = {
|
||||
onBeforeUpdate?: (updateBody: UpdateScheduleInput_2024_06_11) => boolean | Promise<boolean>;
|
||||
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",
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user