mirror of
https://github.com/rjNemo/MERN_sample_app
synced 2026-06-12 11:36:39 +00:00
sets password forget page
This commit is contained in:
parent
61b2480e67
commit
f3cb7c55d6
2 changed files with 78 additions and 12 deletions
|
|
@ -1,13 +1,80 @@
|
||||||
import React from "react";
|
import React, { useState } from "react";
|
||||||
import { Container } from "reactstrap";
|
import { Link } from "react-router-dom";
|
||||||
import ItemModal from "../../components/ItemModal";
|
import { Button, Form, FormGroup, Container } from "reactstrap";
|
||||||
import List from "../../components/List";
|
import { useFirebase } from "../../services/auth";
|
||||||
|
import * as ROUTES from "../../constants/routes";
|
||||||
|
import InputField from "../../components/InputField";
|
||||||
|
|
||||||
|
const useStyles = () => ({
|
||||||
|
root: {
|
||||||
|
paddingTop: "1rem",
|
||||||
|
paddingBottom: "1rem",
|
||||||
|
},
|
||||||
|
button: {
|
||||||
|
marginTop: "1rem",
|
||||||
|
marginBottom: "1rem",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const PasswordForgetPage = () => {
|
||||||
|
const styles = useStyles();
|
||||||
|
|
||||||
export default function PasswordForgetPage() {
|
|
||||||
return (
|
return (
|
||||||
<Container>
|
<Container style={styles.root}>
|
||||||
<ItemModal />
|
<h1>Password Forget</h1>
|
||||||
<List />
|
<PasswordForgetForm />
|
||||||
</Container>
|
</Container>
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
|
const PasswordForgetForm = () => {
|
||||||
|
const [email, setEmail] = useState("");
|
||||||
|
const [error, setError] = useState(null);
|
||||||
|
|
||||||
|
const auth = useFirebase();
|
||||||
|
|
||||||
|
const handleSubmit = (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
auth
|
||||||
|
.resetPassword(email)
|
||||||
|
.then(() => {
|
||||||
|
setEmail("");
|
||||||
|
setError(null);
|
||||||
|
})
|
||||||
|
.catch((err) => setError(err));
|
||||||
|
};
|
||||||
|
|
||||||
|
const isInvalid = email === "";
|
||||||
|
const styles = useStyles();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Form onSubmit={handleSubmit}>
|
||||||
|
<FormGroup>
|
||||||
|
<InputField
|
||||||
|
label="Email Address"
|
||||||
|
id="email"
|
||||||
|
set={setEmail}
|
||||||
|
type="email"
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
color="dark"
|
||||||
|
style={styles.button}
|
||||||
|
disabled={isInvalid}
|
||||||
|
block
|
||||||
|
type="submit"
|
||||||
|
>
|
||||||
|
Reset my Password
|
||||||
|
</Button>
|
||||||
|
{error && <p>{error.message}</p>}
|
||||||
|
</FormGroup>
|
||||||
|
</Form>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const PasswordForgetLink = () => (
|
||||||
|
<p>
|
||||||
|
<Link to={ROUTES.PASSWORD_FORGET}>Forgot Password?</Link>
|
||||||
|
</p>
|
||||||
|
);
|
||||||
|
|
||||||
|
export default PasswordForgetPage;
|
||||||
|
|
|
||||||
|
|
@ -5,15 +5,13 @@ import { useFirebase } from "../../services/auth";
|
||||||
import { SignUpLink } from "../SignUp";
|
import { SignUpLink } from "../SignUp";
|
||||||
import InputField from "../../components/InputField";
|
import InputField from "../../components/InputField";
|
||||||
import * as ROUTES from "../../constants/routes";
|
import * as ROUTES from "../../constants/routes";
|
||||||
|
import { PasswordForgetLink } from "../PasswordForget";
|
||||||
|
|
||||||
const useStyles = () => ({
|
const useStyles = () => ({
|
||||||
root: {
|
root: {
|
||||||
paddingTop: "1rem",
|
paddingTop: "1rem",
|
||||||
paddingBottom: "1rem",
|
paddingBottom: "1rem",
|
||||||
},
|
},
|
||||||
inputField: {
|
|
||||||
paddingBottom: "1rem",
|
|
||||||
},
|
|
||||||
button: {
|
button: {
|
||||||
marginTop: "1rem",
|
marginTop: "1rem",
|
||||||
marginBottom: "1rem",
|
marginBottom: "1rem",
|
||||||
|
|
@ -29,6 +27,7 @@ export default function SignInPage() {
|
||||||
<Container style={styles.root}>
|
<Container style={styles.root}>
|
||||||
<h1>Sign In</h1>
|
<h1>Sign In</h1>
|
||||||
<SignInForm />
|
<SignInForm />
|
||||||
|
<PasswordForgetLink />
|
||||||
<SignUpLink />
|
<SignUpLink />
|
||||||
</Container>
|
</Container>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue