diff --git a/context/AuthContext.js b/context/AuthContext.js index 0808f9e..d7e5c72 100644 --- a/context/AuthContext.js +++ b/context/AuthContext.js @@ -2,6 +2,7 @@ import { auth } from "firebase.config"; import { createUserWithEmailAndPassword, onAuthStateChanged, + sendPasswordResetEmail, signInWithEmailAndPassword, signOut, } from "firebase/auth"; @@ -46,9 +47,13 @@ export const AuthContextProvider = ({ children }) => { setUser(null); await signOut(auth); }; - + const resetPassword = (email) => { + return sendPasswordResetEmail(auth, email); + }; return ( - + {loading ? null : children} ); diff --git a/data/products.json b/data/products.json index de1eb84..4ab8455 100644 --- a/data/products.json +++ b/data/products.json @@ -595,8 +595,8 @@ "condition": "New", "seller": { "id": 88888888, - "displayName": "Umut Polat", - "email": "studentstoretemp@gmail.com", + "displayName": "Nouh Rastanawi", + "email": "studentstoretemp@gmaill.com", "image": "https://www.random-name-generator.com/images/faces/male-white/37.jpg?ezimgfmt=rs:148x143/rscb1/ng:webp/ngcb1" }, "requestedBuyers": [], diff --git a/src/components/EditProfile/EditProfile.jsx b/src/components/EditProfile/EditProfile.jsx index 3203c0b..51e3c3d 100644 --- a/src/components/EditProfile/EditProfile.jsx +++ b/src/components/EditProfile/EditProfile.jsx @@ -5,16 +5,20 @@ import { updateProfile } from "firebase/auth"; import { useRouter } from "next/router"; import { useTranslation } from "next-i18next"; import * as React from "react"; +import { useRef } from "react"; import { toast, ToastContainer } from "react-toastify"; import { injectStyle } from "react-toastify/dist/inject-style"; import Button from "../button"; import Input from "../input"; +import { useAuth } from "../../../context/AuthContext"; if (typeof window !== "undefined") { injectStyle(); } export default function EditProfile() { + const emailRef = useRef(null); + const { resetPassword } = useAuth(); const { t } = useTranslation("profile"); const router = useRouter(); @@ -34,6 +38,20 @@ export default function EditProfile() { .catch(() => {}); }; + const resetUserPassword = async (event) => { + event.preventDefault(); + + await resetPassword(emailRef.current.value) + .then(() => { + toast.success( + t( + "Check your inbox we Sent you a link to reset your password" + ) + "!" + ); + }) + .catch(() => {}); + }; + return (
@@ -49,12 +67,18 @@ export default function EditProfile() { placeholder={t("name")} required /> - - - +
@@ -68,6 +92,15 @@ export default function EditProfile() { handleClick={updateInfo} /> + + +
diff --git a/src/components/EditProfile/__test__/__snapshots__/EditProfile.test.jsx.snap b/src/components/EditProfile/__test__/__snapshots__/EditProfile.test.jsx.snap index 39f94d3..fc7fdbe 100644 --- a/src/components/EditProfile/__test__/__snapshots__/EditProfile.test.jsx.snap +++ b/src/components/EditProfile/__test__/__snapshots__/EditProfile.test.jsx.snap @@ -18,24 +18,10 @@ exports[`renders correctly 1`] = ` - -
@@ -60,6 +46,15 @@ exports[`renders correctly 1`] = ` save-changes + + +