import React, { useState } from "react"; import Link from "next/link"; import { Controller, useForm } from "react-hook-form"; import { XCircle } from "lucide-react"; // 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 "types/auth"; type Props = { email: string; updateEmail: (email: string) => void; }; const authService = new AuthService(); export const SetPasswordLink: React.FC = (props) => { const { email, updateEmail } = props; // states const [isSendingNewLink, setIsSendingNewLink] = useState(false); const { setToastAlert } = useToast(); const { control, formState: { errors, isValid }, watch, } = useForm({ defaultValues: { email, }, mode: "onChange", reValidateMode: "onChange", }); const handleSendNewLink = async () => { setIsSendingNewLink(true); const payload: IEmailCheckData = { email: watch("email"), type: "password", }; await authService .emailCheck(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.", }) ) .finally(() => setIsSendingNewLink(false)); }; 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, ref } }) => (
{ updateEmail(e.target.value); onChange(e.target.value); }} ref={ref} hasError={Boolean(errors.email)} placeholder="orville.wright@firstflight.com" className="w-full h-[46px] placeholder:text-onboarding-text-400 border border-onboarding-border-100 pr-12" /> {value.length > 0 && ( onChange("")} /> )}
)} />

When you click the button above, you agree with our{" "} terms and conditions of service.

); };