import { useState, type FC } from 'react' import type { Commentary, EditorialInfo } from '../lib/api.ts' import { STATUS_LABELS, STATUS_VARIANTS } from '../lib/editorial.ts' import { RetroBadge, RetroButton } from './retro' interface Props { commentary: Commentary | null editorial: EditorialInfo visiblePublic: boolean visibleScholarly: boolean } const CommentaryPanel: FC = ({ commentary, editorial, visiblePublic, visibleScholarly }) => { const [tab, setTab] = useState<'public' | 'scholarly'>('public') if (!visiblePublic && !visibleScholarly) return null const activeTab: 'public' | 'scholarly' = !visiblePublic && visibleScholarly ? 'scholarly' : !visibleScholarly && visiblePublic ? 'public' : tab const content = activeTab === 'public' ? commentary?.public : commentary?.scholarly const bothVisible = visiblePublic && visibleScholarly return (
Commentaire {STATUS_LABELS[editorial.status]}
{bothVisible && (
setTab('public')} > Public setTab('scholarly')} > Savant
)} {content ? (

{content}

) : (

Commentaire non disponible.

)}
) } export default CommentaryPanel