import Link from 'next/link' import { useNostrConnect } from '@/hooks/useNostrConnect' import { useAuthorPresentation } from '@/hooks/useAuthorPresentation' import { useEffect, useState } from 'react' import { t } from '@/lib/i18n' export function ConditionalPublishButton() { const { connected, pubkey } = useNostrConnect() const { checkPresentationExists } = useAuthorPresentation(pubkey ?? null) const [hasPresentation, setHasPresentation] = useState(null) useEffect(() => { const check = async () => { if (!connected || !pubkey) { setHasPresentation(null) return } const presentation = await checkPresentationExists() setHasPresentation(presentation !== null) } void check() }, [connected, pubkey, checkPresentationExists]) if (!connected || !pubkey) { return ( {t('nav.createAuthorPage')} ) } if (hasPresentation === null) { return (
{t('nav.loading')}
) } if (!hasPresentation) { return ( {t('nav.createAuthorPage')} ) } return ( {t('nav.publish')} ) }