import { Button } from "@/src/components/ui/button"; import { CopyIcon, CheckIcon } from "lucide-react"; import { useState } from "react"; import { Popover, PopoverContent, PopoverTrigger, } from "@/src/components/ui/popover"; import { cn } from "@/src/utils/tailwind"; import { Label } from "@/src/components/ui/label"; import { copyTextToClipboard } from "@/src/utils/clipboard"; interface IdItem { name: string; id: string; } export const CopyIdsPopover = ({ idItems, className, }: { idItems: IdItem[]; className?: string; }) => { const [copiedId, setCopiedId] = useState(null); const handleCopy = (textToCopy: string) => { copyTextToClipboard(textToCopy); setCopiedId(textToCopy); setTimeout(() => setCopiedId(null), 1500); }; // If only one idItem provided, use simple button with only one ID if (idItems.length === 1) { return ( ); } return (
{idItems.map((item) => (
{item.name}
{item.id}
))}
); };