Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | 1x 1x 25x 25x 5x 5x 4x 4x 4x 5x 25x 25x 25x 25x 24x 24x 24x 24x 24x 24x 24x 4x 20x 24x 25x 25x | 'use client';
import { useState } from 'react';
import { Copy, Check } from 'lucide-react';
import { Button } from '@/components/ui/button';
import { copyToClipboard } from '@/lib/utils';
interface IdentityBadgeProps {
code: string;
showCopy?: boolean;
className?: string;
}
export function IdentityBadge({ code, showCopy = true, className }: IdentityBadgeProps) {
const [copied, setCopied] = useState(false);
const handleCopy = async () => {
const success = await copyToClipboard(code);
if (success) {
setCopied(true);
setTimeout(() => setCopied(false), 2000);
}
};
return (
<div className={`inline-flex items-center gap-2 ${className || ''}`}>
<code className="identity-code rounded bg-muted px-2 py-1 text-sm text-primary">{code}</code>
{showCopy && (
<Button
variant="ghost"
size="icon"
className="h-7 w-7"
onClick={handleCopy}
title={copied ? 'Copied!' : 'Copy identity code'}
>
{copied ? (
<Check className="h-3.5 w-3.5 text-green-500" />
) : (
<Copy className="h-3.5 w-3.5" />
)}
</Button>
)}
</div>
);
}
|