79 lines
2.3 KiB
TypeScript
79 lines
2.3 KiB
TypeScript
import { Card, Skeleton } 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
|
|
}
|
|
|
|
function AuthorPageLoadingSkeleton(): React.ReactElement {
|
|
return (
|
|
<div className="space-y-6">
|
|
<div className="space-y-4">
|
|
<Skeleton variant="rectangular" height={32} className="w-1/3" />
|
|
<Skeleton variant="rectangular" height={200} className="w-full" />
|
|
</div>
|
|
<div className="space-y-4">
|
|
<Skeleton variant="rectangular" height={24} className="w-1/4" />
|
|
<Skeleton variant="rectangular" height={100} className="w-full" />
|
|
</div>
|
|
<div className="space-y-4">
|
|
<Skeleton variant="rectangular" height={24} className="w-1/4" />
|
|
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
|
{Array.from({ length: 2 }).map((_, index) => (
|
|
<Skeleton key={index} variant="rectangular" height={150} className="w-full" />
|
|
))}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
function AuthorPageError({ error }: { error: string }): React.ReactElement {
|
|
return <p className="text-red-400">{error}</p>
|
|
}
|
|
|
|
function AuthorPageNotFound(): React.ReactElement {
|
|
return (
|
|
<Card variant="default" className="bg-cyber-dark/50">
|
|
<p className="text-cyber-accent">{t('author.notFound')}</p>
|
|
</Card>
|
|
)
|
|
}
|
|
|
|
export function AuthorPageContent({
|
|
presentation,
|
|
series,
|
|
totalSponsoring,
|
|
authorPubkey,
|
|
loading,
|
|
error,
|
|
onSeriesCreated,
|
|
}: AuthorPageContentProps): React.ReactElement {
|
|
if (loading) {
|
|
return <AuthorPageLoadingSkeleton />
|
|
}
|
|
if (error) {
|
|
return <AuthorPageError error={error} />
|
|
}
|
|
if (!presentation) {
|
|
return <AuthorPageNotFound />
|
|
}
|
|
return (
|
|
<>
|
|
<AuthorPageHeader presentation={presentation} />
|
|
<SponsoringSummary totalSponsoring={totalSponsoring} author={presentation} onSponsor={onSeriesCreated} />
|
|
<SeriesList series={series} authorPubkey={authorPubkey} onSeriesCreated={onSeriesCreated} />
|
|
</>
|
|
)
|
|
}
|