'use client' import Link from 'next/link' import { useState, Suspense } from 'react' import { useSearchParams, useRouter } from 'next/navigation' import PublicShell from '@/components/PublicShell' import { ADMIN_API_BASE } from '@/lib/api' export default function AdminResetPasswordPage() { return ( ) } function AdminResetPasswordContent() { const searchParams = useSearchParams() const router = useRouter() const token = searchParams.get('token') const [password, setPassword] = useState('') const [showPassword, setShowPassword] = useState(false) const [confirm, setConfirm] = useState('') const [showConfirm, setShowConfirm] = useState(false) const [loading, setLoading] = useState(false) const [done, setDone] = useState(false) const [error, setError] = useState(null) async function handleSubmit(e: React.FormEvent) { e.preventDefault() if (password.length < 8) { setError('Password must be at least 8 characters.'); return } if (password !== confirm) { setError('Passwords do not match.'); return } setLoading(true) setError(null) try { const res = await fetch(`${ADMIN_API_BASE}/admin/auth/reset-password`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, credentials: 'include', body: JSON.stringify({ token, password }), }) const json = await res.json() if (!res.ok) { if (json?.error === 'invalid_token') throw new Error('This reset link is invalid or has expired.') throw new Error('Something went wrong. Please try again.') } setDone(true) } catch (err: any) { setError(err.message ?? 'Something went wrong.') } finally { setLoading(false) } } if (!token) { return (

No reset token found.

Request a new reset link
) } if (done) { return (

Password updated

You can now sign in with your new password.

) } return (
{error && (
{error}
)}
setPassword(e.target.value)} placeholder="••••••••" className="w-full rounded-2xl border border-stone-200 bg-white px-4 py-3 pr-10 text-sm text-stone-900 focus:border-transparent focus:outline-none focus:ring-2 focus:ring-orange-500 dark:border-blue-800 dark:bg-[#07101e]/80 dark:text-stone-100" />
setConfirm(e.target.value)} placeholder="••••••••" className="w-full rounded-2xl border border-stone-200 bg-white px-4 py-3 pr-10 text-sm text-stone-900 focus:border-transparent focus:outline-none focus:ring-2 focus:ring-orange-500 dark:border-blue-800 dark:bg-[#07101e]/80 dark:text-stone-100" />
Back to sign in
) } function AdminResetShell({ children }: { children: React.ReactNode }) { return (
RentalDriveGo

Reset password

{children}
) }