fix: Remove cancel and reschedule links from email when event type doesn't allow (#22653)
Co-authored-by: Kartik Saini <[email protected]>
This commit is contained in:
1 parent
c88ed8cae7
commit
9b886036ad
7 files changed
+38
-5
No files matched your search
@@ -1,4 +1,4 @@
|
||||
import { getCancelLink, getRescheduleLink, getBookingUrl } from "@calcom/lib/CalEventParser";
|
||||
import { getBookingUrl, getCancelLink, getRescheduleLink } from "@calcom/lib/CalEventParser";
|
||||
import type { CalendarEvent, Person } from "@calcom/types/Calendar";
|
||||
|
||||
export function ManageLink(props: { calEvent: CalendarEvent; attendee: Person }) {
|
||||
@@ -11,8 +11,8 @@ export function ManageLink(props: { calEvent: CalendarEvent; attendee: Person })
|
||||
|
||||
const isOriginalAttendee = props.attendee.email === props.calEvent.attendees[0]?.email;
|
||||
const isOrganizer = props.calEvent.organizer.email === props.attendee.email;
|
||||
const hasCancelLink = Boolean(cancelLink);
|
||||
const hasRescheduleLink = Boolean(rescheduleLink);
|
||||
const hasCancelLink = Boolean(cancelLink) && !props.calEvent.disableCancelling;
|
||||
const hasRescheduleLink = Boolean(rescheduleLink) && !props.calEvent.disableRescheduling;
|
||||
const hasBookingLink = Boolean(bookingLink);
|
||||
const isRecurringEvent = props.calEvent.recurringEvent;
|
||||
const shouldDisplayRescheduleLink = Boolean(hasRescheduleLink && !isRecurringEvent);
|
||||
@@ -39,8 +39,7 @@ export function ManageLink(props: { calEvent: CalendarEvent; attendee: Person })
|
||||
textAlign: "center",
|
||||
width: "100%",
|
||||
}}>
|
||||
<>{t("need_to_make_a_change")}</>
|
||||
|
||||
{(shouldDisplayRescheduleLink || hasCancelLink) && <>{t("need_to_make_a_change")}</>}
|
||||
{shouldDisplayRescheduleLink && (
|
||||
<span>
|
||||
<a
|
||||
|
||||
@@ -687,4 +687,26 @@ describe("CalendarEventBuilder", () => {
|
||||
expect(event.title).toBe("Updated Event");
|
||||
expect(event.type).toBe("existing-type");
|
||||
});
|
||||
|
||||
it("should propagate disableCancelling and disableRescheduling", () => {
|
||||
const event = new CalendarEventBuilder()
|
||||
.withBasicDetails({
|
||||
bookerUrl: "https://cal.com/user/test-slug",
|
||||
title: "Test Event",
|
||||
startTime: mockStartTime,
|
||||
endTime: mockEndTime,
|
||||
additionalNotes: "Some notes",
|
||||
})
|
||||
.withEventType({
|
||||
slug: "test-slug",
|
||||
description: "Test description",
|
||||
id: 123,
|
||||
disableCancelling: true,
|
||||
disableRescheduling: true,
|
||||
})
|
||||
.build();
|
||||
|
||||
expect(event.disableCancelling).toBe(true);
|
||||
expect(event.disableRescheduling).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -53,6 +53,8 @@ export class CalendarEventBuilder {
|
||||
seatsShowAttendees?: boolean | null;
|
||||
seatsShowAvailabilityCount?: boolean | null;
|
||||
customReplyToEmail?: string | null;
|
||||
disableRescheduling?: boolean;
|
||||
disableCancelling?: boolean;
|
||||
}) {
|
||||
this.event = {
|
||||
...this.event,
|
||||
@@ -68,6 +70,8 @@ export class CalendarEventBuilder {
|
||||
seatsShowAttendees: eventType.seatsPerTimeSlot ? eventType.seatsShowAttendees : true,
|
||||
seatsShowAvailabilityCount: eventType.seatsPerTimeSlot ? eventType.seatsShowAvailabilityCount : true,
|
||||
customReplyToEmail: eventType.customReplyToEmail,
|
||||
disableRescheduling: eventType.disableRescheduling ?? false,
|
||||
disableCancelling: eventType.disableCancelling ?? false,
|
||||
};
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -1129,6 +1129,8 @@ async function handler(
|
||||
seatsShowAttendees: eventType.seatsPerTimeSlot ? eventType.seatsShowAttendees : true,
|
||||
seatsShowAvailabilityCount: eventType.seatsPerTimeSlot ? eventType.seatsShowAvailabilityCount : true,
|
||||
customReplyToEmail: eventType.customReplyToEmail,
|
||||
disableRescheduling: eventType.disableRescheduling ?? false,
|
||||
disableCancelling: eventType.disableCancelling ?? false,
|
||||
})
|
||||
.withOrganizer({
|
||||
id: organizerUser.id,
|
||||
|
||||
@@ -23,6 +23,8 @@ export const getEventTypesFromDB = async (eventTypeId: number) => {
|
||||
disableGuests: true,
|
||||
restrictionScheduleId: true,
|
||||
useBookerTimezone: true,
|
||||
disableRescheduling: true,
|
||||
disableCancelling: true,
|
||||
users: {
|
||||
select: {
|
||||
credentials: {
|
||||
|
||||
@@ -147,6 +147,8 @@ export class CalendarEventBuilder implements ICalendarEventBuilder {
|
||||
destinationCalendar: true,
|
||||
hideCalendarNotes: true,
|
||||
hideCalendarEventDetails: true,
|
||||
disableCancelling: true,
|
||||
disableRescheduling: true,
|
||||
},
|
||||
});
|
||||
} catch (error) {
|
||||
|
||||
Vendored
+2
@@ -206,6 +206,8 @@ export interface CalendarEvent {
|
||||
iCalUID?: string | null;
|
||||
iCalSequence?: number | null;
|
||||
hideOrganizerEmail?: boolean;
|
||||
disableCancelling?: boolean;
|
||||
disableRescheduling?: boolean;
|
||||
|
||||
// It has responses to all the fields(system + user)
|
||||
responses?: CalEventResponses | null;
|
||||
|
||||
Reference in new issue
Block a user