// Page Create / edit header phiếu Duyệt NCC riêng (deep-link "Sửa header"
// button trong PeDetailTabs). Refactor 2026-05-07: wrap PeHeaderForm cho DRY
// + auto support manual budget (Mig 17). NCC + Báo giá + Items vẫn chỉnh ở
// Detail tabs sau khi save.
import { useNavigate, useSearchParams } from 'react-router-dom'
import { ClipboardCheck } from 'lucide-react'
import { PeHeaderForm } from '@/components/pe/PeHeaderForm'
import { PurchaseEvaluationType } from '@/types/purchaseEvaluation'

export function PurchaseEvaluationCreatePage() {
  const navigate = useNavigate()
  const [sp] = useSearchParams()
  const editId = sp.get('id')
  const urlType = sp.get('type') ? Number(sp.get('type')) : PurchaseEvaluationType.DuyetNcc

  return (
    <div className="space-y-4 p-6">
      <header className="flex items-center gap-2">
        <ClipboardCheck className="h-5 w-5 text-slate-500" />
        <h1 className="text-base font-semibold tracking-tight text-slate-900">
          {editId ? 'Sửa phiếu Duyệt NCC' : 'Tạo phiếu Duyệt NCC mới'}
        </h1>
      </header>

      <PeHeaderForm
        editId={editId}
        defaultType={urlType}
        onSaved={(id, type) => navigate(`/purchase-evaluations?id=${id}&type=${type}`)}
        onCancel={() => navigate(-1)}
      />
    </div>
  )
}
