story-research-zapwall/pages/presentation.tsx
Nicolas Cantu 398b9506e6 Remove duplicate title and description from presentation page
- Remove title and description from pages/presentation.tsx
- Keep title with user name in AuthorPresentationEditor form
- Fix duplicate display issue
2025-12-27 23:56:31 +01:00

59 lines
1.7 KiB
TypeScript

import { useEffect, useCallback } from 'react'
import { useRouter } from 'next/router'
import Head from 'next/head'
import { PageHeader } from '@/components/PageHeader'
import { Footer } from '@/components/Footer'
import { AuthorPresentationEditor } from '@/components/AuthorPresentationEditor'
import { useNostrAuth } from '@/hooks/useNostrAuth'
import { useAuthorPresentation } from '@/hooks/useAuthorPresentation'
import { t } from '@/lib/i18n'
function usePresentationRedirect(connected: boolean, pubkey: string | null) {
const router = useRouter()
const { checkPresentationExists } = useAuthorPresentation(pubkey ?? null)
const redirectIfExists = useCallback(async () => {
if (!connected || !pubkey) {
return
}
const presentation = await checkPresentationExists()
if (presentation) {
await router.push('/')
}
}, [checkPresentationExists, connected, pubkey, router])
useEffect(() => {
void redirectIfExists()
}, [redirectIfExists])
}
function PresentationLayout() {
return (
<>
<Head>
<title>{t('presentation.title')} - {t('home.title')}</title>
<meta
name="description"
content={t('presentation.description')}
/>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" href="/favicon.ico" />
</Head>
<main className="min-h-screen bg-cyber-darker">
<PageHeader />
<div className="max-w-4xl mx-auto px-4 py-8">
<AuthorPresentationEditor />
</div>
<Footer />
</main>
</>
)
}
export default function PresentationPage() {
const { connected, pubkey } = useNostrAuth()
usePresentationRedirect(connected, pubkey)
return <PresentationLayout />
}