import { ArticleEditorForm } from './ArticleEditorForm'
import type { ArticleDraft } from '@/lib/articlePublisher'

interface EditPanelProps {
  draft: ArticleDraft | null
  editingArticleId: string | null
  loading: boolean
  error: string | null
  onCancel: () => void
  onDraftChange: (draft: ArticleDraft) => void
  onSubmit: () => void
}

export function EditPanel({
  draft,
  editingArticleId,
  loading,
  error,
  onCancel,
  onDraftChange,
  onSubmit,
}: EditPanelProps) {
  if (!draft || !editingArticleId) {
    return null
  }
  return (
    <div className="border rounded-lg p-4 bg-white space-y-3">
      <h3 className="text-lg font-semibold">Edit article</h3>
      <ArticleEditorForm
        draft={draft}
        onDraftChange={onDraftChange}
        onSubmit={(e) => {
          e.preventDefault()
          onSubmit()
        }}
        loading={loading}
        error={error}
        onCancel={onCancel}
      />
    </div>
  )
}
