"use client"; import { useEffect, useState } from "react"; import { api } from "@/lib/api/client"; import { Button } from "@/components/ui/button"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { Input } from "@/components/ui/input"; export default function SettingsPage() { const [me, setMe] = useState<{ display_name: string | null; email: string } | null>(null); const [current, setCurrent] = useState(""); const [next, setNext] = useState(""); const [confirm, setConfirm] = useState(""); const [msg, setMsg] = useState<{ kind: "ok" | "err"; text: string } | null>(null); const [busy, setBusy] = useState(false); useEffect(() => { api.GET("/api/v1/users/me").then((r) => setMe(r.data ?? null)); }, []); async function changePassword(e: React.FormEvent) { e.preventDefault(); setMsg(null); if (next.length < 8) { setMsg({ kind: "err", text: "New password must be at least 8 characters." }); return; } if (next !== confirm) { setMsg({ kind: "err", text: "New passwords don't match." }); return; } setBusy(true); const { error } = await api.POST("/api/v1/auth/change-password", { body: { current_password: current, new_password: next }, }); setBusy(false); if (error) { setMsg({ kind: "err", text: "Current password is incorrect." }); return; } setCurrent(""); setNext(""); setConfirm(""); setMsg({ kind: "ok", text: "Password changed." }); } return (
Full-account export, restore, and account deletion are coming next.