- **Motivations :** Assurer passage du lint strict et clarifier la logique paiements/publications. - **Root causes :** Fonctions trop longues, promesses non gérées et typages WebLN/Nostr incomplets. - **Correctifs :** Refactor PaymentModal (handlers void), extraction helpers articlePublisher, simplification polling sponsoring/zap, corrections curly et awaits. - **Evolutions :** Nouveau module articlePublisherHelpers pour présentation/aiguillage contenu privé. - **Page affectées :** components/PaymentModal.tsx, lib/articlePublisher.ts, lib/articlePublisherHelpers.ts, lib/paymentPolling.ts, lib/sponsoring.ts, lib/nostrZapVerification.ts et dépendances liées.
65 lines
1.7 KiB
TypeScript
65 lines
1.7 KiB
TypeScript
import Head from 'next/head'
|
|
import { useRouter } from 'next/router'
|
|
import { ConnectButton } from '@/components/ConnectButton'
|
|
import { ArticleEditor } from '@/components/ArticleEditor'
|
|
|
|
function PublishHeader() {
|
|
return (
|
|
<Head>
|
|
<title>Publish Article - zapwall4Science</title>
|
|
<meta name="description" content="Publish a new article with free preview and paid content" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
</Head>
|
|
)
|
|
}
|
|
|
|
function PublishHero({ onBack }: { onBack: () => void }) {
|
|
return (
|
|
<div className="mb-6">
|
|
<button
|
|
onClick={onBack}
|
|
className="text-blue-600 hover:text-blue-700 text-sm font-medium mb-4"
|
|
>
|
|
← Back to Articles
|
|
</button>
|
|
<h2 className="text-3xl font-bold">Publish New Article</h2>
|
|
<p className="text-gray-600 mt-2">Create an article with a free preview and paid full content</p>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export default function PublishPage() {
|
|
const router = useRouter()
|
|
|
|
const handlePublishSuccess = () => {
|
|
setTimeout(() => {
|
|
void router.push('/')
|
|
}, 2000)
|
|
}
|
|
|
|
return (
|
|
<>
|
|
<PublishHeader />
|
|
|
|
<main className="min-h-screen bg-gray-50">
|
|
<header className="bg-white shadow-sm">
|
|
<div className="max-w-4xl mx-auto px-4 py-4 flex justify-between items-center">
|
|
<h1 className="text-2xl font-bold text-gray-900">zapwall4Science</h1>
|
|
<ConnectButton />
|
|
</div>
|
|
</header>
|
|
|
|
<div className="max-w-4xl mx-auto px-4 py-8">
|
|
<PublishHero
|
|
onBack={() => {
|
|
void router.push('/')
|
|
}}
|
|
/>
|
|
|
|
<ArticleEditor onPublishSuccess={handlePublishSuccess} />
|
|
</div>
|
|
</main>
|
|
</>
|
|
)
|
|
}
|