UNPKG

naim-firebase-auth-wrapper

Version:

React components and hooks for Firebase Authentication and Firestore with Mantine UI

29 lines 1.6 kB
'use client'; import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; import { useState } from 'react'; import { useAuth } from '../hooks/useAuth'; import { PasswordInput, Button, Stack, Paper, Title } from '@mantine/core'; export const PasswordChange = () => { const { updateUserPassword } = useAuth(); const [currentPassword, setCurrentPassword] = useState(''); const [newPassword, setNewPassword] = useState(''); const [loading, setLoading] = useState(false); const handleSubmit = async (e) => { e.preventDefault(); setLoading(true); try { await updateUserPassword(currentPassword, newPassword); alert('Password updated successfully'); setCurrentPassword(''); setNewPassword(''); } catch (error) { alert(error); } finally { setLoading(false); } }; return (_jsxs(Paper, { radius: "md", p: "xl", withBorder: true, children: [_jsx(Title, { order: 3, mb: "md", children: "Change Password" }), _jsx("form", { onSubmit: handleSubmit, children: _jsxs(Stack, { children: [_jsx(PasswordInput, { required: true, label: "Current Password", value: currentPassword, onChange: (e) => setCurrentPassword(e.target.value), radius: "md" }), _jsx(PasswordInput, { required: true, label: "New Password", value: newPassword, onChange: (e) => setNewPassword(e.target.value), radius: "md" }), _jsx(Button, { type: "submit", loading: loading, radius: "md", children: "Update Password" })] }) })] })); }; //# sourceMappingURL=PasswordChange.js.map