React-SaaS-sample/src/components/ForgotPass.js
Ruidy Nemausat d501c9d04f template
2019-11-02 20:18:05 +01:00

38 lines
804 B
JavaScript

import React, { useState } from "react";
import Auth from "./Auth";
import { useAuth } from "./../util/auth.js";
function ForgotPass(props) {
const auth = useAuth();
const [status, setStatus] = useState();
const onSubmit = ({ email }) => {
setStatus({ type: "pending" });
auth
.sendPasswordResetEmail(email)
.then(() => {
setStatus({
type: "success",
message: "Password reset email sent"
});
})
.catch(error => {
setStatus({
type: "error",
message: error.message
});
});
};
return (
<Auth
mode="forgotpass"
buttonText={props.buttonText}
parentColor={props.parentColor}
onSubmit={onSubmit}
status={status}
/>
);
}
export default ForgotPass;