Files
calendar/packages/features/ee/workflows/lib/getOptions.ts
T
Carina WollendorferGitHubCarinaWollizomarskodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
7b18272d60 SMS workflow actions only for Teams (#6003)
* disable sms actions for users without team

* add isTeamsPlan query

* disable SMS action if user is not in a team

* remove console log

* disable SMS actions also in AddActionDialog

* throw error is users wants to add sms or edit  to sms action

* code clean up

* Get actions options from backend. cleanup

* Typefix

Co-authored-by: CarinaWolli <wollencarina@gmail.com>
Co-authored-by: zomars <zomars@me.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2022-12-15 00:11:57 +00:00

39 lines
1.3 KiB
TypeScript

import { WorkflowActions } from "@prisma/client";
import { TFunction } from "next-i18next";
import { TIME_UNIT, WORKFLOW_ACTIONS, WORKFLOW_TEMPLATES, WORKFLOW_TRIGGER_EVENTS } from "./constants";
export function getWorkflowActionOptions(t: TFunction, isTeamsPlan?: boolean) {
return WORKFLOW_ACTIONS.map((action) => {
const actionString = t(`${action.toLowerCase()}_action`);
const isSMSAction = action === WorkflowActions.SMS_ATTENDEE || action === WorkflowActions.SMS_NUMBER;
return {
label: actionString.charAt(0).toUpperCase() + actionString.slice(1),
value: action,
disabled: isSMSAction && !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) {
return WORKFLOW_TEMPLATES.map((template) => {
return { label: t(`${template.toLowerCase()}`), value: template };
});
}