import { useState } from 'react' import { useMutation } from '@tanstack/react-query' import { KeyRound, LogOut, ShieldCheck } from 'lucide-react' import { Link } from 'react-router-dom' import { authApi } from '../lib/auth' import { useAuth } from '../lib/useAuth' import { CAP, can } from '../lib/can' import { TimeZonePanel } from './TimeZonePanel' import { Badge, Panel } from '../components/ui' export function Settings() { const { principal, logout } = useAuth() return (
{/* Account management lives on ONE screen. Settings used to carry its own Team panel: a second user list on a different query key, whose invite sent no tool set and so created accounts entitled to nothing, and whose role changes did not invalidate the other screen. Two surfaces for the same thing disagreed about what access a person had, which is the worst possible thing for an access control screen to be ambiguous about. */} {can(principal, CAP.userInvite) && (

Create accounts, set roles, and choose which tools each person can see.

Open accounts and access
)} {/* Owner only: the server refuses it for anyone else, so offering it would be a button that fails. */} {can(principal, CAP.orgSettings) && }

Federated SSO (Login.gov, Entra Gov, PIV CAC) and public signup are a later sub phase. Invites are delivered manually at pilot, the link is shown after you invite a teammate.

) } function AccountPanel({ onLogout, role, orgID }: { onLogout: () => void; role: string; orgID: string }) { const [oldPw, setOldPw] = useState('') const [newPw, setNewPw] = useState('') const [msg, setMsg] = useState('') const change = useMutation({ mutationFn: () => authApi.changePassword(oldPw, newPw), onSuccess: () => { setMsg('Password changed.') setOldPw('') setNewPw('') }, onError: () => setMsg('Could not change the password. Check the current one.'), }) const logoutAll = useMutation({ mutationFn: () => authApi.logoutAll() }) return (
{role || 'unknown role'} org {orgID.slice(0, 8)}
{ e.preventDefault() setMsg('') if (newPw.length < 8) { setMsg('Use at least 8 characters.') return } change.mutate() }} >
Change password
{msg &&

{msg}

}
) }