import type { Article } from '@/types/nostr' import { useNostrAuth } from '@/hooks/useNostrAuth' import { useArticlePayment } from '@/hooks/useArticlePayment' import { ArticlePreview } from './ArticlePreview' import { PaymentModal } from './PaymentModal' import { t } from '@/lib/i18n' import Link from 'next/link' interface ArticleCardProps { article: Article onUnlock?: (article: Article) => void } function ArticleMeta({ article, error, paymentInvoice, onClose, onPaymentComplete, }: { article: Article error: string | null paymentInvoice: ReturnType['paymentInvoice'] onClose: () => void onPaymentComplete: () => void }) { return ( <> {error &&

{error}

}
{t('publication.published', { date: new Date(article.createdAt * 1000).toLocaleDateString() })}
{paymentInvoice && ( )} ) } export function ArticleCard({ article, onUnlock }: ArticleCardProps) { const { pubkey, connect } = useNostrAuth() const { loading, error, paymentInvoice, handleUnlock, handlePaymentComplete, handleCloseModal, } = useArticlePayment(article, pubkey ?? null, () => { onUnlock?.(article) }, connect) return (

{article.title}

{t('publication.viewAuthor')}
{ void handleUnlock() }} />
{ void handlePaymentComplete() }} />
) }