import type { Article } from '@/types/nostr' import { useNostrConnect } from '@/hooks/useNostrConnect' import { useArticlePayment } from '@/hooks/useArticlePayment' import { ArticlePreview } from './ArticlePreview' import { PaymentModal } from './PaymentModal' 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}

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

{article.title}

{ void handleUnlock() }} />
{ void handlePaymentComplete() }} />
) }