- Fix unused function warnings by renaming to _unusedExtractTags - Fix type errors in nostrTagSystem.ts for includes() calls - Fix type errors in reviews.ts for filter kinds array - Fix ArrayBuffer type errors in articleEncryption.ts - Remove unused imports (DecryptionKey, decryptArticleContent, extractTagsFromEvent) - All TypeScript checks now pass without disabling any controls
89 lines
2.4 KiB
TypeScript
89 lines
2.4 KiB
TypeScript
import type { Article } from '@/types/nostr'
|
|
import { useNostrConnect } from '@/hooks/useNostrConnect'
|
|
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<typeof useArticlePayment>['paymentInvoice']
|
|
onClose: () => void
|
|
onPaymentComplete: () => void
|
|
}) {
|
|
return (
|
|
<>
|
|
{error && <p className="text-sm text-red-400 mt-2">{error}</p>}
|
|
<div className="text-xs text-cyber-accent/50 mt-4">
|
|
{t('publication.published', { date: new Date(article.createdAt * 1000).toLocaleDateString() })}
|
|
</div>
|
|
{paymentInvoice && (
|
|
<PaymentModal
|
|
invoice={paymentInvoice}
|
|
onClose={onClose}
|
|
onPaymentComplete={onPaymentComplete}
|
|
/>
|
|
)}
|
|
</>
|
|
)
|
|
}
|
|
|
|
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 className="border border-neon-cyan/30 rounded-lg p-6 bg-cyber-dark hover:border-neon-cyan/50 hover:shadow-glow-cyan transition-all">
|
|
<div className="mb-2 flex items-center justify-between">
|
|
<h2 className="text-2xl font-bold text-neon-cyan">{article.title}</h2>
|
|
<Link
|
|
href={`/author/${article.pubkey}`}
|
|
className="text-xs text-cyber-accent/70 hover:text-neon-cyan transition-colors"
|
|
>
|
|
{t('publication.viewAuthor')}
|
|
</Link>
|
|
</div>
|
|
<div className="text-cyber-accent mb-4">
|
|
<ArticlePreview
|
|
article={article}
|
|
loading={loading}
|
|
onUnlock={() => {
|
|
void handleUnlock()
|
|
}}
|
|
/>
|
|
</div>
|
|
<ArticleMeta
|
|
article={article}
|
|
error={error}
|
|
paymentInvoice={paymentInvoice}
|
|
onClose={handleCloseModal}
|
|
onPaymentComplete={() => {
|
|
void handlePaymentComplete()
|
|
}}
|
|
/>
|
|
</article>
|
|
)
|
|
}
|