import { useState } from "react"; import { Link, useNavigate, useSearchParams } from "react-router-dom"; import { useAuthStore } from "../stores/auth.ts"; export function ResetPasswordPage() { const [searchParams] = useSearchParams(); const token = searchParams.get("token") || ""; const navigate = useNavigate(); const [password, setPassword] = useState(""); const [confirmPassword, setConfirmPassword] = useState(""); const [success, setSuccess] = useState(false); const [localError, setLocalError] = useState(null); const { resetPassword, isLoading, error, clearError } = useAuthStore(); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); clearError(); setLocalError(null); if (password.length < 8) { setLocalError("Password must be at least 8 characters."); return; } if (password !== confirmPassword) { setLocalError("Passwords do not match."); return; } try { await resetPassword(token, password); setSuccess(true); } catch { // error displayed from store } }; if (!token) { return (
            {"┌─ DUMPSTER ─┐"}
          

[INVALID LINK]

This password reset link is missing or invalid. Request a new one.

[REQUEST NEW LINK]
); } return (
          {"┌─ DUMPSTER ─┐"}
        

[RESET PASSWORD]

{success ? (

Password updated successfully.

All existing sessions have been logged out.

) : (
setPassword(e.target.value)} className="terminal-input" required minLength={8} autoComplete="new-password" autoFocus />
setConfirmPassword(e.target.value)} className="terminal-input" required minLength={8} autoComplete="new-password" />
{(localError || error) && (

ERR: {localError || error}

)}
[BACK TO LOGIN]
)}
); }