import { ReactElement, useCallback } from "react"; import Image from "next/image"; import Link from "next/link"; import { useRouter } from "next/router"; import { useTheme } from "next-themes"; import { Lightbulb } from "lucide-react"; import { Controller, useForm } from "react-hook-form"; // services import { AuthService } from "services/auth.service"; // hooks import useToast from "hooks/use-toast"; // layouts import DefaultLayout from "layouts/default-layout"; // ui import { Button, Input } from "@plane/ui"; // images import BluePlaneLogoWithoutText from "public/plane-logos/blue-without-text.png"; import latestFeatures from "public/onboarding/onboarding-pages.svg"; // helpers import { checkEmailValidity } from "helpers/string.helper"; // type import { NextPageWithLayout } from "types/app"; import { useMobxStore } from "lib/mobx/store-provider"; // types import { IUser, IUserSettings } from "types"; type TResetPasswordFormValues = { email: string; password: string; }; const defaultValues: TResetPasswordFormValues = { email: "", password: "", }; // services const authService = new AuthService(); const HomePage: NextPageWithLayout = () => { // router const router = useRouter(); const { uidb64, token, email } = router.query; // next-themes const { resolvedTheme } = useTheme(); // toast const { setToastAlert } = useToast(); // mobx store const { user: { fetchCurrentUser, fetchCurrentUserSettings }, } = useMobxStore(); // form info const { control, formState: { errors, isSubmitting, isValid }, handleSubmit, } = useForm({ defaultValues: { ...defaultValues, email: email?.toString() ?? "", }, }); const handleSignInRedirection = useCallback( async (user: IUser) => { // if the user is not onboarded, redirect them to the onboarding page if (!user.is_onboarded) { router.push("/onboarding"); return; } // if the user is onboarded, fetch their last workspace details await fetchCurrentUserSettings().then((userSettings: IUserSettings) => { const workspaceSlug = userSettings?.workspace?.last_workspace_slug || userSettings?.workspace?.fallback_workspace_slug; if (workspaceSlug) router.push(`/${workspaceSlug}`); else router.push("/profile"); }); }, [fetchCurrentUserSettings, router] ); const mutateUserInfo = useCallback(async () => { await fetchCurrentUser().then(async (user) => { await handleSignInRedirection(user); }); }, [fetchCurrentUser, handleSignInRedirection]); const handleResetPassword = async (formData: TResetPasswordFormValues) => { if (!uidb64 || !token || !email) return; const payload = { new_password: formData.password, }; await authService .resetPassword(uidb64.toString(), token.toString(), payload) .then(() => mutateUserInfo()) .catch((err) => setToastAlert({ type: "error", title: "Error!", message: err?.error ?? "Something went wrong. Please try again.", }) ); }; return (
Plane Logo Plane

Let{"'"}s get a new password

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

Whatever you choose now will be your account{"'"}s password until you change it.

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

Try the latest features, like Tiptap editor, to write compelling responses.{" "} See new features

Plane Issues
); }; HomePage.getLayout = function getLayout(page: ReactElement) { return {page}; }; export default HomePage;