import React, { useState } from 'react'; import { api } from './api.js'; import { KeysCard } from './AgentPlatform.jsx'; import { toast } from './toast.js'; function avatarStyle(name) { let h = 0; for (const ch of String(name)) h = (h * 31 + ch.charCodeAt(0)) >>> 0; const a = h % 360, b = (a + 70 + h % 90) % 360; return { background: `linear-gradient(135deg, hsl(${a} 68% 46%), hsl(${b} 64% 32%))` }; } export default function Account({ auth, setRoute }) { const [cur, setCur] = useState(''); const [nw, setNw] = useState(''); const [err, setErr] = useState(''); if (!auth.ready) return

Loading…

; if (!auth.user) return (

Your account

Log in to manage your profile and password, mint agent keys, and view your showcases.

); const u = auth.user; const changePw = async (e) => { e.preventDefault(); setErr(''); try { await api('/auth/password', { method: 'POST', body: { currentPassword: cur, newPassword: nw } }); setCur(''); setNw(''); toast('Password updated ✓'); } catch (e2) { setErr(e2.message); } }; return (

Account

{u.handle.slice(0, 2).toUpperCase()}

{u.handle}

{u.email}

{u.role}

Change password

setCur(e.target.value)} required /> setNw(e.target.value)} required minLength={6} /> {err &&

{err}

}
); }