import { dateLocaleCode } from '@/lib/dateFnsI18n'; import { Link } from 'react-router-dom'; import type { NostrEvent } from '@nostrify/nostrify'; import { Star, ThumbsUp, ArrowUpRight } from 'lucide-react'; import { Card, CardContent } from '@/components/ui/card'; import { Skeleton } from '@/components/ui/skeleton'; import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'; import { TradeReputationCard } from '@/components/TradeReputationCard'; import { TradeRecommendationsCard } from '@/components/TradeRecommendationsCard'; import { DeckRating } from '@/components/DeckRating'; import { useTradeReputation, TRADE_METHODS, type TradeRole } from '@/hooks/useTradeAttestations'; import { useAuthor } from '@/hooks/useAuthor'; import { genUserName } from '@/lib/genUserName'; import { cn } from '@/lib/utils'; import { useTranslation } from '@/contexts/language'; /** One trade record / review row. */ function ReviewRow({ ev, selfPubkey }: { ev: NostrEvent; selfPubkey: string }) { const { t } = useTranslation(); const role = ev.tags.find(([t]) => t === 'd')?.[1]?.split(':')[2] as TradeRole | undefined; const counterparty = ev.tags.find(([t]) => t === 'p')?.[1] ?? ''; const method = ev.tags.find(([t]) => t === 'method')?.[1]; const amount = ev.tags.find(([t]) => t === 'amount')?.[1]; const rating = Number(ev.tags.find(([t]) => t === 'rating')?.[1] ?? 0); const coord = ev.tags.find(([t]) => t === 'a')?.[1] ?? ''; const [, listingPubkey, listingId] = coord.split(':'); const author = useAuthor(counterparty); const name = author.data?.metadata?.name ?? genUserName(counterparty); const picture = author.data?.metadata?.picture; const given = ev.pubkey === selfPubkey; const date = new Date(ev.created_at * 1000).toLocaleDateString(dateLocaleCode()); return (
{ev.content}
}{t('marketUi.reputationPanel.emptyBefore')} {t('marketUi.trades.title')} {t('marketUi.reputationPanel.emptyAfter')}