import { Card } from '../ui'
import { t } from '@/lib/i18n'
import type { AuthorPresentationArticle, Series } from '@/types/nostr'
import { AuthorPageHeader } from './AuthorPageHeader'
import { SponsoringSummary } from './SponsoringSummary'
import { SeriesList } from './SeriesList'

type AuthorPageContentProps = {
  presentation: AuthorPresentationArticle | null
  series: Series[]
  totalSponsoring: number
  authorPubkey: string
  loading: boolean
  error: string | null
  onSeriesCreated: () => void
}

export function AuthorPageContent({
  presentation,
  series,
  totalSponsoring,
  authorPubkey,
  loading,
  error,
  onSeriesCreated,
}: AuthorPageContentProps): React.ReactElement {
  if (loading) {
    return <p className="text-cyber-accent">{t('common.loading')}</p>
  }

  if (error) {
    return <p className="text-red-400">{error}</p>
  }

  if (!presentation) {
    return (
      <Card variant="default" className="bg-cyber-dark/50">
        <p className="text-cyber-accent">{t('author.notFound')}</p>
      </Card>
    )
  }

  return (
    <>
      <AuthorPageHeader presentation={presentation} />
      <SponsoringSummary totalSponsoring={totalSponsoring} author={presentation} onSponsor={onSeriesCreated} />
      <SeriesList series={series} authorPubkey={authorPubkey} onSeriesCreated={onSeriesCreated} />
    </>
  )
}
