Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 34 additions & 9 deletions packages/emails/src/components/WhenInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import dayjs from "@calcom/dayjs";
import "@calcom/dayjs/locales";
import { getEveryFreqFor } from "@calcom/lib/recurringStrings";
import type { TimeFormat } from "@calcom/lib/timeFormat";
import type { CalendarEvent, Person } from "@calcom/types/Calendar";
import type { RecurringEvent } from "@calcom/types/Calendar";
import type { CalendarEvent, Person, RecurringEvent } from "@calcom/types/Calendar";

import { Info } from "./Info";

Expand Down Expand Up @@ -40,10 +39,22 @@ export function WhenInfo(props: {
}) {
const { timeZone, t, calEvent: { recurringEvent } = {}, locale, timeFormat } = props;

function getPreviousRecipientStart(format: string): string | null {
if(!props.calEvent.previousStartTime) return null
return dayjs(props.calEvent.previousStartTime).tz(timeZone).locale(locale).format(format)
}

function getPreviousRecipientEnd(format: string): string | null {
if(!props.calEvent.previousEndTime) return null
return dayjs(props.calEvent.previousEndTime).tz(timeZone).locale(locale).format(format)
}

function getRecipientStart(format: string) {
return dayjs(props.calEvent.startTime).tz(timeZone).locale(locale).format(format);
}

const hasPreviousTime = !!(props.calEvent.previousStartTime && props.calEvent.previousEndTime);

function getRecipientEnd(format: string) {
return dayjs(props.calEvent.endTime).tz(timeZone).locale(locale).format(format);
}
Expand All @@ -56,16 +67,30 @@ export function WhenInfo(props: {
return (
<div>
<Info
label={`${t("when")} ${recurringInfo !== "" ? ` - ${recurringInfo}` : ""}`}
label={`${t("when")}${recurringInfo ? ` - ${recurringInfo}` : ""}`}
lineThrough={
!!props.calEvent.cancellationReason && !props.calEvent.cancellationReason.includes("$RCH$")
!!props.calEvent.cancellationReason &&
!props.calEvent.cancellationReason.includes("$RCH$")
}
description={
<span data-testid="when">
{recurringEvent?.count ? `${t("starting")} ` : ""}
{getRecipientStart(`dddd, LL | ${timeFormat}`)} - {getRecipientEnd(timeFormat)}{" "}
<span style={{ color: "#4B5563" }}>({timeZone})</span>
</span>
<div data-testid="when">
{hasPreviousTime && (
<div
style={{ textDecoration: "line-through", opacity: 0.6 }}
data-testid="previous-when">
{recurringEvent?.count ? `${t("starting")} ` : ""}
{getPreviousRecipientStart(`dddd, LL | ${timeFormat}`)} -{" "}
{getPreviousRecipientEnd(timeFormat)}{" "}
({timeZone})
</div>
)}
<div>
{recurringEvent?.count ? `${t("starting")} ` : ""}
{getRecipientStart(`dddd, LL | ${timeFormat}`)} -{" "}
{getRecipientEnd(timeFormat)}{" "}
({timeZone})
</div>
</div>
}
withSpacer
/>
Expand Down
13 changes: 13 additions & 0 deletions packages/features/bookings/lib/BookingEmailSmsHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ export class BookingEmailSmsHandler {
private async _handleRescheduled(data: RescheduleEmailAndSmsPayload) {
const {
evt,
originalRescheduledBooking,
eventType: { metadata },
rescheduleReason,
additionalNotes,
Expand All @@ -127,6 +128,12 @@ export class BookingEmailSmsHandler {
await sendRescheduledEmailsAndSMS(
{
...evt,
previousStartTime: originalRescheduledBooking?.startTime
? dayjs(originalRescheduledBooking.startTime).utc().format()
: undefined,
previousEndTime: originalRescheduledBooking?.endTime
? dayjs(originalRescheduledBooking.endTime).utc().format()
: undefined,
additionalInformation,
additionalNotes,
cancellationReason: `$RCH$${rescheduleReason || ""}`,
Expand Down Expand Up @@ -157,6 +164,12 @@ export class BookingEmailSmsHandler {
additionalInformation,
additionalNotes,
cancellationReason: `$RCH$${rescheduleReason || ""}`,
previousStartTime: originalRescheduledBooking?.startTime
? dayjs(originalRescheduledBooking.startTime).utc().format()
: undefined,
previousEndTime: originalRescheduledBooking?.endTime
? dayjs(originalRescheduledBooking.endTime).utc().format()
: undefined,
};
const cancelledRRHostEvt = cloneDeep(copyEventAdditionalInfo);
this.log.debug("Emails: Sending rescheduled emails for booking confirmation");
Expand Down
2 changes: 2 additions & 0 deletions packages/types/Calendar.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ export interface CalendarEvent {
platformRescheduleUrl?: string | null;
platformCancelUrl?: string | null;
platformBookingUrl?: string | null;
previousStartTime?: string;
previousEndTime?: string;
hideBranding?: boolean;
oneTimePassword?: string | null;
delegationCredentialId?: string | null;
Expand Down
Loading