import React from "react"; import { observer } from "mobx-react-lite"; import { Controller, useForm } from "react-hook-form"; import { XCircle } from "lucide-react"; import { IEmailCheckData } from "@plane/types"; // services import { Button, Input, TOAST_TYPE, setToast } from "@plane/ui"; import { checkEmailValidity } from "@/helpers/string.helper"; import { AuthService } from "@/services/auth.service"; // ui // helpers // 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 { 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) => setToast({ type: TOAST_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("")} /> )}
)} />
); });