diff --git a/apps/web/components/eventtype/EventAvailabilityTab.tsx b/apps/web/components/eventtype/EventAvailabilityTab.tsx index e60f05f30d..9b20648df7 100644 --- a/apps/web/components/eventtype/EventAvailabilityTab.tsx +++ b/apps/web/components/eventtype/EventAvailabilityTab.tsx @@ -154,12 +154,11 @@ const EventTypeScheduleDetails = ({ const EventTypeSchedule = ({ eventType }: { eventType: EventTypeSetup }) => { const { t } = useLocale(); - const { shouldLockIndicator, shouldLockDisableProps, isManagedEventType, isChildrenManagedEventType } = - useLockedFieldsManager( - eventType, - t("locked_fields_admin_description"), - t("locked_fields_member_description") - ); + const { shouldLockIndicator, isManagedEventType, isChildrenManagedEventType } = useLockedFieldsManager( + eventType, + t("locked_fields_admin_description"), + t("locked_fields_member_description") + ); const { watch } = useFormContext(); const watchSchedule = watch("schedule"); const formMethods = useFormContext(); @@ -205,6 +204,8 @@ const EventTypeSchedule = ({ eventType }: { eventType: EventTypeSetup }) => { const value = options.find((option) => scheduleId ? option.value === scheduleId + : isManagedEventType + ? option.value === 0 : option.value === schedules.find((schedule) => schedule.isDefault)?.id ); diff --git a/apps/web/pages/event-types/index.tsx b/apps/web/pages/event-types/index.tsx index 5ad100ae18..d5ef9e2ca5 100644 --- a/apps/web/pages/event-types/index.tsx +++ b/apps/web/pages/event-types/index.tsx @@ -352,6 +352,9 @@ export const EventTypeList = ({ group, groupIndex, readOnly, types }: EventTypeL const firstItem = types[0]; const lastItem = types[types.length - 1]; + const isManagedEventPrefix = () => { + return deleteDialogTypeSchedulingType === SchedulingType.MANAGED ? "_managed" : ""; + }; return (
    @@ -501,7 +504,7 @@ export const EventTypeList = ({ group, groupIndex, readOnly, types }: EventTypeL )} {/* readonly is only set when we are on a team - if we are on a user event type null will be the value. */} {(group.metadata?.readOnly === false || group.metadata.readOnly === null) && - isManagedEventType && ( + !isChildrenManagedEventType && ( <> @@ -533,27 +536,31 @@ export const EventTypeList = ({ group, groupIndex, readOnly, types }: EventTypeL - - - {t("preview")} - - - - { - navigator.clipboard.writeText(calLink); - showToast(t("link_copied"), "success"); - }} - StartIcon={Clipboard} - className="w-full rounded-none text-left"> - {t("copy_link")} - - + {!isManagedEventType && ( + <> + + + {t("preview")} + + + + { + navigator.clipboard.writeText(calLink); + showToast(t("link_copied"), "success"); + }} + StartIcon={Clipboard} + className="w-full rounded-none text-left"> + {t("copy_link")} + + + + )} {isNativeShare ? ( ) : null} - - router.push("/event-types/" + type.id)} - StartIcon={Edit} - className="w-full rounded-none"> - {t("edit")} - - - - openDuplicateModal(type, group)} - StartIcon={Copy} - data-testid={"event-type-duplicate-" + type.id}> - {t("duplicate")} - - - - - { - setDeleteDialogOpen(true); - setDeleteDialogTypeId(type.id); - setDeleteDialogSchedulingType(type.schedulingType); - }} - StartIcon={Trash} - className="w-full rounded-none"> - {t("delete")} - - + {!readOnly && ( + + router.push("/event-types/" + type.id)} + StartIcon={Edit} + className="w-full rounded-none"> + {t("edit")} + + + )} + {!isManagedEventType && !isChildrenManagedEventType && ( + + openDuplicateModal(type, group)} + StartIcon={Copy} + data-testid={"event-type-duplicate-" + type.id}> + {t("duplicate")} + + + )} + {/* readonly is only set when we are on a team - if we are on a user event type null will be the value. */} + {(group.metadata?.readOnly === false || group.metadata.readOnly === null) && + !isChildrenManagedEventType && ( + <> + + + { + setDeleteDialogOpen(true); + setDeleteDialogTypeId(type.id); + setDeleteDialogSchedulingType(type.schedulingType); + }} + StartIcon={Trash} + className="w-full rounded-none"> + {t("delete")} + + + + )} @@ -616,36 +633,24 @@ export const EventTypeList = ({ group, groupIndex, readOnly, types }: EventTypeL { e.preventDefault(); deleteEventTypeHandler(deleteDialogTypeId); }}> -

    - {t( - `delete_${ - deleteDialogTypeSchedulingType === SchedulingType.MANAGED && "managed" - }_event_type_description` - )} -

    + i18nKey={`delete${isManagedEventPrefix()}_event_type_description`} + components={{ li:

  • , ul:
      }}> +
        +
      • Members assigned to this event type will also have their event types deleted.
      • +
      • + Anyone who they've shared their link with will no longer be able to book using it. +
      • +
      +

  • diff --git a/apps/web/test/lib/handleChildrenEventTypes.test.ts b/apps/web/test/lib/handleChildrenEventTypes.test.ts index dfd173e4e8..e88e89cc9c 100644 --- a/apps/web/test/lib/handleChildrenEventTypes.test.ts +++ b/apps/web/test/lib/handleChildrenEventTypes.test.ts @@ -95,7 +95,8 @@ describe("handleChildrenEventTypes", () => { it("Adds new users", async () => { // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore - const { schedulingType, id, teamId, timeZone, scheduleId, users, ...evType } = mockFindFirstEventType({ + // eslint-disable-next-line + const { schedulingType, id, teamId, timeZone, users, ...evType } = mockFindFirstEventType({ id: 123, metadata: { managedEventConfig: {} }, locations: [], @@ -130,6 +131,7 @@ describe("handleChildrenEventTypes", () => { it("Updates old users", async () => { // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore + // eslint-disable-next-line const { schedulingType, id, teamId, timeZone, locations, parentId, userId, scheduleId, ...evType } = mockFindFirstEventType({ metadata: { managedEventConfig: {} }, @@ -214,7 +216,8 @@ describe("handleChildrenEventTypes", () => { it("Deletes existent event types for new users added", async () => { // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore - const { schedulingType, id, teamId, timeZone, scheduleId, users, ...evType } = mockFindFirstEventType({ + // eslint-disable-next-line + const { schedulingType, id, teamId, timeZone, users, ...evType } = mockFindFirstEventType({ id: 123, metadata: { managedEventConfig: {} }, locations: [], @@ -250,6 +253,7 @@ describe("handleChildrenEventTypes", () => { it("Deletes existent event types for old users updated", async () => { // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore + // eslint-disable-next-line const { schedulingType, id, teamId, timeZone, users, locations, parentId, userId, ...evType } = mockFindFirstEventType({ metadata: { managedEventConfig: {} }, diff --git a/packages/prisma/zod-utils.ts b/packages/prisma/zod-utils.ts index b90ed3b1b8..bfd7809952 100644 --- a/packages/prisma/zod-utils.ts +++ b/packages/prisma/zod-utils.ts @@ -517,7 +517,7 @@ export const allManagedEventTypeProps: { [k in keyof Omit