Scheduling infrastructure for absolutely everyone.
feat: dry run behaviour for event type atoms (#20689)
Rajiv Sahalce995c39f2e2
diff --git a/packages/platform/atoms/event-types/wrappers/CreateEventTypePlatformWrapper.tsx b/packages/platform/atoms/event-types/wrappers/CreateEventTypePlatformWrapper.tsxindex e470e6d431a..f25cc8f6761 100644--- a/packages/platform/atoms/event-types/wrappers/CreateEventTypePlatformWrapper.tsx+++ b/packages/platform/atoms/event-types/wrappers/CreateEventTypePlatformWrapper.tsx@@ -27,6 +27,7 @@ type CreateEventTypeProps = {buttons?: ActionButtonsClassNames;};onCancel?: () => void;+ isDryRun?: boolean;};const ActionButtons = ({@@ -67,6 +68,7 @@ export const CreateEventTypePlatformWrapper = ({onError,customClassNames,onCancel,+ isDryRun = false,}: CreateEventTypeProps) => {const { form, isManagedEventType } = useCreateEventTypeForm();const createEventTypeQuery = useCreateEventType({ onSuccess, onError });@@ -86,15 +88,16 @@ export const CreateEventTypePlatformWrapper = ({form={form}isManagedEventType={isManagedEventType}handleSubmit={(values) => {- createTeamEventTypeQuery.mutate({- lengthInMinutes: values.length,- title: values.title,- slug: values.slug,- description: values.description ?? "",- schedulingType: values.schedulingType ?? "COLLECTIVE",- hosts: [],- teamId,- });+ !isDryRun &&+ createTeamEventTypeQuery.mutate({+ lengthInMinutes: values.length,+ title: values.title,+ slug: values.slug,+ description: values.description ?? "",+ schedulingType: values.schedulingType ?? "COLLECTIVE",+ hosts: [],+ teamId,+ });}}SubmitButton={(isPending) =>ActionButtons({@@ -115,12 +118,13 @@ export const CreateEventTypePlatformWrapper = ({form={form}isManagedEventType={isManagedEventType}handleSubmit={(values) => {- createEventTypeQuery.mutate({- lengthInMinutes: values.length,- title: values.title,- slug: values.slug,- description: values.description ?? "",- });+ !isDryRun &&+ createEventTypeQuery.mutate({+ lengthInMinutes: values.length,+ title: values.title,+ slug: values.slug,+ description: values.description ?? "",+ });}}SubmitButton={(isPending) =>ActionButtons({diff --git a/packages/platform/atoms/event-types/wrappers/EventTypePlatformWrapper.tsx b/packages/platform/atoms/event-types/wrappers/EventTypePlatformWrapper.tsxindex ad4bd54672b..f27cb4bc949 100644--- a/packages/platform/atoms/event-types/wrappers/EventTypePlatformWrapper.tsx+++ b/packages/platform/atoms/event-types/wrappers/EventTypePlatformWrapper.tsx@@ -56,6 +56,7 @@ export type EventTypePlatformWrapperProps = {allowDelete: boolean;customClassNames?: EventTypeCustomClassNames;disableToasts?: boolean;+ isDryRun?: boolean;};const EventType = ({@@ -68,6 +69,7 @@ const EventType = ({allowDelete = true,customClassNames,disableToasts = false,+ isDryRun = false,...props}: EventTypeSetupProps & EventTypePlatformWrapperProps) => {const { t } = useLocale();@@ -141,7 +143,13 @@ const EventType = ({const { form, handleSubmit } = useEventTypeForm({eventType,- onSubmit: (data) => updateMutation.mutate(data),+ onSubmit: (data) => {+ if (!isDryRun) {+ updateMutation.mutate(data);+ } else {+ toast({ description: t("event_type_updated_successfully", { eventTypeTitle: eventType.title }) });+ }+ },});const slug = form.watch("slug") ?? eventType.slug;@@ -244,12 +252,16 @@ const EventType = ({});const onDelete = () => {- if (allowDelete) {+ if (allowDelete && !isDryRun) {isTeamEventTypeDeleted.current = true;team?.id? deleteTeamEventTypeMutation.mutate({ eventTypeId: id, teamId: team.id }): deleteMutation.mutate(id);}++ if (isDryRun) {+ handleDeleteSuccess();+ }};const onConflict = (conflicts: ChildrenEventType[]) => {@@ -307,6 +319,7 @@ export const EventTypePlatformWrapper = ({onDeleteError,allowDelete = true,customClassNames,+ isDryRun,}: EventTypePlatformWrapperProps) => {const { data: eventTypeQueryData } = useAtomsEventTypeById(id);const queryClient = useQueryClient();@@ -338,6 +351,7 @@ export const EventTypePlatformWrapper = ({onDeleteError={onDeleteError}allowDelete={allowDelete}customClassNames={customClassNames}+ isDryRun={isDryRun}/>);};