Repository Public
1/**2 * v7 perp live — a venue account that an agent trades under a derivative mandate says so wherever the owner could place a3 * manual order on it (Futures → Accounts, the terminal's order panel), with what a manual order then does to the agent.4 */5import { useQuery } from '@tanstack/react-query';6import { get } from '../api';7import { useT } from '../i18n';8import { Icon, Notice } from '../ui';9import type { LiveSummary } from './live';1011export function AgentOnAccount({ account }: { account: Pick<LiveSummary, 'mandate'> }) {12 const t = useT();13 const m = account.mandate, on = !!m && m.phase !== 'ended';14 const agents = useQuery({ queryKey: ['agents'], queryFn: () => get<{ agents: { id: string; name: string }[] }>('/agents'), enabled: on, staleTime: 30_000, retry: 0 });15 if (!m || !on) return null;16 const name = agents.data?.agents.find((a) => a.id === m.agentId)?.name ?? m.agentId;17 return <Notice tone="warn"><div data-testid="agent-on-account" data-phase={m.phase}>18 <b className="flex items-center gap-1.5 font-semibold"><Icon n="key" className="h-4 w-4 shrink-0" />{t('plUsedBy', { name })}</b>19 <span className="mt-0.5 block text-[12.5px]">{t(m.phase === 'active' ? 'plMandateOn' : 'plMandateWinding')}</span>20 {m.phase === 'active' && <span className="mt-1 block text-[12.5px] leading-snug">{t('plManualWarn')}</span>}21 <a href={`/agents/${encodeURIComponent(m.agentId)}`} className="mt-1 inline-flex min-h-9 items-center gap-1 text-[13px] font-semibold underline">{t('plUsedByOpen')}<Icon n="chev" className="h-3.5 w-3.5" /></a>22 </div></Notice>;23}24