first commit
This commit is contained in:
45
calcom/packages/lib/recurringStrings.ts
Normal file
45
calcom/packages/lib/recurringStrings.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
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 "";
|
||||
};
|
||||
Reference in New Issue
Block a user