import { useState } from 'react' import { ArticleCard } from './ArticleCard' import type { Article } from '@/types/nostr' interface UserArticlesProps { articles: Article[] loading: boolean error: string | null onLoadContent: (articleId: string, authorPubkey: string) => Promise
showEmptyMessage?: boolean } function ArticlesLoading() { return (

Loading articles...

) } function ArticlesError({ message }: { message: string }) { return (

{message}

) } function EmptyState({ show }: { show: boolean }) { if (!show) { return null } return (

No articles published yet.

) } function UserArticlesView({ articles, loading, error, showEmptyMessage, unlockedArticles, onUnlock, }: Omit & { unlockedArticles: Set; onUnlock: (article: Article) => void }) { if (loading) { return } if (error) { return } if (articles.length === 0) { return } return (
{articles.map((article) => ( ))}
) } export function UserArticles({ articles, loading, error, onLoadContent, showEmptyMessage = true, }: UserArticlesProps) { const [unlockedArticles, setUnlockedArticles] = useState>(new Set()) const handleUnlock = async (article: Article) => { const fullArticle = await onLoadContent(article.id, article.pubkey) if (fullArticle?.paid) { setUnlockedArticles((prev) => new Set([...prev, article.id])) } } return ( { void handleUnlock(a) }} /> ) }