import { useState } from 'react' import { useNostrConnect } from '@/hooks/useNostrConnect' import { useArticlePublishing } from '@/hooks/useArticlePublishing' import type { ArticleDraft } from '@/lib/articlePublisher' import { ArticleEditorForm } from './ArticleEditorForm' interface ArticleEditorProps { onPublishSuccess?: (articleId: string) => void onCancel?: () => void } function NotConnectedMessage() { return (

Please connect with Nostr to publish articles

) } function SuccessMessage() { return (

Article Published!

Your article has been successfully published.

) } export function ArticleEditor({ onPublishSuccess, onCancel }: ArticleEditorProps) { const { connected, pubkey } = useNostrConnect() const { loading, error, success, publishArticle } = useArticlePublishing(pubkey ?? null) const [draft, setDraft] = useState({ title: '', preview: '', content: '', zapAmount: 800, category: undefined, }) const handleSubmit = async (e: React.FormEvent) => { e.preventDefault() const articleId = await publishArticle(draft) if (articleId) { onPublishSuccess?.(articleId) } } if (!connected) { return } if (success) { return } return ( { void handleSubmit(e) }} loading={loading} error={error} onCancel={onCancel} /> ) }