"use client" import { FormEvent, useState } from "react" import AuthShell from "../components/AuthShell" export default function SetupAccountPage() { const [currentPassword, setCurrentPassword] = useState("") const [password, setPassword] = useState("") const [confirmPassword, setConfirmPassword] = useState("") const [message, setMessage] = useState("") const [busy, setBusy] = useState(false) const submit = async (event: FormEvent) => { event.preventDefault() setMessage("") if (password !== confirmPassword) { setMessage("Passwords do not match.") return } setBusy(true) try { const response = await fetch("/api/auth/setup", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ currentPassword, password }), }) const data = await response.json() if (!response.ok) throw new Error(data.error || "Could not update account.") setMessage("Account updated. Redirecting...") window.setTimeout(() => { window.location.href = "/" }, 600) } catch (error) { setMessage(error instanceof Error ? error.message : "Could not update account.") } finally { setBusy(false) } } return (
{message && (
{message}
)} Back to Sign In
) }