import { zodResolver } from "@hookform/resolvers/zod"; import { useEffect } from "react"; import { useForm } from "react-hook-form"; import { z } from "zod"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { Dialog, DialogContent, DialogFooter, DialogClose, Button, TextField, Form, InputError, } from "@calcom/ui"; interface SecondaryEmailModalProps { isLoading: boolean; errorMessage?: string; handleAddEmail: (value: { email: string }) => void; onCancel: () => void; clearErrorMessage: () => void; } const SecondaryEmailModal = ({ isLoading, errorMessage, handleAddEmail, onCancel, clearErrorMessage, }: SecondaryEmailModalProps) => { const { t } = useLocale(); type FormValues = { email: string; }; const formMethods = useForm({ resolver: zodResolver( z.object({ email: z.string().email(), }) ), }); useEffect(() => { // We will reset the errorMessage once the user starts modifying the email const subscription = formMethods.watch(() => clearErrorMessage()); return () => subscription.unsubscribe(); }, [formMethods.watch]); return (
{errorMessage && } {t("cancel")}
); }; export default SecondaryEmailModal;