import React from 'react'
import { Link } from 'react-router-dom'
import { useFormEditorActions } from '../context/FormEditorActionsContext'

/**
 * Vollseiten-Editor: Zurück/Titel oben; FormActionBar fix unten (alle Viewports via FormEditorBottomSlot).
 */
export default function PageFormEditorChrome({
  title,
  backTo,
  backLabel = 'Zurück',
  actionConfig,
  children,
  testId,
}) {
  useFormEditorActions(actionConfig)

  return (
    <div className="page-form-editor" data-testid={testId}>
      <header className="page-form-editor__header">
        {backTo ? (
          <Link to={backTo} className="page-form-editor__back">
            ← {backLabel}
          </Link>
        ) : null}
        <h1 className="page-form-editor__title">{title}</h1>
      </header>
      <div className="page-form-editor__body">{children}</div>
    </div>
  )
}
