'use client'; import { Input, Label } from '@/components/input'; import { Button } from '@/components/ui/button'; import { apiFetch } from '@/lib/api'; import { Loader2 } from 'lucide-react'; import Link from 'next/link'; import { useEffect, useState } from 'react'; interface Profile { id: string; email: string; name: string | null; phone: string | null; isAdmin: boolean; createdAt: string; } export default function ProfilePage() { const [profile, setProfile] = useState(null); const [name, setName] = useState(''); const [busy, setBusy] = useState(false); const [error, setError] = useState(null); const [saved, setSaved] = useState(false); function load() { apiFetch<{ profile: Profile }>('/v1/account/profile') .then((r) => { setProfile(r.profile); setName(r.profile.name ?? ''); }) .catch((e) => setError((e as Error).message)); } useEffect(load, []); async function save(e: React.FormEvent) { e.preventDefault(); if (!profile) return; setBusy(true); setError(null); setSaved(false); try { await apiFetch('/v1/account/profile', { method: 'PATCH', body: JSON.stringify({ name: name.trim() }), }); setSaved(true); load(); } catch (err) { setError((err as Error).message); } finally { setBusy(false); } } if (!profile && !error) { return (
); } if (!profile) { return (

{error}

); } return (

Profile

Personal details. Email and phone can't be changed self-service yet — open a{' '} support ticket {' '} if you need it changed.

setName(e.target.value)} maxLength={128} placeholder="How should we address you?" />
{error &&

{error}

} {saved &&

Saved.

}
Billing → Support → Your data →
); } function ReadField({ label, value, mono }: { label: string; value: string; mono?: boolean }) { return (
{label}
{value}
); }