46 lines
1.1 KiB
TypeScript
46 lines
1.1 KiB
TypeScript
import type { TFunction } from "next-i18next";
|
|
|
|
import { Frequency } from "@calcom/prisma/zod-utils";
|
|
import type { RecurringEvent } from "@calcom/types/Calendar";
|
|
|
|
export const getRecurringFreq = ({
|
|
t,
|
|
recurringEvent,
|
|
}: {
|
|
t: TFunction;
|
|
recurringEvent: RecurringEvent;
|
|
}): string => {
|
|
if (recurringEvent.interval && recurringEvent.freq) {
|
|
return t("every_for_freq", {
|
|
freq: `${recurringEvent.interval > 1 ? recurringEvent.interval : ""} ${t(
|
|
Frequency[recurringEvent.freq].toString().toLowerCase(),
|
|
{
|
|
count: recurringEvent.interval,
|
|
}
|
|
)}`,
|
|
});
|
|
}
|
|
return "";
|
|
};
|
|
|
|
export const getEveryFreqFor = ({
|
|
t,
|
|
recurringEvent,
|
|
recurringCount,
|
|
recurringFreq,
|
|
}: {
|
|
t: TFunction;
|
|
recurringEvent: RecurringEvent;
|
|
recurringCount?: number;
|
|
recurringFreq?: string;
|
|
}): string => {
|
|
if (recurringEvent.freq) {
|
|
return `${recurringFreq || getRecurringFreq({ t, recurringEvent })} ${
|
|
recurringCount || recurringEvent.count
|
|
} ${t("occurrence", {
|
|
count: recurringCount || recurringEvent.count,
|
|
})}`;
|
|
}
|
|
return "";
|
|
};
|