import { Badge } from '@/components/ui/badge' import { useFetchRelayInfo } from '@/hooks' import { TRelayInfo } from '@/types' import { GitBranch, Mail, SquareCode } from 'lucide-react' import RelayIcon from '../RelayIcon' import UserAvatar from '../UserAvatar' import Username from '../Username' export default function RelayInfo({ url }: { url: string }) { const { relayInfo, isFetching } = useFetchRelayInfo(url) if (isFetching || !relayInfo) { return null } return (
{relayInfo.name &&
{relayInfo.name}
}
{!!relayInfo.tags?.length && (
{relayInfo.tags.map((tag) => ( {tag} ))}
)} {relayInfo.description && (
{relayInfo.description}
)}
{relayInfo.pubkey && (
Operator
)} {relayInfo.contact && (
Contact
{relayInfo.contact}
)} {relayInfo.software && (
Software
{formatSoftware(relayInfo.software)}
)} {relayInfo.version && (
Version
{relayInfo.version}
)}
) } function formatSoftware(software: string) { const parts = software.split('/') return parts[parts.length - 1] } function RelayBadges({ relayInfo }: { relayInfo: TRelayInfo }) { return (
{relayInfo.supported_nips?.includes(42) && ( Auth )} {relayInfo.supported_nips?.includes(50) && ( Search )} {relayInfo.limitation?.payment_required && ( Payment )} {relayInfo.supported_nips?.includes(29) && ( Groups )}
) }