import { BadgeCheck, Loader2, AlertTriangle } from 'lucide-react';
import {
Tooltip,
TooltipContent,
TooltipProvider,
TooltipTrigger,
} from '@/components/ui/tooltip';
import { useCrewNip05 } from '@/hooks/useCrewNip05';
import { cn } from '@/lib/utils';
interface CrewNip05BadgeProps {
nip05?: string;
founderPubkey?: string;
className?: string;
}
/**
* Verified-handle badge for a crew's optional NIP-05.
*
* - `verified`: green check + the handle. The domain confirms the founder key.
* - `mismatch`: red warning — the domain points the handle at a different key.
* - `unreachable`: muted handle (shown but unverified) while the domain is down.
* - `none`: renders nothing.
*/
export function CrewNip05Badge({ nip05, founderPubkey, className }: CrewNip05BadgeProps) {
const { data, isLoading } = useCrewNip05(nip05, founderPubkey);
if (!nip05) return null;
const status = data?.status ?? (isLoading ? 'loading' : 'unreachable');
const handle = nip05.trim().toLowerCase();
if (status === 'mismatch') {
return (
{handle}
This domain points the handle at a different Nostr key than the crew founder. Not verified.
);
}
if (status === 'verified') {
return (
{handle}
Verified — the domain confirms this handle belongs to the crew's founder key.
);
}
// loading / unreachable — show the handle, muted.
return (
{status === 'loading' ? (
) : null}
{handle}
);
}