53 lines
1.4 KiB
TypeScript
53 lines
1.4 KiB
TypeScript
import type { Article } from '@/types/nostr'
|
|
import { AuthorCard } from './AuthorCard'
|
|
import { ErrorState, EmptyState } from './ui'
|
|
import { t } from '@/lib/i18n'
|
|
|
|
interface AuthorsListProps {
|
|
authors: Article[]
|
|
allAuthors: Article[]
|
|
loading: boolean
|
|
error: string | null
|
|
}
|
|
|
|
function LoadingState(): React.ReactElement {
|
|
return (
|
|
<div className="text-center py-12">
|
|
<p className="text-cyber-accent/70">{t('common.loading.authors')}</p>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
function AuthorsEmptyState({ hasAny }: { hasAny: boolean }): React.ReactElement {
|
|
return (
|
|
<EmptyState
|
|
title={hasAny ? t('common.empty.authors.filtered') : t('common.empty.authors')}
|
|
/>
|
|
)
|
|
}
|
|
|
|
export function AuthorsList({ authors, allAuthors, loading, error }: AuthorsListProps): React.ReactElement {
|
|
if (loading) {
|
|
return <LoadingState />
|
|
}
|
|
if (error) {
|
|
return <ErrorState message={error} />
|
|
}
|
|
if (authors.length === 0) {
|
|
return <AuthorsEmptyState hasAny={allAuthors.length > 0} />
|
|
}
|
|
|
|
return (
|
|
<>
|
|
<div className="mb-4 text-sm text-cyber-accent/70">
|
|
Showing {authors.length} of {allAuthors.length} author{allAuthors.length !== 1 ? 's' : ''}
|
|
</div>
|
|
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
|
|
{authors.map((author) => (
|
|
<AuthorCard key={author.pubkey} presentation={author} />
|
|
))}
|
|
</div>
|
|
</>
|
|
)
|
|
}
|