Spaces:
Paused
Paused
File size: 1,706 Bytes
bcf46c3 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | import React, { useState } from 'react';
import { supabase } from '../context';
export default function UpdatePassword({ onComplete }) {
const [password, setPassword] = useState('');
const [error, setError] = useState('');
const [loading, setLoading] = useState(false);
const handleUpdate = async (e) => {
e.preventDefault();
setLoading(true);
setError('');
const { error } = await supabase.auth.updateUser({ password });
setLoading(false);
if (error) {
setError(error.message);
} else {
alert('Password updated successfully!');
onComplete();
}
};
return (
<div className="auth-container">
<div className="auth-card">
<h2 className="auth-title">Update Password</h2>
<p className="text-muted" style={{ marginBottom: '1rem', textAlign: 'center' }}>
Please enter your new password below.
</p>
{error && <div className="error-message">{error}</div>}
<form onSubmit={handleUpdate}>
<div className="form-group">
<label className="form-label">New Password</label>
<input
type="password"
className="form-input"
placeholder="••••••••"
value={password}
onChange={(e) => setPassword(e.target.value)}
required
minLength={6}
/>
</div>
<button
type="submit"
className="submit-btn"
disabled={loading}
>
{loading ? 'Updating...' : 'Update Password'}
</button>
</form>
</div>
</div>
);
}
|