Recurring event fixes (#3030)
* Incorporates recurringEvent into calEvent * Recurrent event fixes * Update event.ts * type fixes * Update zod-utils.ts * Adding more recurringEvent to calEvent and other fixes * Moving away from heavy 3rd party enum * Fixing test * Renaming as suggested and fixes Co-authored-by: Leo Giovanetti <[email protected]>
This commit is contained in:
1 parent
8cd420173c
commit
b11398f551
55 files changed
+315
-333
No files matched your search
@@ -3,31 +3,26 @@ import timezone from "dayjs/plugin/timezone";
|
||||
import { TFunction } from "next-i18next";
|
||||
import rrule from "rrule";
|
||||
|
||||
import type { CalendarEvent, RecurringEvent } from "@calcom/types/Calendar";
|
||||
import type { CalendarEvent } from "@calcom/types/Calendar";
|
||||
|
||||
import { Info } from "./Info";
|
||||
|
||||
dayjs.extend(timezone);
|
||||
|
||||
function getRecurringWhen(props: { calEvent: CalendarEvent; recurringEvent: RecurringEvent }) {
|
||||
function getRecurringWhen(props: { calEvent: CalendarEvent }) {
|
||||
const t = props.calEvent.attendees[0].language.translate;
|
||||
return props.recurringEvent?.count && props.recurringEvent?.freq
|
||||
const { calEvent: { recurringEvent } = {} } = props;
|
||||
return recurringEvent?.count && recurringEvent?.freq
|
||||
? ` - ${t("every_for_freq", {
|
||||
freq: t(`${rrule.FREQUENCIES[props.recurringEvent.freq].toString().toLowerCase()}`),
|
||||
})} ${props.recurringEvent.count} ${t(
|
||||
`${rrule.FREQUENCIES[props.recurringEvent.freq].toString().toLowerCase()}`,
|
||||
{ count: props.recurringEvent.count }
|
||||
)}`
|
||||
freq: t(`${rrule.FREQUENCIES[recurringEvent.freq].toString().toLowerCase()}`),
|
||||
})} ${recurringEvent.count} ${t(`${rrule.FREQUENCIES[recurringEvent.freq].toString().toLowerCase()}`, {
|
||||
count: recurringEvent.count,
|
||||
})}`
|
||||
: "";
|
||||
}
|
||||
|
||||
export function WhenInfo(props: {
|
||||
calEvent: CalendarEvent;
|
||||
recurringEvent: RecurringEvent;
|
||||
timeZone: string;
|
||||
t: TFunction;
|
||||
}) {
|
||||
const { timeZone, t } = props;
|
||||
export function WhenInfo(props: { calEvent: CalendarEvent; timeZone: string; t: TFunction }) {
|
||||
const { timeZone, t, calEvent: { recurringEvent } = {} } = props;
|
||||
|
||||
function getRecipientStart(format: string) {
|
||||
return dayjs(props.calEvent.startTime).tz(timeZone).format(format);
|
||||
@@ -44,7 +39,7 @@ export function WhenInfo(props: {
|
||||
lineThrough={!!props.calEvent.cancellationReason}
|
||||
description={
|
||||
<>
|
||||
{props.recurringEvent?.count ? `${t("starting")} ` : ""}
|
||||
{recurringEvent?.count ? `${t("starting")} ` : ""}
|
||||
{t(getRecipientStart("dddd").toLowerCase())}, {t(getRecipientStart("MMMM").toLowerCase())}{" "}
|
||||
{getRecipientStart("D, YYYY | h:mma")} - {getRecipientEnd("h:mma")}{" "}
|
||||
<span style={{ color: "#888888" }}>({timeZone})</span>
|
||||
|
||||
@@ -2,7 +2,9 @@ import { AttendeeScheduledEmail } from "./AttendeeScheduledEmail";
|
||||
|
||||
export const AttendeeDeclinedEmail = (props: React.ComponentProps<typeof AttendeeScheduledEmail>) => (
|
||||
<AttendeeScheduledEmail
|
||||
title={props.recurringEvent?.count ? "event_request_declined_recurring" : "event_request_declined"}
|
||||
title={
|
||||
props.calEvent.recurringEvent?.count ? "event_request_declined_recurring" : "event_request_declined"
|
||||
}
|
||||
headerType="xCircle"
|
||||
subject="event_declined_subject"
|
||||
callToAction={null}
|
||||
|
||||
@@ -3,10 +3,10 @@ import { AttendeeScheduledEmail } from "./AttendeeScheduledEmail";
|
||||
export const AttendeeRequestEmail = (props: React.ComponentProps<typeof AttendeeScheduledEmail>) => (
|
||||
<AttendeeScheduledEmail
|
||||
title={props.calEvent.organizer.language.translate(
|
||||
props.recurringEvent?.count ? "booking_submitted_recurring" : "booking_submitted"
|
||||
props.calEvent.recurringEvent?.count ? "booking_submitted_recurring" : "booking_submitted"
|
||||
)}
|
||||
subtitle={props.calEvent.organizer.language.translate(
|
||||
props.recurringEvent.count
|
||||
props.calEvent.recurringEvent?.count
|
||||
? "user_needs_to_confirm_or_reject_booking_recurring"
|
||||
: "user_needs_to_confirm_or_reject_booking",
|
||||
{ user: props.calEvent.organizer.name }
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { CalendarEvent, Person, RecurringEvent } from "@calcom/types/Calendar";
|
||||
import type { CalendarEvent, Person } from "@calcom/types/Calendar";
|
||||
|
||||
import { BaseScheduledEmail } from "./BaseScheduledEmail";
|
||||
|
||||
@@ -6,7 +6,6 @@ export const AttendeeScheduledEmail = (
|
||||
props: {
|
||||
calEvent: CalendarEvent;
|
||||
attendee: Person;
|
||||
recurringEvent: RecurringEvent;
|
||||
} & Partial<React.ComponentProps<typeof BaseScheduledEmail>>
|
||||
) => {
|
||||
return (
|
||||
|
||||
@@ -5,7 +5,7 @@ import toArray from "dayjs/plugin/toArray";
|
||||
import utc from "dayjs/plugin/utc";
|
||||
import type { TFunction } from "next-i18next";
|
||||
|
||||
import type { CalendarEvent, Person, RecurringEvent } from "@calcom/types/Calendar";
|
||||
import type { CalendarEvent, Person } from "@calcom/types/Calendar";
|
||||
|
||||
import {
|
||||
BaseEmailHtml,
|
||||
@@ -26,7 +26,6 @@ export const BaseScheduledEmail = (
|
||||
props: {
|
||||
calEvent: CalendarEvent;
|
||||
attendee: Person;
|
||||
recurringEvent: RecurringEvent;
|
||||
timeZone: string;
|
||||
t: TFunction;
|
||||
} & Partial<React.ComponentProps<typeof BaseEmailHtml>>
|
||||
@@ -56,7 +55,7 @@ export const BaseScheduledEmail = (
|
||||
title={t(
|
||||
props.title
|
||||
? props.title
|
||||
: props.recurringEvent?.count
|
||||
: props.calEvent.recurringEvent?.count
|
||||
? "your_event_has_been_scheduled_recurring"
|
||||
: "your_event_has_been_scheduled"
|
||||
)}
|
||||
@@ -69,7 +68,7 @@ export const BaseScheduledEmail = (
|
||||
<Info label={t("cancellation_reason")} description={props.calEvent.cancellationReason} withSpacer />
|
||||
<Info label={t("rejection_reason")} description={props.calEvent.rejectionReason} withSpacer />
|
||||
<Info label={t("what")} description={props.calEvent.type} withSpacer />
|
||||
<WhenInfo calEvent={props.calEvent} recurringEvent={props.recurringEvent} t={t} timeZone={timeZone} />
|
||||
<WhenInfo calEvent={props.calEvent} t={t} timeZone={timeZone} />
|
||||
<WhoInfo calEvent={props.calEvent} t={t} />
|
||||
<LocationInfo calEvent={props.calEvent} t={t} />
|
||||
<Info label={t("description")} description={props.calEvent.description} withSpacer />
|
||||
|
||||
@@ -4,7 +4,7 @@ import { OrganizerScheduledEmail } from "./OrganizerScheduledEmail";
|
||||
export const OrganizerRequestEmail = (props: React.ComponentProps<typeof OrganizerScheduledEmail>) => (
|
||||
<OrganizerScheduledEmail
|
||||
title={
|
||||
props.title || props.recurringEvent?.count
|
||||
props.title || props.calEvent.recurringEvent?.count
|
||||
? "event_awaiting_approval_recurring"
|
||||
: "event_awaiting_approval"
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { CalendarEvent, Person, RecurringEvent } from "@calcom/types/Calendar";
|
||||
import type { CalendarEvent, Person } from "@calcom/types/Calendar";
|
||||
|
||||
import { BaseScheduledEmail } from "./BaseScheduledEmail";
|
||||
|
||||
@@ -6,7 +6,6 @@ export const OrganizerScheduledEmail = (
|
||||
props: {
|
||||
calEvent: CalendarEvent;
|
||||
attendee: Person;
|
||||
recurringEvent: RecurringEvent;
|
||||
} & Partial<React.ComponentProps<typeof BaseScheduledEmail>>
|
||||
) => {
|
||||
const t = props.calEvent.organizer.language.translate;
|
||||
@@ -15,7 +14,9 @@ export const OrganizerScheduledEmail = (
|
||||
timeZone={props.calEvent.organizer.timeZone}
|
||||
t={t}
|
||||
subject={t("confirmed_event_type_subject")}
|
||||
title={t(props.recurringEvent?.count ? "new_event_scheduled_recurring" : "new_event_scheduled")}
|
||||
title={t(
|
||||
props.calEvent.recurringEvent?.count ? "new_event_scheduled_recurring" : "new_event_scheduled"
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user