/** * @deprecated file * All new changes should be made to the V2 file in * `/packages/features/ee/workflows/components/v2/AddActionDialog.tsx` */ import { zodResolver } from "@hookform/resolvers/zod"; import { WorkflowActions } from "@prisma/client"; import { isValidPhoneNumber } from "libphonenumber-js"; import { Dispatch, SetStateAction, useState } from "react"; import { Controller, useForm } from "react-hook-form"; import { z } from "zod"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import Button from "@calcom/ui/Button"; import { Dialog, DialogClose, DialogContent, DialogFooter, DialogHeader } from "@calcom/ui/Dialog"; import PhoneInput from "@calcom/ui/form/PhoneInputLazy"; import Select from "@calcom/ui/form/Select"; import { Form } from "@calcom/ui/form/fields"; import { WORKFLOW_ACTIONS } from "../lib/constants"; import { getWorkflowActionOptions } from "../lib/getOptions"; interface IAddActionDialog { isOpenDialog: boolean; setIsOpenDialog: Dispatch>; addAction: (action: WorkflowActions, sendTo?: string) => void; } type AddActionFormValues = { action: WorkflowActions; sendTo?: string; }; /** * @deprecated file * All new changes should be made to the V2 file in * `/packages/features/ee/workflows/components/v2/AddActionDialog.tsx` */ export const AddActionDialog = (props: IAddActionDialog) => { const { t } = useLocale(); const { isOpenDialog, setIsOpenDialog, addAction } = props; const [isPhoneNumberNeeded, setIsPhoneNumberNeeded] = useState(false); const actionOptions = getWorkflowActionOptions(t); const formSchema = z.object({ action: z.enum(WORKFLOW_ACTIONS), sendTo: z .string() .refine((val) => isValidPhoneNumber(val)) .optional(), }); const form = useForm({ mode: "onSubmit", defaultValues: { action: WorkflowActions.EMAIL_HOST, }, resolver: zodResolver(formSchema), }); return (
{ addAction(values.action, values.sendTo); form.unregister("sendTo"); form.unregister("action"); setIsOpenDialog(false); setIsPhoneNumberNeeded(false); }}>
{ return (