Skip to content

Commit de98578

Browse files
authored
fix: use disableToasts for handling notifications in EventTypeSettings atom (calcom#23490)
* fix: use disableToasts for handling notifications * add changesets
1 parent c0a59a2 commit de98578

2 files changed

Lines changed: 19 additions & 4 deletions

File tree

.changeset/light-lands-write.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@calcom/atoms": patch
3+
---
4+
5+
This PR fixes the prop `disableToasts` not working

packages/platform/atoms/event-types/wrappers/EventTypePlatformWrapper.tsx

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,18 @@ const EventType = forwardRef<
9696
const { data: user, isLoading: isUserLoading } = useMe();
9797

9898
const handleDeleteSuccess = () => {
99-
showToast(t("event_type_deleted_successfully"), "success");
99+
if (!disableToasts) {
100+
showToast(t("event_type_deleted_successfully"), "success");
101+
}
100102
isTeamEventTypeDeleted.current = true;
101103
setSlugExistsChildrenDialogOpen([]);
102104
onDeleteSuccess?.();
103105
};
104106

105107
const handleDeleteError = (err: Error) => {
106-
showToast(err.message, "error");
108+
if (!disableToasts) {
109+
showToast(err.message, "error");
110+
}
107111
onDeleteError?.(err.message);
108112
};
109113

@@ -137,7 +141,9 @@ const EventType = forwardRef<
137141

138142
// Reset the form with these values as new default values to ensure the correct comparison for dirtyFields eval
139143
form.reset(currentValues);
140-
toast({ description: t("event_type_updated_successfully", { eventTypeTitle: eventType.title }) });
144+
if (!disableToasts) {
145+
toast({ description: t("event_type_updated_successfully", { eventTypeTitle: eventType.title }) });
146+
}
141147
onSuccess?.(currentValues);
142148
callbacksRef.current?.onSuccess?.();
143149
},
@@ -148,7 +154,9 @@ const EventType = forwardRef<
148154
const currentValues = form.getValues();
149155
const message = err?.message;
150156
const description = message ? t(message) : t(err.message);
151-
toast({ description });
157+
if (!disableToasts) {
158+
toast({ description });
159+
}
152160
onError?.(currentValues, err);
153161

154162
const errorObj = new Error(description);
@@ -386,6 +394,7 @@ export const EventTypePlatformWrapper = forwardRef<
386394
allowDelete = true,
387395
customClassNames,
388396
isDryRun,
397+
disableToasts,
389398
onFormStateChange,
390399
} = props;
391400
const { data: eventTypeQueryData } = useAtomsEventTypeById(id);
@@ -421,6 +430,7 @@ export const EventTypePlatformWrapper = forwardRef<
421430
isDryRun={isDryRun}
422431
onFormStateChange={onFormStateChange}
423432
ref={ref}
433+
disableToasts={disableToasts}
424434
/>
425435
);
426436
});

0 commit comments

Comments
 (0)