* remove event type requires confirmation * allow sms sending also for team (frontend) * allow text to attendee for team (backend) * add rate limiting for SMS (WIP) * add functionality to lock and unlock SMS sending (+admin UI view) * rename to smsLockState * add ability to lock users and teams * don't send sms if locked * add missing imports * fix rate limit namespace * add translation * fix type error * remove prop from UsersTable * add smsLockState to buildUser * code clean up * create seperate sms rate limit function * fix type error * add missing userId and teamId to sendSMS * code improvements * add User Team type * fix marking as reviewed * check monthly sms limit only for user * don't lock orgs * fix type error * fix avatars * fix type error * fix type error * fix type error --------- Co-authored-by: CarinaWolli <wollencarina@gmail.com> Co-authored-by: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com> Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com>
53 lines
1.8 KiB
TypeScript
53 lines
1.8 KiB
TypeScript
import type { TFunction } from "next-i18next";
|
|
|
|
import { WorkflowActions } from "@calcom/prisma/enums";
|
|
|
|
import { isSMSOrWhatsappAction, isWhatsappAction, isEmailToAttendeeAction } from "./actionHelperFunctions";
|
|
import {
|
|
TIME_UNIT,
|
|
WHATSAPP_WORKFLOW_TEMPLATES,
|
|
WORKFLOW_ACTIONS,
|
|
BASIC_WORKFLOW_TEMPLATES,
|
|
WORKFLOW_TRIGGER_EVENTS,
|
|
ATTENDEE_WORKFLOW_TEMPLATES,
|
|
} from "./constants";
|
|
|
|
export function getWorkflowActionOptions(t: TFunction, isTeamsPlan?: boolean, isOrgsPlan?: boolean) {
|
|
return WORKFLOW_ACTIONS.filter((action) => action !== WorkflowActions.EMAIL_ADDRESS) //removing EMAIL_ADDRESS for now due to abuse episode
|
|
.map((action) => {
|
|
const actionString = t(`${action.toLowerCase()}_action`);
|
|
|
|
return {
|
|
label: actionString.charAt(0).toUpperCase() + actionString.slice(1),
|
|
value: action,
|
|
needsTeamsUpgrade: isSMSOrWhatsappAction(action) && !isTeamsPlan,
|
|
};
|
|
});
|
|
}
|
|
|
|
export function getWorkflowTriggerOptions(t: TFunction) {
|
|
return WORKFLOW_TRIGGER_EVENTS.map((triggerEvent) => {
|
|
const triggerString = t(`${triggerEvent.toLowerCase()}_trigger`);
|
|
|
|
return { label: triggerString.charAt(0).toUpperCase() + triggerString.slice(1), value: triggerEvent };
|
|
});
|
|
}
|
|
|
|
export function getWorkflowTimeUnitOptions(t: TFunction) {
|
|
return TIME_UNIT.map((timeUnit) => {
|
|
return { label: t(`${timeUnit.toLowerCase()}_timeUnit`), value: timeUnit };
|
|
});
|
|
}
|
|
|
|
export function getWorkflowTemplateOptions(t: TFunction, action: WorkflowActions | undefined) {
|
|
const TEMPLATES =
|
|
action && isWhatsappAction(action)
|
|
? WHATSAPP_WORKFLOW_TEMPLATES
|
|
: action && isEmailToAttendeeAction(action)
|
|
? ATTENDEE_WORKFLOW_TEMPLATES
|
|
: BASIC_WORKFLOW_TEMPLATES;
|
|
return TEMPLATES.map((template) => {
|
|
return { label: t(`${template.toLowerCase()}`), value: template };
|
|
}) as { label: string; value: any }[];
|
|
}
|