import { useState } from 'react'; import { Button } from '../ui/button'; import { Card, CardContent } from '../ui/card'; import { Input } from '../ui/input'; import { Label } from '../ui/label'; import { resetPassword } from '../../lib/auth-client'; const logo = '/logo.png'; interface Props { onSuccess: () => void; } export function ResetPassword({ onSuccess }: Props) { const token = new URLSearchParams(window.location.search).get('token') || ''; const [password, setPassword] = useState(''); const [confirm, setConfirm] = useState(''); const [error, setError] = useState(''); const [loading, setLoading] = useState(false); const [done, setDone] = useState(false); async function handleSubmit(e: React.FormEvent) { e.preventDefault(); setError(''); if (password.length < 8) { setError('Password must be at least 8 characters'); return; } if (password !== confirm) { setError('Passwords do not match'); return; } setLoading(true); const res = await resetPassword({ newPassword: password, token }); setLoading(false); if (res.error) { setError(res.error.message || 'Failed to reset password. The link may have expired.'); } else { setDone(true); setTimeout(onSuccess, 2000); } } return (
Redirecting you to sign in…
Choose a new password for your account.