import { useState } from 'react' import { Check, ShieldAlert, X } from 'lucide-react' import type { Agent, Approval } from '../../types' import { getAgentMeta } from '../../lib/agentMeta' import { Button } from '../ui/Button' import { cn } from '../../lib/utils' const ACTION_LABELS: Record = { 'docker.restart': 'Container restart', 'docker.update': 'Image update', 'generic.mutate': 'Infrastructure change', } type Props = { approvals: Approval[] agents: Agent[] highlighted: boolean onDecide: (id: string, approved: boolean, decidedBy: string, note: string) => Promise onDismissHighlight?: () => void } export function ApprovalCards({ approvals, agents, highlighted, onDecide, onDismissHighlight }: Props) { const [busyId, setBusyId] = useState(null) const [decider, setDecider] = useState<'mo-commander' | 'bart-commander'>('mo-commander') if (!approvals.length) return null const agentOf = (id: string) => agents.find((a) => a.id === id) const handle = async (id: string, approved: boolean) => { setBusyId(id) try { await onDecide(id, approved, decider, '') } finally { setBusyId(null) } } return (
Pending approvals ({approvals.length})
{highlighted && onDismissHighlight && ( )}
{approvals.map((a) => { const ag = agentOf(a.agent_id) const meta = ag ? getAgentMeta(ag.id) : null const Icon = meta?.icon return (
{Icon && ( )}
{ACTION_LABELS[a.action_type] || a.action_type}

{ag?.name || a.agent_id}

#{a.id.slice(0, 6)}

{a.action}

{a.target &&

Target: {a.target}

}
) })}
) }