import React from "react"; import { Controller, useForm } from "react-hook-form"; // 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 = { email: string; updateEmail: (email: string) => void; }; const authService = new AuthService(); export const SetPasswordLink: React.FC = (props) => { const { email, updateEmail } = props; const { setToastAlert } = useToast(); const { control, formState: { errors, isSubmitting, isValid }, handleSubmit, } = useForm({ defaultValues: { email, }, mode: "onChange", reValidateMode: "onChange", }); const handleSendNewLink = async (formData: { email: string }) => { updateEmail(formData.email); const payload: IEmailCheckData = { email: formData.email, }; await authService .sendResetPasswordLink(payload) .then(() => setToastAlert({ type: "success", title: "Success!", message: "We have sent a new link to your email.", }) ) .catch((err) => setToastAlert({ type: "error", title: "Error!", message: err?.error ?? "Something went wrong. Please try again.", }) ); }; return ( <>

Get on your flight deck

We have sent a link to {email}, so you can set a password

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