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