import { CheckCircle2, XCircle, Clock } from "lucide-react";
import { Link } from "@/lib/router";
import { Button } from "@/components/ui/button";
import { Identity } from "./Identity";
import { typeLabel, typeIcon, defaultTypeIcon, ApprovalPayloadRenderer } from "./ApprovalPayload";
import { timeAgo } from "../lib/timeAgo";
import type { Approval, Agent } from "@paperclipai/shared";
function statusIcon(status: string) {
if (status === "approved") return ;
if (status === "rejected") return ;
if (status === "revision_requested") return ;
if (status === "pending") return ;
return null;
}
export function ApprovalCard({
approval,
requesterAgent,
onApprove,
onReject,
onOpen,
detailLink,
isPending,
}: {
approval: Approval;
requesterAgent: Agent | null;
onApprove: () => void;
onReject: () => void;
onOpen?: () => void;
detailLink?: string;
isPending: boolean;
}) {
const Icon = typeIcon[approval.type] ?? defaultTypeIcon;
const label = typeLabel[approval.type] ?? approval.type;
const showResolutionButtons =
approval.type !== "budget_override_required" &&
(approval.status === "pending" || approval.status === "revision_requested");
return (
{/* Header */}
{label}
{requesterAgent && (
requested by
)}
{statusIcon(approval.status)}
{approval.status}
ยท {timeAgo(approval.createdAt)}
{/* Payload */}
{/* Decision note */}
{approval.decisionNote && (
Note: {approval.decisionNote}
)}
{/* Actions */}
{showResolutionButtons && (
)}
{detailLink ? (
) : (
)}
);
}