import { ReactElement } from "react"; import Image from "next/image"; import Link from "next/link"; import { useRouter } from "next/router"; import { useTheme } from "next-themes"; import { Controller, useForm } from "react-hook-form"; // icons import { CircleCheck } from "lucide-react"; // ui import { Button, Input, TOAST_TYPE, getButtonStyling, setToast } from "@plane/ui"; // components import { PageHead } from "@/components/core"; // constants import { FORGOT_PASS_LINK, NAVIGATE_TO_SIGNUP } from "@/constants/event-tracker"; // helpers import { EPageTypes } from "@/helpers/authentication.helper"; import { cn } from "@/helpers/common.helper"; import { checkEmailValidity } from "@/helpers/string.helper"; // hooks import { useEventTracker } from "@/hooks/store"; import useTimer from "@/hooks/use-timer"; // layouts import DefaultLayout from "@/layouts/default-layout"; // lib import { NextPageWithLayout } from "@/lib/types"; // wrappers import { AuthenticationWrapper } from "@/lib/wrappers"; // services import { AuthService } from "@/services/auth.service"; // images import PlaneBackgroundPatternDark from "public/auth/background-pattern-dark.svg"; import PlaneBackgroundPattern from "public/auth/background-pattern.svg"; import BluePlaneLogoWithoutText from "public/plane-logos/blue-without-text.png"; type TForgotPasswordFormValues = { email: string; }; const defaultValues: TForgotPasswordFormValues = { email: "", }; // services const authService = new AuthService(); const ForgotPasswordPage: NextPageWithLayout = () => { // router const router = useRouter(); const { email } = router.query; // store hooks const { captureEvent } = useEventTracker(); // hooks const { resolvedTheme } = useTheme(); // timer const { timer: resendTimerCode, setTimer: setResendCodeTimer } = useTimer(0); // form info const { control, formState: { errors, isSubmitting, isValid }, handleSubmit, } = useForm({ defaultValues: { ...defaultValues, email: email?.toString() ?? "", }, }); const handleForgotPassword = async (formData: TForgotPasswordFormValues) => { await authService .sendResetPasswordLink({ email: formData.email, }) .then(() => { captureEvent(FORGOT_PASS_LINK, { state: "SUCCESS", }); setToast({ type: TOAST_TYPE.SUCCESS, title: "Email sent", message: "Check your inbox for a link to reset your password. If it doesn't appear within a few minutes, check your spam folder.", }); setResendCodeTimer(30); }) .catch((err) => { captureEvent(FORGOT_PASS_LINK, { state: "FAILED", }); setToast({ type: TOAST_TYPE.ERROR, title: "Error!", message: err?.error ?? "Something went wrong. Please try again.", }); }); }; return (
Plane background pattern
Plane Logo Plane
New to Plane?{" "} captureEvent(NAVIGATE_TO_SIGNUP, {})} className="font-semibold text-custom-primary-100 hover:underline" > Create an account

Reset your password

Enter your user account{"'"}s verified email address and we will send you a password reset link.

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

We sent the reset link to your email address

)}
Back to sign in
); }; ForgotPasswordPage.getLayout = function getLayout(page: ReactElement) { return ( {page} ); }; export default ForgotPasswordPage;