import Link from 'next/link' import Image from 'next/image' import { useNostrAuth } from '@/hooks/useNostrAuth' import { useAuthorPresentation } from '@/hooks/useAuthorPresentation' import { useEffect, useState } from 'react' import { t } from '@/lib/i18n' import type { Article } from '@/types/nostr' const buttonClassName = 'px-4 py-2 bg-neon-cyan/20 hover:bg-neon-cyan/30 text-neon-cyan rounded-lg text-sm font-medium transition-all border border-neon-cyan/50 hover:shadow-glow-cyan' function CreateAuthorPageLink() { return ( {t('nav.createAuthorPage')} ) } function PublishLink() { return ( {t('nav.publish')} ) } function LoadingButton() { return (
{t('nav.loading')}
) } function AuthorProfileLink({ presentation, profile }: { presentation: Article; profile: { name?: string; picture?: string } | null }) { const authorName = presentation.title.replace(/^Présentation de /, '') || profile?.name || 'Auteur' const picture = presentation.bannerUrl || profile?.picture return ( {picture ? (
{authorName}
) : (
{authorName.charAt(0).toUpperCase()}
)} {authorName} ) } export function ConditionalPublishButton() { const { connected, pubkey, profile } = useNostrAuth() const { checkPresentationExists } = useAuthorPresentation(pubkey ?? null) const [presentation, setPresentation] = useState
(null) const [loading, setLoading] = useState(false) useEffect(() => { const check = async () => { if (!connected || !pubkey) { setPresentation(null) setLoading(false) return } setLoading(true) const pres = await checkPresentationExists() setPresentation(pres) setLoading(false) } void check() }, [connected, pubkey, checkPresentationExists]) if (!connected || !pubkey) { return } if (loading) { return } if (!presentation) { return } // If presentation exists, show author profile link instead of publish button return }