import React from "react"; import { Controller, useForm } from "react-hook-form"; import { XCircle } from "lucide-react"; import { observer } from "mobx-react-lite"; // services import { AuthService } from "services/auth.service"; // hooks import useToast from "hooks/use-toast"; // ui import { Button, Input } from "@plane/ui"; // helpers import { checkEmailValidity } from "helpers/string.helper"; // types import { IEmailCheckData } from "@plane/types"; type Props = { onSubmit: (isPasswordAutoset: boolean) => void; updateEmail: (email: string) => void; }; type TEmailFormValues = { email: string; }; const authService = new AuthService(); export const SignInEmailForm: React.FC = observer((props) => { const { onSubmit, updateEmail } = props; // hooks const { setToastAlert } = useToast(); 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, }; // update the global email state updateEmail(data.email); await authService .emailCheck(payload) .then((res) => onSubmit(res.is_password_autoset)) .catch((err) => setToastAlert({ type: "error", title: "Error!", message: err?.error ?? "Something went wrong. Please try again.", }) ); }; return ( <>

Welcome back, let{"'"}s get you on board

Get back to your issues, projects and workspaces.

checkEmailValidity(value) || "Email is invalid", }} render={({ field: { value, onChange } }) => (
{value.length > 0 && ( onChange("")} /> )}
)} />
); });