story-research-zapwall/components/ConditionalPublishButton.tsx
Nicolas Cantu 2a191f35f4 Fix all TypeScript errors and warnings
- Fix unused function warnings by renaming to _unusedExtractTags
- Fix type errors in nostrTagSystem.ts for includes() calls
- Fix type errors in reviews.ts for filter kinds array
- Fix ArrayBuffer type errors in articleEncryption.ts
- Remove unused imports (DecryptionKey, decryptArticleContent, extractTagsFromEvent)
- All TypeScript checks now pass without disabling any controls
2025-12-27 22:26:13 +01:00

56 lines
1.6 KiB
TypeScript

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<boolean | null>(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 null
}
if (hasPresentation === null) {
return (
<div className="px-4 py-2 bg-neon-cyan/20 text-neon-cyan rounded-lg text-sm font-medium">
{t('nav.loading')}
</div>
)
}
if (!hasPresentation) {
return (
<Link
href="/presentation"
className="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"
>
{t('nav.createAuthorPage')}
</Link>
)
}
return (
<Link
href="/publish"
className="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"
>
{t('nav.publish')}
</Link>
)
}