"use client"; import React from "react"; import { Controller, useForm } from "react-hook-form"; // icons import { XCircle, CircleAlert } from "lucide-react"; // ui import { Button, Input, Spinner } from "@plane/ui"; // helpers import { checkEmailValidity } from "@/helpers/string.helper"; // types import { IEmailCheckData } from "@/types/auth"; type Props = { onSubmit: (data: IEmailCheckData) => Promise; }; type TEmailFormValues = { email: string; }; export const EmailForm: React.FC = (props) => { const { onSubmit } = props; const { control, formState: { errors, isSubmitting, isValid }, handleSubmit, } = useForm({ defaultValues: { email: "", }, mode: "onChange", reValidateMode: "onChange", }); const handleFormSubmit = async (data: TEmailFormValues) => { const payload: IEmailCheckData = { email: data.email, }; onSubmit(payload); }; return (
checkEmailValidity(value) || "Email is invalid", }} render={({ field: { value, onChange, ref } }) => ( <>
{value.length > 0 && ( onChange("")} /> )}
{errors.email && (

{errors.email.message}

)} )} />
); };