Skip to content

Commit

Permalink
feat(reset password page): add error message & add Link component
Browse files Browse the repository at this point in the history
  • Loading branch information
ismail-benlaredj committed Nov 6, 2023
1 parent dc6e6c6 commit 335752b
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/pages/reset-password/index.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { useState } from "react";
import { getAuth, sendPasswordResetEmail } from "firebase/auth";
import Link from "next/link";
import { useRouter } from "next/router"; // Import useRouter
import { useState } from "react";

import Button from "@/components/button/Button";

export default function ResetPasswordForm() {
const [email, setEmail] = useState("");
const [errorMessage, setErrorMessage] = useState();
const router = useRouter(); // Use useRouter
const auth = getAuth();

Expand All @@ -15,7 +18,7 @@ export default function ResetPasswordForm() {
router.push("/login"); // Use router.push
})
.catch((error) => {
console.log("Error:", error);
setErrorMessage(error.message);
});
}

Expand All @@ -27,6 +30,9 @@ export default function ResetPasswordForm() {
</h1>
<form className='bg-white rounded px-8 pt-6 pb-8 mb-4'>
<div className='mb-4'>
{errorMessage && (
<p className='text-red'>{errorMessage}</p>
)}
<label
className='block text-gray-700 text-sm font-bold mb-2'
htmlFor='email'
Expand All @@ -48,9 +54,9 @@ export default function ResetPasswordForm() {
</Button>
</form>
<div className='text-center'>
<a className='underline' href='/login'>
<Link className='underline' href='/login'>
Back to Login
</a>
</Link>
</div>
</div>
</div>
Expand Down

0 comments on commit 335752b

Please sign in to comment.