import { useMemo } from 'react'; import { Link } from 'react-router-dom'; import { Bookmark, Crown, Shield, Users } from 'lucide-react'; import { nip19 } from 'nostr-tools'; import type { NostrEvent } from '@nostrify/nostrify'; import { parseCommunityEvent, COMMUNITY_DEFINITION_KIND } from '@/lib/communityUtils'; import { cn } from '@/lib/utils'; interface CommunityCardProps { /** The kind 34550 community definition event. */ event: NostrEvent; /** Whether the current user founded this community. */ isFounded?: boolean; /** Whether the current user is a validated member. */ isMember?: boolean; /** Whether the current user follows this community via NIP-51 kind 10004. */ isBookmarked?: boolean; className?: string; } /** * Compact card for displaying a community in a list. * Shows image, name, description snippet, founder info, and community status. */ export function CommunityCard({ event, isFounded, isMember, isBookmarked, className, }: CommunityCardProps) { const community = useMemo(() => parseCommunityEvent(event), [event]); if (!community) return null; const naddr = nip19.naddrEncode({ kind: COMMUNITY_DEFINITION_KIND, pubkey: event.pubkey, identifier: community.dTag, }); return (
{isFounded && ( )} {isMember && ( )} {isBookmarked && ( )}
{/* Image backdrop */} {community.image ? ( {community.name} ) : (
)}

{community.name}

{community.description && (

{community.description}

)}
); }