import React, { useEffect, useState } from "react";
import PATHS from "router/paths";
import usersAPI from "services/entities/users";
import formatErrorResponse from "utilities/format_error_response";
// @ts-ignore
import ForgotPasswordForm from "components/forms/ForgotPasswordForm";
// @ts-ignore
import StackedWhiteBoxes from "components/StackedWhiteBoxes";
import AuthenticationFormWrapper from "components/AuthenticationFormWrapper";
import Spinner from "components/Spinner";
import CustomLink from "components/CustomLink";
const ForgotPasswordPage = () => {
const [email, setEmail] = useState("");
const [errors, setErrors] = useState<{ [key: string]: string }>({});
const [isLoading, setIsLoading] = useState(false);
const baseClass = "forgot-password";
useEffect(() => {
setErrors({});
}, []);
const handleSubmit = async (formData: any) => {
setIsLoading(true);
try {
await usersAPI.forgotPassword(formData);
setEmail(formData.email);
setErrors({});
} catch (response) {
const errorObject = formatErrorResponse(response);
setEmail("");
setErrors(errorObject);
return false;
} finally {
setIsLoading(false);
}
};
const renderContent = () => {
if (isLoading) {
return
An email was sent to{" "}
{email}. Click the
link in the email to proceed with the password reset process. If you
did not receive an email please contact your Fleet administrator.
You can find more information on resetting passwords at the{" "}
Enter your email below to receive an email with instructions to reset your password.