import { ArticleCard } from './ArticleCard' import type { Article } from '@/types/nostr' import { memo } from 'react' import Link from 'next/link' interface UserArticlesViewProps { articles: Article[] loading: boolean error: string | null showEmptyMessage?: boolean unlockedArticles: Set onUnlock: (article: Article) => void onEdit: (article: Article) => void onDelete: (article: Article) => void editingArticleId: string | null currentPubkey: string | null pendingDeleteId: string | null requestDelete: (articleId: string) => void onSelectSeries?: ((seriesId: string | undefined) => void) | undefined } const ArticlesLoading = () => (

Loading articles...

) const ArticlesError = ({ message }: { message: string }) => (

{message}

) const EmptyState = ({ show }: { show: boolean }) => show ? (

No articles published yet.

) : null function ArticleActions({ article, onEdit, onDelete, editingArticleId, pendingDeleteId, requestDelete, }: { article: Article onEdit: (article: Article) => void onDelete: (article: Article) => void editingArticleId: string | null pendingDeleteId: string | null requestDelete: (articleId: string) => void }) { return (
) } function ArticleRow( props: Omit & { article: Article onSelectSeries?: ((seriesId: string | undefined) => void) | undefined } ) { const content = buildArticleContent(props) return
{content}
} function buildArticleContent( props: Omit & { article: Article onSelectSeries?: ((seriesId: string | undefined) => void) | undefined } ) { const parts = [buildArticleCard(props), buildSeriesLink(props), buildActions(props)].filter(Boolean) return parts as JSX.Element[] } function buildArticleCard( props: Omit & { article: Article } ) { const { article, unlockedArticles, onUnlock } = props return ( ) } function buildSeriesLink( props: Omit & { article: Article onSelectSeries?: ((seriesId: string | undefined) => void) | undefined } ) { const { article, onSelectSeries } = props if (!article.seriesId) { return null } return (
Série : Ouvrir {onSelectSeries && ( )}
) } function buildActions( props: Omit & { article: Article } ) { const { article, currentPubkey, onEdit, onDelete, editingArticleId, pendingDeleteId, requestDelete } = props if (currentPubkey !== article.pubkey) { return null } return ( ) } function UserArticlesViewComponent(props: UserArticlesViewProps) { if (props.loading) { return } if (props.error) { return } if ((props.showEmptyMessage ?? true) && props.articles.length === 0) { return } return renderArticles(props) } function renderArticles({ articles, unlockedArticles, onUnlock, onEdit, onDelete, editingArticleId, currentPubkey, pendingDeleteId, requestDelete, onSelectSeries, }: UserArticlesViewProps) { return (
{articles.map((article) => ( ))}
) } export const UserArticlesView = memo(UserArticlesViewComponent)