2023-02-27 07:24:43 +00:00
|
|
|
import type { WorkflowStep } from "@prisma/client";
|
|
|
|
import { TimeUnit, WorkflowActions, WorkflowTemplates, WorkflowTriggerEvents } from "@prisma/client";
|
|
|
|
import type { Dispatch, SetStateAction } from "react";
|
|
|
|
import { useRef, useState, useEffect } from "react";
|
|
|
|
import type { UseFormReturn } from "react-hook-form";
|
|
|
|
import { Controller } from "react-hook-form";
|
2022-07-30 15:49:01 +00:00
|
|
|
import "react-phone-number-input/style.css";
|
2022-07-14 00:10:45 +00:00
|
|
|
|
2022-12-15 21:54:40 +00:00
|
|
|
import { classNames } from "@calcom/lib";
|
2022-12-12 11:00:15 +00:00
|
|
|
import { SENDER_ID } from "@calcom/lib/constants";
|
2023-01-18 14:32:39 +00:00
|
|
|
import { SENDER_NAME } from "@calcom/lib/constants";
|
2022-07-20 19:48:40 +00:00
|
|
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
2022-08-26 01:04:44 +00:00
|
|
|
import { HttpError } from "@calcom/lib/http-error";
|
2023-01-23 23:08:01 +00:00
|
|
|
import { trpc } from "@calcom/trpc/react";
|
2022-11-23 02:55:25 +00:00
|
|
|
import {
|
2022-12-15 21:54:40 +00:00
|
|
|
Badge,
|
2022-11-23 02:55:25 +00:00
|
|
|
Button,
|
|
|
|
Checkbox,
|
|
|
|
Dialog,
|
|
|
|
DialogClose,
|
|
|
|
DialogContent,
|
|
|
|
Dropdown,
|
|
|
|
DropdownMenuContent,
|
|
|
|
DropdownMenuItem,
|
2023-01-15 11:40:40 +00:00
|
|
|
DropdownItem,
|
2022-11-23 02:55:25 +00:00
|
|
|
DropdownMenuTrigger,
|
|
|
|
EmailField,
|
|
|
|
Label,
|
|
|
|
PhoneInput,
|
|
|
|
Select,
|
|
|
|
showToast,
|
|
|
|
TextArea,
|
|
|
|
TextField,
|
2023-01-09 14:15:11 +00:00
|
|
|
Editor,
|
|
|
|
AddVariablesDropdown,
|
2023-01-18 14:32:39 +00:00
|
|
|
Input,
|
2022-11-23 02:55:25 +00:00
|
|
|
} from "@calcom/ui";
|
2023-04-12 15:26:31 +00:00
|
|
|
import { ArrowDown, MoreHorizontal, Trash2, HelpCircle } from "@calcom/ui/components/icon";
|
2022-07-28 19:58:26 +00:00
|
|
|
|
2023-01-10 02:22:17 +00:00
|
|
|
import { DYNAMIC_TEXT_VARIABLES } from "../lib/constants";
|
2022-12-15 21:54:40 +00:00
|
|
|
import { getWorkflowTemplateOptions, getWorkflowTriggerOptions } from "../lib/getOptions";
|
2023-01-18 14:32:39 +00:00
|
|
|
import { isSMSAction } from "../lib/isSMSAction";
|
2022-07-28 19:58:26 +00:00
|
|
|
import type { FormValues } from "../pages/workflow";
|
2022-11-23 02:55:25 +00:00
|
|
|
import { TimeTimeUnitInput } from "./TimeTimeUnitInput";
|
2022-07-14 00:10:45 +00:00
|
|
|
|
|
|
|
type WorkflowStepProps = {
|
|
|
|
step?: WorkflowStep;
|
2022-07-20 19:48:40 +00:00
|
|
|
form: UseFormReturn<FormValues>;
|
2022-07-14 00:10:45 +00:00
|
|
|
reload?: boolean;
|
|
|
|
setReload?: Dispatch<SetStateAction<boolean>>;
|
2023-02-27 07:24:43 +00:00
|
|
|
teamId?: number;
|
2022-07-14 00:10:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export default function WorkflowStepContainer(props: WorkflowStepProps) {
|
2023-02-27 07:24:43 +00:00
|
|
|
const { t } = useLocale();
|
2022-12-15 21:54:40 +00:00
|
|
|
const utils = trpc.useContext();
|
2023-01-11 18:41:45 +00:00
|
|
|
|
2023-02-27 07:24:43 +00:00
|
|
|
const { step, form, reload, setReload, teamId } = props;
|
|
|
|
const { data: _verifiedNumbers } = trpc.viewer.workflows.getVerifiedNumbers.useQuery(
|
|
|
|
{ teamId },
|
|
|
|
{ enabled: !!teamId }
|
|
|
|
);
|
|
|
|
const verifiedNumbers = _verifiedNumbers?.map((number) => number.phoneNumber) || [];
|
2022-11-23 02:55:25 +00:00
|
|
|
const [isAdditionalInputsDialogOpen, setIsAdditionalInputsDialogOpen] = useState(false);
|
2022-08-03 22:22:38 +00:00
|
|
|
|
2022-12-15 21:54:40 +00:00
|
|
|
const [verificationCode, setVerificationCode] = useState("");
|
|
|
|
|
2022-11-23 02:55:25 +00:00
|
|
|
const [isPhoneNumberNeeded, setIsPhoneNumberNeeded] = useState(
|
|
|
|
step?.action === WorkflowActions.SMS_NUMBER ? true : false
|
2022-08-03 22:22:38 +00:00
|
|
|
);
|
2022-07-14 00:10:45 +00:00
|
|
|
|
2022-11-23 02:55:25 +00:00
|
|
|
const [isSenderIdNeeded, setIsSenderIdNeeded] = useState(
|
|
|
|
step?.action === WorkflowActions.SMS_NUMBER || step?.action === WorkflowActions.SMS_ATTENDEE
|
|
|
|
? true
|
|
|
|
: false
|
2022-08-03 22:22:38 +00:00
|
|
|
);
|
2022-11-23 02:55:25 +00:00
|
|
|
|
2023-02-27 07:24:43 +00:00
|
|
|
useEffect(() => {
|
|
|
|
setNumberVerified(
|
|
|
|
!!step &&
|
|
|
|
!!verifiedNumbers.find((number) => number === form.getValues(`steps.${step.stepNumber - 1}.sendTo`))
|
|
|
|
);
|
|
|
|
}, [verifiedNumbers.length]);
|
|
|
|
|
2022-11-23 02:55:25 +00:00
|
|
|
const [isEmailAddressNeeded, setIsEmailAddressNeeded] = useState(
|
|
|
|
step?.action === WorkflowActions.EMAIL_ADDRESS ? true : false
|
2022-07-14 00:10:45 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
const [isCustomReminderBodyNeeded, setIsCustomReminderBodyNeeded] = useState(
|
|
|
|
step?.template === WorkflowTemplates.CUSTOM ? true : false
|
|
|
|
);
|
|
|
|
|
|
|
|
const [isEmailSubjectNeeded, setIsEmailSubjectNeeded] = useState(
|
2022-11-23 02:55:25 +00:00
|
|
|
step?.action === WorkflowActions.EMAIL_ATTENDEE ||
|
|
|
|
step?.action === WorkflowActions.EMAIL_HOST ||
|
|
|
|
step?.action === WorkflowActions.EMAIL_ADDRESS
|
2022-07-14 00:10:45 +00:00
|
|
|
? true
|
|
|
|
: false
|
|
|
|
);
|
|
|
|
|
|
|
|
const [showTimeSection, setShowTimeSection] = useState(
|
2022-11-23 02:55:25 +00:00
|
|
|
form.getValues("trigger") === WorkflowTriggerEvents.BEFORE_EVENT ||
|
|
|
|
form.getValues("trigger") === WorkflowTriggerEvents.AFTER_EVENT
|
|
|
|
);
|
|
|
|
|
|
|
|
const [showTimeSectionAfter, setShowTimeSectionAfter] = useState(
|
|
|
|
form.getValues("trigger") === WorkflowTriggerEvents.AFTER_EVENT
|
2022-07-14 00:10:45 +00:00
|
|
|
);
|
2022-12-15 00:11:57 +00:00
|
|
|
const { data: actionOptions } = trpc.viewer.workflows.getWorkflowActionOptions.useQuery();
|
2022-07-14 00:10:45 +00:00
|
|
|
const triggerOptions = getWorkflowTriggerOptions(t);
|
|
|
|
const templateOptions = getWorkflowTemplateOptions(t);
|
|
|
|
|
2022-11-23 02:55:25 +00:00
|
|
|
const { ref: emailSubjectFormRef, ...restEmailSubjectForm } = step
|
|
|
|
? form.register(`steps.${step.stepNumber - 1}.emailSubject`)
|
|
|
|
: { ref: null, name: "" };
|
2022-08-03 22:22:38 +00:00
|
|
|
|
2022-11-23 02:55:25 +00:00
|
|
|
const { ref: reminderBodyFormRef, ...restReminderBodyForm } = step
|
|
|
|
? form.register(`steps.${step.stepNumber - 1}.reminderBody`)
|
|
|
|
: { ref: null, name: "" };
|
2022-08-03 22:22:38 +00:00
|
|
|
|
|
|
|
const refEmailSubject = useRef<HTMLTextAreaElement | null>(null);
|
|
|
|
|
|
|
|
const refReminderBody = useRef<HTMLTextAreaElement | null>(null);
|
|
|
|
|
2022-12-15 21:54:40 +00:00
|
|
|
const [numberVerified, setNumberVerified] = useState(
|
2023-02-27 07:24:43 +00:00
|
|
|
step &&
|
|
|
|
!!verifiedNumbers.find((number) => number === form.getValues(`steps.${step.stepNumber - 1}.sendTo`))
|
2022-12-15 21:54:40 +00:00
|
|
|
);
|
|
|
|
|
2023-01-09 14:15:11 +00:00
|
|
|
const addVariableBody = (variable: string) => {
|
2022-08-03 22:22:38 +00:00
|
|
|
if (step) {
|
2023-01-09 14:15:11 +00:00
|
|
|
const currentMessageBody = refReminderBody?.current?.value || "";
|
|
|
|
const cursorPosition = refReminderBody?.current?.selectionStart || currentMessageBody.length;
|
|
|
|
const messageWithAddedVariable = `${currentMessageBody.substring(0, cursorPosition)}{${variable
|
|
|
|
.toUpperCase()
|
|
|
|
.replace(/ /g, "_")}}${currentMessageBody.substring(cursorPosition)}`;
|
|
|
|
form.setValue(`steps.${step.stepNumber - 1}.reminderBody`, messageWithAddedVariable);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
const addVariableEmailSubject = (variable: string) => {
|
|
|
|
if (step) {
|
|
|
|
const currentEmailSubject = refEmailSubject?.current?.value || "";
|
|
|
|
const cursorPosition = refEmailSubject?.current?.selectionStart || currentEmailSubject.length;
|
|
|
|
const subjectWithAddedVariable = `${currentEmailSubject.substring(0, cursorPosition)}{${variable
|
|
|
|
.toUpperCase()
|
|
|
|
.replace(/ /g, "_")}}${currentEmailSubject.substring(cursorPosition)}`;
|
|
|
|
form.setValue(`steps.${step.stepNumber - 1}.emailSubject`, subjectWithAddedVariable);
|
2022-08-03 22:22:38 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-12-15 21:54:40 +00:00
|
|
|
const sendVerificationCodeMutation = trpc.viewer.workflows.sendVerificationCode.useMutation({
|
|
|
|
onSuccess: async () => {
|
|
|
|
showToast(t("verification_code_sent"), "success");
|
|
|
|
},
|
|
|
|
onError: async (error) => {
|
|
|
|
showToast(error.message, "error");
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
const verifyPhoneNumberMutation = trpc.viewer.workflows.verifyPhoneNumber.useMutation({
|
|
|
|
onSuccess: async (isVerified) => {
|
|
|
|
showToast(isVerified ? t("verified_successfully") : t("wrong_code"), "success");
|
|
|
|
setNumberVerified(isVerified);
|
|
|
|
utils.viewer.workflows.getVerifiedNumbers.invalidate();
|
|
|
|
},
|
|
|
|
onError: (err) => {
|
|
|
|
if (err instanceof HttpError) {
|
|
|
|
const message = `${err.statusCode}: ${err.message}`;
|
|
|
|
showToast(message, "error");
|
|
|
|
setNumberVerified(false);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2023-01-12 16:03:30 +00:00
|
|
|
/* const testActionMutation = trpc.viewer.workflows.testAction.useMutation({
|
2022-08-26 01:04:44 +00:00
|
|
|
onSuccess: async () => {
|
|
|
|
showToast(t("notification_sent"), "success");
|
|
|
|
},
|
|
|
|
onError: (err) => {
|
2022-12-13 21:34:21 +00:00
|
|
|
let message = t("unexpected_error_try_again");
|
|
|
|
if (err instanceof TRPCClientError) {
|
|
|
|
if (err.message === "rate-limit-exceeded") {
|
|
|
|
message = t("rate_limit_exceeded");
|
2022-12-15 21:54:40 +00:00
|
|
|
} else {
|
|
|
|
message = err.message;
|
2022-12-13 21:34:21 +00:00
|
|
|
}
|
|
|
|
}
|
2022-08-26 01:04:44 +00:00
|
|
|
if (err instanceof HttpError) {
|
2022-12-13 21:34:21 +00:00
|
|
|
message = `${err.statusCode}: ${err.message}`;
|
2022-08-26 01:04:44 +00:00
|
|
|
}
|
2022-12-13 21:34:21 +00:00
|
|
|
showToast(message, "error");
|
2022-08-26 01:04:44 +00:00
|
|
|
},
|
2023-01-12 16:03:30 +00:00
|
|
|
}); */
|
2022-08-26 01:04:44 +00:00
|
|
|
|
2022-07-14 00:10:45 +00:00
|
|
|
//trigger
|
|
|
|
if (!step) {
|
|
|
|
const trigger = form.getValues("trigger");
|
2022-11-23 02:55:25 +00:00
|
|
|
const triggerString = t(`${trigger.toLowerCase()}_trigger`);
|
2022-07-14 00:10:45 +00:00
|
|
|
|
2022-11-23 02:55:25 +00:00
|
|
|
const selectedTrigger = {
|
|
|
|
label: triggerString.charAt(0).toUpperCase() + triggerString.slice(1),
|
|
|
|
value: trigger,
|
|
|
|
};
|
2022-07-14 00:10:45 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<div className="flex justify-center">
|
2023-04-05 18:14:46 +00:00
|
|
|
<div className="min-w-80 bg-default border-subtle w-full rounded-md border p-7">
|
2022-11-23 02:55:25 +00:00
|
|
|
<div className="flex">
|
2023-04-05 18:14:46 +00:00
|
|
|
<div className="bg-subtle text-default mt-[3px] flex h-5 w-5 items-center justify-center rounded-full p-1 text-xs font-medium ltr:mr-5 rtl:ml-5">
|
2022-11-23 02:55:25 +00:00
|
|
|
1
|
|
|
|
</div>
|
|
|
|
<div>
|
2023-04-05 18:14:46 +00:00
|
|
|
<div className="text-emphasis text-base font-bold">{t("trigger")}</div>
|
|
|
|
<div className="text-default text-sm">{t("when_something_happens")}</div>
|
2022-11-23 02:55:25 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2023-04-05 18:14:46 +00:00
|
|
|
<div className="border-subtle my-7 border-t" />
|
2022-11-23 02:55:25 +00:00
|
|
|
<Label>{t("when")}</Label>
|
2022-07-14 00:10:45 +00:00
|
|
|
<Controller
|
|
|
|
name="trigger"
|
|
|
|
control={form.control}
|
|
|
|
render={() => {
|
|
|
|
return (
|
|
|
|
<Select
|
|
|
|
isSearchable={false}
|
2022-11-23 02:55:25 +00:00
|
|
|
className="text-sm"
|
2022-07-14 00:10:45 +00:00
|
|
|
onChange={(val) => {
|
|
|
|
if (val) {
|
|
|
|
form.setValue("trigger", val.value);
|
2022-11-23 02:55:25 +00:00
|
|
|
if (
|
|
|
|
val.value === WorkflowTriggerEvents.BEFORE_EVENT ||
|
|
|
|
val.value === WorkflowTriggerEvents.AFTER_EVENT
|
|
|
|
) {
|
2022-07-14 00:10:45 +00:00
|
|
|
setShowTimeSection(true);
|
2022-11-23 02:55:25 +00:00
|
|
|
if (val.value === WorkflowTriggerEvents.AFTER_EVENT) {
|
|
|
|
setShowTimeSectionAfter(true);
|
|
|
|
} else {
|
|
|
|
setShowTimeSectionAfter(false);
|
|
|
|
}
|
2022-07-14 00:10:45 +00:00
|
|
|
form.setValue("time", 24);
|
|
|
|
form.setValue("timeUnit", TimeUnit.HOUR);
|
|
|
|
} else {
|
|
|
|
setShowTimeSection(false);
|
2022-11-23 02:55:25 +00:00
|
|
|
setShowTimeSectionAfter(false);
|
2022-07-14 00:10:45 +00:00
|
|
|
form.unregister("time");
|
|
|
|
form.unregister("timeUnit");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
defaultValue={selectedTrigger}
|
|
|
|
options={triggerOptions}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
{showTimeSection && (
|
2022-11-23 02:55:25 +00:00
|
|
|
<div className="mt-5">
|
|
|
|
<Label>{showTimeSectionAfter ? t("how_long_after") : t("how_long_before")}</Label>
|
|
|
|
<TimeTimeUnitInput form={form} />
|
2022-07-14 00:10:45 +00:00
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (step && step.action) {
|
2022-11-23 02:55:25 +00:00
|
|
|
const actionString = t(`${step.action.toLowerCase()}_action`);
|
|
|
|
|
|
|
|
const selectedAction = {
|
|
|
|
label: actionString.charAt(0).toUpperCase() + actionString.slice(1),
|
|
|
|
value: step.action,
|
2023-01-11 18:41:45 +00:00
|
|
|
needsUpgrade: false,
|
2022-11-23 02:55:25 +00:00
|
|
|
};
|
|
|
|
|
2022-07-14 00:10:45 +00:00
|
|
|
const selectedTemplate = { label: t(`${step.template.toLowerCase()}`), value: step.template };
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
2022-11-23 02:55:25 +00:00
|
|
|
<div className="my-3 flex justify-center">
|
2023-04-12 15:26:31 +00:00
|
|
|
<ArrowDown className="text-subtle stroke-[1.5px] text-3xl" />
|
2022-07-14 00:10:45 +00:00
|
|
|
</div>
|
|
|
|
<div className="flex justify-center">
|
2023-04-05 18:14:46 +00:00
|
|
|
<div className="min-w-80 bg-default border-subtle flex w-full rounded-md border p-7">
|
2022-11-23 02:55:25 +00:00
|
|
|
<div className="w-full">
|
|
|
|
<div className="flex">
|
|
|
|
<div className="w-full">
|
|
|
|
<div className="flex">
|
2023-04-05 18:14:46 +00:00
|
|
|
<div className="bg-subtle text-default mt-[3px] flex h-5 w-5 items-center justify-center rounded-full p-1 text-xs ltr:mr-5 rtl:ml-5">
|
2022-11-23 02:55:25 +00:00
|
|
|
{step.stepNumber + 1}
|
|
|
|
</div>
|
|
|
|
<div>
|
2023-04-05 18:14:46 +00:00
|
|
|
<div className="text-emphasis text-base font-bold">{t("action")}</div>
|
|
|
|
<div className="text-default text-sm">{t("action_is_performed")}</div>
|
2022-11-23 02:55:25 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<Dropdown>
|
|
|
|
<DropdownMenuTrigger asChild>
|
2023-04-12 15:26:31 +00:00
|
|
|
<Button type="button" color="minimal" variant="icon" StartIcon={MoreHorizontal} />
|
2022-11-23 02:55:25 +00:00
|
|
|
</DropdownMenuTrigger>
|
|
|
|
<DropdownMenuContent>
|
|
|
|
<DropdownMenuItem>
|
2023-01-15 11:40:40 +00:00
|
|
|
<DropdownItem
|
|
|
|
type="button"
|
2023-04-12 15:26:31 +00:00
|
|
|
StartIcon={Trash2}
|
2023-01-15 11:40:40 +00:00
|
|
|
color="destructive"
|
2022-11-23 02:55:25 +00:00
|
|
|
onClick={() => {
|
|
|
|
const steps = form.getValues("steps");
|
|
|
|
const updatedSteps = steps
|
|
|
|
?.filter((currStep) => currStep.id !== step.id)
|
|
|
|
.map((s) => {
|
|
|
|
const updatedStep = s;
|
|
|
|
if (step.stepNumber < updatedStep.stepNumber) {
|
|
|
|
updatedStep.stepNumber = updatedStep.stepNumber - 1;
|
|
|
|
}
|
|
|
|
return updatedStep;
|
|
|
|
});
|
|
|
|
form.setValue("steps", updatedSteps);
|
|
|
|
if (setReload) {
|
|
|
|
setReload(!reload);
|
|
|
|
}
|
2023-01-15 11:40:40 +00:00
|
|
|
}}>
|
2022-11-23 02:55:25 +00:00
|
|
|
{t("delete")}
|
2023-01-15 11:40:40 +00:00
|
|
|
</DropdownItem>
|
2022-11-23 02:55:25 +00:00
|
|
|
</DropdownMenuItem>
|
|
|
|
</DropdownMenuContent>
|
|
|
|
</Dropdown>
|
|
|
|
</div>
|
|
|
|
</div>
|
2023-04-05 18:14:46 +00:00
|
|
|
<div className="border-subtle my-7 border-t" />
|
2022-07-14 00:10:45 +00:00
|
|
|
<div>
|
2022-11-23 02:55:25 +00:00
|
|
|
<Label>{t("do_this")}</Label>
|
2022-07-14 00:10:45 +00:00
|
|
|
<Controller
|
|
|
|
name={`steps.${step.stepNumber - 1}.action`}
|
|
|
|
control={form.control}
|
|
|
|
render={() => {
|
|
|
|
return (
|
|
|
|
<Select
|
|
|
|
isSearchable={false}
|
2022-11-23 02:55:25 +00:00
|
|
|
className="text-sm"
|
2022-07-14 00:10:45 +00:00
|
|
|
onChange={(val) => {
|
|
|
|
if (val) {
|
2022-11-25 14:34:55 +00:00
|
|
|
const oldValue = form.getValues(`steps.${step.stepNumber - 1}.action`);
|
2023-01-18 14:32:39 +00:00
|
|
|
|
|
|
|
if (isSMSAction(val.value)) {
|
2022-11-23 02:55:25 +00:00
|
|
|
setIsSenderIdNeeded(true);
|
|
|
|
setIsEmailAddressNeeded(false);
|
2022-11-25 14:34:55 +00:00
|
|
|
setIsPhoneNumberNeeded(val.value === WorkflowActions.SMS_NUMBER);
|
2022-12-15 21:54:40 +00:00
|
|
|
setNumberVerified(false);
|
2023-01-18 14:32:39 +00:00
|
|
|
if (!isSMSAction(oldValue)) {
|
2022-11-25 14:34:55 +00:00
|
|
|
form.setValue(`steps.${step.stepNumber - 1}.reminderBody`, "");
|
2023-01-18 14:32:39 +00:00
|
|
|
form.setValue(`steps.${step.stepNumber - 1}.sender`, SENDER_ID);
|
2022-11-25 14:34:55 +00:00
|
|
|
}
|
2022-07-14 00:10:45 +00:00
|
|
|
} else {
|
|
|
|
setIsPhoneNumberNeeded(false);
|
2022-11-23 02:55:25 +00:00
|
|
|
setIsSenderIdNeeded(false);
|
2022-11-25 14:34:55 +00:00
|
|
|
setIsEmailAddressNeeded(val.value === WorkflowActions.EMAIL_ADDRESS);
|
|
|
|
|
2023-01-18 14:32:39 +00:00
|
|
|
if (isSMSAction(oldValue)) {
|
2022-11-25 14:34:55 +00:00
|
|
|
form.setValue(`steps.${step.stepNumber - 1}.reminderBody`, "");
|
2023-01-18 14:32:39 +00:00
|
|
|
form.setValue(`steps.${step.stepNumber - 1}.senderName`, SENDER_NAME);
|
2022-11-25 14:34:55 +00:00
|
|
|
}
|
2022-07-14 00:10:45 +00:00
|
|
|
}
|
2022-11-25 14:34:55 +00:00
|
|
|
|
2022-11-23 02:55:25 +00:00
|
|
|
form.unregister(`steps.${step.stepNumber - 1}.sendTo`);
|
|
|
|
form.clearErrors(`steps.${step.stepNumber - 1}.sendTo`);
|
2022-07-14 00:10:45 +00:00
|
|
|
if (
|
|
|
|
val.value === WorkflowActions.EMAIL_ATTENDEE ||
|
2022-11-23 02:55:25 +00:00
|
|
|
val.value === WorkflowActions.EMAIL_HOST ||
|
|
|
|
val.value === WorkflowActions.EMAIL_ADDRESS
|
2022-07-14 00:10:45 +00:00
|
|
|
) {
|
|
|
|
setIsEmailSubjectNeeded(true);
|
|
|
|
} else {
|
|
|
|
setIsEmailSubjectNeeded(false);
|
|
|
|
}
|
|
|
|
form.setValue(`steps.${step.stepNumber - 1}.action`, val.value);
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
defaultValue={selectedAction}
|
2022-11-23 22:42:42 +00:00
|
|
|
options={actionOptions}
|
2022-12-15 00:11:57 +00:00
|
|
|
isOptionDisabled={(option: {
|
|
|
|
label: string;
|
|
|
|
value: WorkflowActions;
|
2023-01-11 18:41:45 +00:00
|
|
|
needsUpgrade: boolean;
|
|
|
|
}) => option.needsUpgrade}
|
2022-07-14 00:10:45 +00:00
|
|
|
/>
|
|
|
|
);
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</div>
|
2023-02-20 17:40:08 +00:00
|
|
|
{isPhoneNumberNeeded && (
|
2023-04-05 18:14:46 +00:00
|
|
|
<div className="bg-muted mt-2 rounded-md p-4 pt-0">
|
2023-02-20 17:40:08 +00:00
|
|
|
<Label className="pt-4">{t("custom_phone_number")}</Label>
|
|
|
|
<div className="block sm:flex">
|
2023-03-02 18:15:28 +00:00
|
|
|
<Controller
|
2023-02-20 17:40:08 +00:00
|
|
|
name={`steps.${step.stepNumber - 1}.sendTo`}
|
2023-03-02 18:15:28 +00:00
|
|
|
render={({ field: { value, onChange } }) => (
|
|
|
|
<PhoneInput
|
|
|
|
placeholder={t("phone_number")}
|
|
|
|
id={`steps.${step.stepNumber - 1}.sendTo`}
|
|
|
|
className="min-w-fit sm:rounded-tl-md sm:rounded-bl-md sm:border-r-transparent"
|
|
|
|
required
|
|
|
|
value={value}
|
|
|
|
onChange={(val) => {
|
|
|
|
const isAlreadyVerified = !!verifiedNumbers
|
|
|
|
?.concat([])
|
2023-04-03 09:25:20 +00:00
|
|
|
.find((number) => number.replace(/\s/g, "") === val?.replace(/\s/g, ""));
|
2023-03-02 18:15:28 +00:00
|
|
|
setNumberVerified(isAlreadyVerified);
|
|
|
|
onChange(val);
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
)}
|
2023-02-20 17:40:08 +00:00
|
|
|
/>
|
|
|
|
<Button
|
|
|
|
color="secondary"
|
|
|
|
disabled={numberVerified || false}
|
|
|
|
className={classNames(
|
|
|
|
"-ml-[3px] h-[40px] min-w-fit sm:block sm:rounded-tl-none sm:rounded-bl-none ",
|
|
|
|
numberVerified ? "hidden" : "mt-3 sm:mt-0"
|
|
|
|
)}
|
|
|
|
onClick={() =>
|
|
|
|
sendVerificationCodeMutation.mutate({
|
|
|
|
phoneNumber: form.getValues(`steps.${step.stepNumber - 1}.sendTo`) || "",
|
|
|
|
})
|
|
|
|
}>
|
|
|
|
{t("send_code")}
|
|
|
|
</Button>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
{form.formState.errors.steps &&
|
|
|
|
form.formState?.errors?.steps[step.stepNumber - 1]?.sendTo && (
|
|
|
|
<p className="mt-1 text-xs text-red-500">
|
|
|
|
{form.formState?.errors?.steps[step.stepNumber - 1]?.sendTo?.message || ""}
|
|
|
|
</p>
|
|
|
|
)}
|
|
|
|
{numberVerified ? (
|
|
|
|
<div className="mt-1">
|
|
|
|
<Badge variant="green">{t("number_verified")}</Badge>
|
|
|
|
</div>
|
|
|
|
) : (
|
2022-11-23 02:55:25 +00:00
|
|
|
<>
|
2023-02-20 17:40:08 +00:00
|
|
|
<div className="mt-3 flex">
|
|
|
|
<TextField
|
|
|
|
className=" border-r-transparent"
|
|
|
|
placeholder="Verification code"
|
|
|
|
value={verificationCode}
|
|
|
|
onChange={(e) => {
|
|
|
|
setVerificationCode(e.target.value);
|
2022-12-15 21:54:40 +00:00
|
|
|
}}
|
2023-02-20 17:40:08 +00:00
|
|
|
required
|
2022-12-15 21:54:40 +00:00
|
|
|
/>
|
|
|
|
<Button
|
|
|
|
color="secondary"
|
2023-02-20 17:40:08 +00:00
|
|
|
className="-ml-[3px] rounded-tl-none rounded-bl-none "
|
|
|
|
disabled={verifyPhoneNumberMutation.isLoading}
|
|
|
|
onClick={() => {
|
|
|
|
verifyPhoneNumberMutation.mutate({
|
2022-12-15 21:54:40 +00:00
|
|
|
phoneNumber: form.getValues(`steps.${step.stepNumber - 1}.sendTo`) || "",
|
2023-02-20 17:40:08 +00:00
|
|
|
code: verificationCode,
|
2023-02-27 07:24:43 +00:00
|
|
|
teamId,
|
2023-02-20 17:40:08 +00:00
|
|
|
});
|
|
|
|
}}>
|
2023-02-27 07:24:43 +00:00
|
|
|
{t("verify")}
|
2022-12-15 21:54:40 +00:00
|
|
|
</Button>
|
|
|
|
</div>
|
2023-02-27 07:24:43 +00:00
|
|
|
{form.formState.errors.steps &&
|
|
|
|
form.formState?.errors?.steps[step.stepNumber - 1]?.sendTo && (
|
|
|
|
<p className="mt-1 text-xs text-red-500">
|
|
|
|
{form.formState?.errors?.steps[step.stepNumber - 1]?.sendTo?.message || ""}
|
|
|
|
</p>
|
|
|
|
)}
|
2022-11-23 02:55:25 +00:00
|
|
|
</>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
)}
|
2023-04-05 18:14:46 +00:00
|
|
|
<div className="bg-muted-4 mt-2 rounded-md pt-0">
|
2023-01-18 14:32:39 +00:00
|
|
|
{isSenderIdNeeded ? (
|
|
|
|
<>
|
|
|
|
<div className="pt-4">
|
|
|
|
<Label>{t("sender_id")}</Label>
|
|
|
|
<Input
|
|
|
|
type="text"
|
|
|
|
placeholder={SENDER_ID}
|
|
|
|
maxLength={11}
|
|
|
|
{...form.register(`steps.${step.stepNumber - 1}.sender`)}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
{form.formState.errors.steps &&
|
|
|
|
form.formState?.errors?.steps[step.stepNumber - 1]?.sender && (
|
|
|
|
<p className="mt-1 text-xs text-red-500">{t("sender_id_error_message")}</p>
|
|
|
|
)}
|
|
|
|
</>
|
|
|
|
) : (
|
|
|
|
<>
|
|
|
|
<div className="pt-4">
|
|
|
|
<Label>{t("sender_name")}</Label>
|
|
|
|
<Input
|
|
|
|
type="text"
|
|
|
|
placeholder={SENDER_NAME}
|
|
|
|
{...form.register(`steps.${step.stepNumber - 1}.senderName`)}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</>
|
|
|
|
)}
|
|
|
|
</div>
|
2022-11-23 02:55:25 +00:00
|
|
|
{form.getValues(`steps.${step.stepNumber - 1}.action`) === WorkflowActions.SMS_ATTENDEE && (
|
|
|
|
<div className="mt-2">
|
|
|
|
<Controller
|
|
|
|
name={`steps.${step.stepNumber - 1}.numberRequired`}
|
|
|
|
control={form.control}
|
|
|
|
render={() => (
|
|
|
|
<Checkbox
|
|
|
|
defaultChecked={
|
|
|
|
form.getValues(`steps.${step.stepNumber - 1}.numberRequired`) || false
|
|
|
|
}
|
|
|
|
description={t("make_phone_number_required")}
|
|
|
|
onChange={(e) =>
|
|
|
|
form.setValue(`steps.${step.stepNumber - 1}.numberRequired`, e.target.checked)
|
|
|
|
}
|
2022-07-14 00:10:45 +00:00
|
|
|
/>
|
|
|
|
)}
|
2022-11-23 02:55:25 +00:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
{isEmailAddressNeeded && (
|
2023-04-05 18:14:46 +00:00
|
|
|
<div className="bg-muted-4 mt-5 rounded-md">
|
2022-11-23 02:55:25 +00:00
|
|
|
<EmailField
|
|
|
|
required
|
|
|
|
label={t("email_address")}
|
|
|
|
{...form.register(`steps.${step.stepNumber - 1}.sendTo`)}
|
|
|
|
/>
|
|
|
|
</div>
|
2022-07-14 00:10:45 +00:00
|
|
|
)}
|
|
|
|
<div className="mt-5">
|
2022-11-23 02:55:25 +00:00
|
|
|
<Label>{t("message_template")}</Label>
|
2022-07-14 00:10:45 +00:00
|
|
|
<Controller
|
|
|
|
name={`steps.${step.stepNumber - 1}.template`}
|
|
|
|
control={form.control}
|
|
|
|
render={() => {
|
|
|
|
return (
|
|
|
|
<Select
|
|
|
|
isSearchable={false}
|
2022-11-23 02:55:25 +00:00
|
|
|
className="text-sm"
|
2022-07-14 00:10:45 +00:00
|
|
|
onChange={(val) => {
|
|
|
|
if (val) {
|
|
|
|
form.setValue(`steps.${step.stepNumber - 1}.template`, val.value);
|
|
|
|
const isCustomTemplate = val.value === WorkflowTemplates.CUSTOM;
|
|
|
|
setIsCustomReminderBodyNeeded(isCustomTemplate);
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
defaultValue={selectedTemplate}
|
|
|
|
options={templateOptions}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
{isCustomReminderBodyNeeded && (
|
2023-04-05 18:14:46 +00:00
|
|
|
<div className="bg-muted-4 mt-2 rounded-md pt-2 md:p-6 md:pt-4">
|
2022-07-14 00:10:45 +00:00
|
|
|
{isEmailSubjectNeeded && (
|
2022-11-25 14:34:55 +00:00
|
|
|
<div className="mb-6">
|
|
|
|
<div className="flex items-center">
|
2022-11-23 02:55:25 +00:00
|
|
|
<Label className="mb-0 flex-none">{t("subject")}</Label>
|
|
|
|
<div className="flex-grow text-right">
|
2023-01-09 14:15:11 +00:00
|
|
|
<AddVariablesDropdown
|
|
|
|
addVariable={addVariableEmailSubject}
|
2023-01-10 02:22:17 +00:00
|
|
|
variables={DYNAMIC_TEXT_VARIABLES}
|
2023-01-09 14:15:11 +00:00
|
|
|
/>
|
2022-11-23 02:55:25 +00:00
|
|
|
</div>
|
2022-08-03 22:22:38 +00:00
|
|
|
</div>
|
2022-11-23 02:55:25 +00:00
|
|
|
<TextArea
|
|
|
|
ref={(e) => {
|
|
|
|
emailSubjectFormRef?.(e);
|
|
|
|
refEmailSubject.current = e;
|
|
|
|
}}
|
2022-11-25 14:34:55 +00:00
|
|
|
rows={1}
|
|
|
|
className="my-0 focus:ring-transparent"
|
2022-11-23 02:55:25 +00:00
|
|
|
required
|
|
|
|
{...restEmailSubjectForm}
|
|
|
|
/>
|
|
|
|
{form.formState.errors.steps &&
|
|
|
|
form.formState?.errors?.steps[step.stepNumber - 1]?.emailSubject && (
|
|
|
|
<p className="mt-1 text-xs text-red-500">
|
|
|
|
{form.formState?.errors?.steps[step.stepNumber - 1]?.emailSubject?.message || ""}
|
|
|
|
</p>
|
|
|
|
)}
|
2022-07-14 00:10:45 +00:00
|
|
|
</div>
|
|
|
|
)}
|
2022-11-25 14:34:55 +00:00
|
|
|
|
|
|
|
{step.action !== WorkflowActions.SMS_ATTENDEE &&
|
|
|
|
step.action !== WorkflowActions.SMS_NUMBER ? (
|
|
|
|
<>
|
|
|
|
<div className="mb-2 flex items-center pb-[1.5px]">
|
|
|
|
<Label className="mb-0 flex-none ">
|
|
|
|
{isEmailSubjectNeeded ? t("email_body") : t("text_message")}
|
|
|
|
</Label>
|
|
|
|
</div>
|
2023-01-09 14:15:11 +00:00
|
|
|
<Editor
|
|
|
|
getText={() => {
|
|
|
|
return props.form.getValues(`steps.${step.stepNumber - 1}.reminderBody`) || "";
|
|
|
|
}}
|
|
|
|
setText={(text: string) => {
|
|
|
|
props.form.setValue(`steps.${step.stepNumber - 1}.reminderBody`, text);
|
|
|
|
props.form.clearErrors();
|
|
|
|
}}
|
2023-01-10 02:22:17 +00:00
|
|
|
variables={DYNAMIC_TEXT_VARIABLES}
|
2023-01-25 01:08:10 +00:00
|
|
|
height="200px"
|
2023-01-09 14:15:11 +00:00
|
|
|
/>
|
2022-11-25 14:34:55 +00:00
|
|
|
</>
|
|
|
|
) : (
|
|
|
|
<>
|
|
|
|
<div className="flex items-center">
|
|
|
|
<Label className="mb-0 flex-none">
|
|
|
|
{isEmailSubjectNeeded ? t("email_body") : t("text_message")}
|
|
|
|
</Label>
|
|
|
|
<div className="flex-grow text-right">
|
2023-01-09 14:15:11 +00:00
|
|
|
<AddVariablesDropdown
|
|
|
|
addVariable={addVariableBody}
|
2023-01-10 02:22:17 +00:00
|
|
|
variables={DYNAMIC_TEXT_VARIABLES}
|
2023-01-09 14:15:11 +00:00
|
|
|
/>
|
2022-11-25 14:34:55 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<TextArea
|
|
|
|
ref={(e) => {
|
|
|
|
reminderBodyFormRef?.(e);
|
|
|
|
refReminderBody.current = e;
|
|
|
|
}}
|
|
|
|
className="my-0 h-24"
|
|
|
|
required
|
|
|
|
{...restReminderBodyForm}
|
|
|
|
/>
|
|
|
|
</>
|
|
|
|
)}
|
2022-11-23 02:55:25 +00:00
|
|
|
{form.formState.errors.steps &&
|
|
|
|
form.formState?.errors?.steps[step.stepNumber - 1]?.reminderBody && (
|
2022-11-25 14:34:55 +00:00
|
|
|
<p className="mt-1 text-sm text-red-500">
|
2022-11-23 02:55:25 +00:00
|
|
|
{form.formState?.errors?.steps[step.stepNumber - 1]?.reminderBody?.message || ""}
|
|
|
|
</p>
|
2022-07-14 00:10:45 +00:00
|
|
|
)}
|
2022-11-23 02:55:25 +00:00
|
|
|
<div className="mt-3 ">
|
|
|
|
<button type="button" onClick={() => setIsAdditionalInputsDialogOpen(true)}>
|
2023-04-05 18:14:46 +00:00
|
|
|
<div className="text-default mt-2 flex text-sm">
|
2023-04-12 15:26:31 +00:00
|
|
|
<HelpCircle className="mt-[3px] h-3 w-3 ltr:mr-2 rtl:ml-2" />
|
2022-11-23 02:55:25 +00:00
|
|
|
<p className="text-left">{t("using_additional_inputs_as_variables")}</p>
|
|
|
|
</div>
|
|
|
|
</button>
|
2022-08-03 22:22:38 +00:00
|
|
|
</div>
|
2022-11-23 02:55:25 +00:00
|
|
|
</div>
|
2022-07-14 00:10:45 +00:00
|
|
|
)}
|
2023-01-12 16:03:30 +00:00
|
|
|
{/* {form.getValues(`steps.${step.stepNumber - 1}.action`) !== WorkflowActions.SMS_ATTENDEE && (
|
2022-08-26 01:04:44 +00:00
|
|
|
<Button
|
|
|
|
type="button"
|
2023-01-12 16:03:30 +00:00
|
|
|
className="w-full mt-7"
|
2022-08-26 01:04:44 +00:00
|
|
|
onClick={() => {
|
2022-11-23 02:55:25 +00:00
|
|
|
let isEmpty = false;
|
2022-12-15 21:54:40 +00:00
|
|
|
|
2022-11-23 02:55:25 +00:00
|
|
|
if (!form.getValues(`steps.${step.stepNumber - 1}.sendTo`) && isPhoneNumberNeeded) {
|
|
|
|
form.setError(`steps.${step.stepNumber - 1}.sendTo`, {
|
|
|
|
type: "custom",
|
|
|
|
message: t("no_input"),
|
|
|
|
});
|
|
|
|
isEmpty = true;
|
|
|
|
}
|
2022-12-15 21:54:40 +00:00
|
|
|
|
|
|
|
if (!numberVerified && isPhoneNumberNeeded) {
|
|
|
|
form.setError(`steps.${step.stepNumber - 1}.sendTo`, {
|
|
|
|
type: "custom",
|
|
|
|
message: t("not_verified"),
|
|
|
|
});
|
|
|
|
}
|
2022-08-26 01:04:44 +00:00
|
|
|
if (
|
2022-11-23 02:55:25 +00:00
|
|
|
form.getValues(`steps.${step.stepNumber - 1}.template`) === WorkflowTemplates.CUSTOM
|
2022-08-26 01:04:44 +00:00
|
|
|
) {
|
2022-11-23 02:55:25 +00:00
|
|
|
if (!form.getValues(`steps.${step.stepNumber - 1}.reminderBody`)) {
|
|
|
|
form.setError(`steps.${step.stepNumber - 1}.reminderBody`, {
|
|
|
|
type: "custom",
|
|
|
|
message: t("no_input"),
|
|
|
|
});
|
|
|
|
isEmpty = true;
|
|
|
|
} else if (
|
|
|
|
isEmailSubjectNeeded &&
|
|
|
|
!form.getValues(`steps.${step.stepNumber - 1}.emailSubject`)
|
|
|
|
) {
|
|
|
|
form.setError(`steps.${step.stepNumber - 1}.emailSubject`, {
|
|
|
|
type: "custom",
|
|
|
|
message: t("no_input"),
|
|
|
|
});
|
|
|
|
isEmpty = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!isPhoneNumberNeeded && !isEmpty) {
|
|
|
|
//translate body and reminder to english
|
|
|
|
const emailSubject = translateVariablesToEnglish(
|
|
|
|
form.getValues(`steps.${step.stepNumber - 1}.emailSubject`) || "",
|
|
|
|
{ locale: i18n.language, t }
|
|
|
|
);
|
|
|
|
const reminderBody = translateVariablesToEnglish(
|
|
|
|
form.getValues(`steps.${step.stepNumber - 1}.reminderBody`) || "",
|
|
|
|
{ locale: i18n.language, t }
|
|
|
|
);
|
|
|
|
|
2022-08-26 01:04:44 +00:00
|
|
|
testActionMutation.mutate({
|
2022-12-15 20:48:22 +00:00
|
|
|
step,
|
2022-11-23 02:55:25 +00:00
|
|
|
emailSubject,
|
|
|
|
reminderBody,
|
2022-08-26 01:04:44 +00:00
|
|
|
});
|
|
|
|
} else {
|
2022-11-23 02:55:25 +00:00
|
|
|
const isNumberValid =
|
|
|
|
form.formState.errors.steps &&
|
|
|
|
form.formState?.errors?.steps[step.stepNumber - 1]?.sendTo
|
|
|
|
? false
|
|
|
|
: true;
|
|
|
|
|
2022-12-15 21:54:40 +00:00
|
|
|
if (isPhoneNumberNeeded && isNumberValid && !isEmpty && numberVerified) {
|
2022-11-23 02:55:25 +00:00
|
|
|
setConfirmationDialogOpen(true);
|
|
|
|
}
|
2022-08-26 01:04:44 +00:00
|
|
|
}
|
|
|
|
}}
|
|
|
|
color="secondary">
|
|
|
|
<div className="w-full">{t("test_action")}</div>
|
|
|
|
</Button>
|
2023-01-12 16:03:30 +00:00
|
|
|
)*/}
|
2022-07-14 00:10:45 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2023-01-12 16:03:30 +00:00
|
|
|
{/* <Dialog open={confirmationDialogOpen} onOpenChange={setConfirmationDialogOpen}>
|
2022-08-26 01:04:44 +00:00
|
|
|
<ConfirmationDialogContent
|
|
|
|
variety="warning"
|
|
|
|
title={t("test_workflow_action")}
|
|
|
|
confirmBtnText={t("send_sms")}
|
|
|
|
onConfirm={(e) => {
|
|
|
|
e.preventDefault();
|
2022-11-23 02:55:25 +00:00
|
|
|
const reminderBody = translateVariablesToEnglish(
|
|
|
|
form.getValues(`steps.${step.stepNumber - 1}.reminderBody`) || "",
|
|
|
|
{ locale: i18n.language, t }
|
|
|
|
);
|
|
|
|
|
2022-08-26 01:04:44 +00:00
|
|
|
testActionMutation.mutate({
|
2022-12-15 20:48:22 +00:00
|
|
|
step,
|
2022-11-23 02:55:25 +00:00
|
|
|
emailSubject: "",
|
|
|
|
reminderBody: reminderBody || "",
|
2022-08-26 01:04:44 +00:00
|
|
|
});
|
|
|
|
setConfirmationDialogOpen(false);
|
|
|
|
}}>
|
2022-11-23 02:55:25 +00:00
|
|
|
{t("send_sms_to_number", { number: form.getValues(`steps.${step.stepNumber - 1}.sendTo`) })}
|
2022-08-26 01:04:44 +00:00
|
|
|
</ConfirmationDialogContent>
|
2023-01-12 16:03:30 +00:00
|
|
|
</Dialog> */}
|
2022-11-23 02:55:25 +00:00
|
|
|
<Dialog open={isAdditionalInputsDialogOpen} onOpenChange={setIsAdditionalInputsDialogOpen}>
|
2022-11-28 19:14:38 +00:00
|
|
|
<DialogContent type="creation" className="sm:max-w-[610px] md:h-[570px]">
|
2022-11-23 02:55:25 +00:00
|
|
|
<div className="-m-3 h-[430px] overflow-x-hidden overflow-y-scroll sm:m-0">
|
|
|
|
<h1 className="w-full text-xl font-semibold ">{t("how_additional_inputs_as_variables")}</h1>
|
2023-04-05 18:14:46 +00:00
|
|
|
<div className="bg-muted-3 mb-7 mt-7 rounded-md sm:p-4">
|
2022-11-23 02:55:25 +00:00
|
|
|
<p className="test-sm font-medium">{t("format")}</p>
|
2023-04-05 18:14:46 +00:00
|
|
|
<ul className="text-emphasis mt-2 ml-5 list-disc">
|
2022-11-23 02:55:25 +00:00
|
|
|
<li>{t("uppercase_for_letters")}</li>
|
|
|
|
<li>{t("replace_whitespaces_underscores")}</li>
|
|
|
|
<li>{t("ignore_special_characters")}</li>
|
|
|
|
</ul>
|
|
|
|
<div className="mt-6">
|
|
|
|
<p className="test-sm w-full font-medium">{t("example_1")}</p>
|
|
|
|
<div className="mt-2 grid grid-cols-12">
|
2023-04-05 18:14:46 +00:00
|
|
|
<div className="test-sm text-default col-span-5 ltr:mr-2 rtl:ml-2">
|
2023-01-04 07:38:45 +00:00
|
|
|
{t("additional_input_label")}
|
|
|
|
</div>
|
2023-04-05 18:14:46 +00:00
|
|
|
<div className="test-sm text-emphasis col-span-7">{t("company_size")}</div>
|
|
|
|
<div className="test-sm text-default col-span-5 w-full">{t("variable")}</div>
|
2022-11-23 02:55:25 +00:00
|
|
|
|
2023-04-05 18:14:46 +00:00
|
|
|
<div className="test-sm text-emphasis col-span-7 break-words">
|
2022-11-23 02:55:25 +00:00
|
|
|
{" "}
|
|
|
|
{`{${t("company_size")
|
|
|
|
.replace(/[^a-zA-Z0-9 ]/g, "")
|
|
|
|
.trim()
|
|
|
|
.replace(/ /g, "_")
|
|
|
|
.toUpperCase()}}`}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div className="mt-6">
|
|
|
|
<p className="test-sm w-full font-medium">{t("example_2")}</p>
|
|
|
|
<div className="mt-2 grid grid-cols-12">
|
2023-04-05 18:14:46 +00:00
|
|
|
<div className="test-sm text-default col-span-5 ltr:mr-2 rtl:ml-2">
|
2023-01-04 07:38:45 +00:00
|
|
|
{t("additional_input_label")}
|
|
|
|
</div>
|
2023-04-05 18:14:46 +00:00
|
|
|
<div className="test-sm text-emphasis col-span-7">{t("what_help_needed")}</div>
|
|
|
|
<div className="test-sm text-default col-span-5">{t("variable")}</div>
|
|
|
|
<div className="test-sm text-emphasis col-span-7 break-words">
|
2022-11-23 02:55:25 +00:00
|
|
|
{" "}
|
|
|
|
{`{${t("what_help_needed")
|
|
|
|
.replace(/[^a-zA-Z0-9 ]/g, "")
|
|
|
|
.trim()
|
|
|
|
.replace(/ /g, "_")
|
|
|
|
.toUpperCase()}}`}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div className="flex flex-row-reverse">
|
2022-11-28 19:14:38 +00:00
|
|
|
<DialogClose color="primary" />
|
2022-11-23 02:55:25 +00:00
|
|
|
</div>
|
|
|
|
</DialogContent>
|
|
|
|
</Dialog>
|
2022-07-14 00:10:45 +00:00
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return <></>;
|
|
|
|
}
|