From bca4d08b01be3eef16e64899e3cb8f6cb13751e2 Mon Sep 17 00:00:00 2001 From: Burhanuddin Khatri <144617735+BurhanCantCode@users.noreply.github.com> Date: Sat, 3 Aug 2024 23:34:16 +0500 Subject: [PATCH] Add files via upload --- components/PasswordReset.tsx | 62 ++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 components/PasswordReset.tsx diff --git a/components/PasswordReset.tsx b/components/PasswordReset.tsx new file mode 100644 index 0000000..0ba3385 --- /dev/null +++ b/components/PasswordReset.tsx @@ -0,0 +1,62 @@ +import { useState } from 'react'; +import { Box, Button, TextField, Typography, Snackbar, Alert } from '@mui/material'; +import { auth } from '../utils/firebaseConfig'; +import { sendPasswordResetEmail } from 'firebase/auth'; + +const PasswordReset = () => { + const [email, setEmail] = useState(''); + const [loading, setLoading] = useState(false); + const [success, setSuccess] = useState(false); + const [error, setError] = useState(null); + + const handlePasswordReset = async () => { + setLoading(true); + setError(null); + try { + await sendPasswordResetEmail(auth, email); + setSuccess(true); + } catch (err: unknown) { + setError('Failed to send password reset email. Please check the email address and try again.'); + } finally { + setLoading(false); + } + }; + + return ( + + + Reset Password + + setEmail(e.target.value)} + required + fullWidth + margin="normal" + /> + + setSuccess(false)}> + setSuccess(false)} severity="success" sx={{ width: '100%' }}> + Password reset email sent successfully! + + + {error && ( + + {error} + + )} + + ); +}; + +export default PasswordReset; \ No newline at end of file