export function formatMgmtDate(value) {
  if (!value) return "—";
  const d = new Date(value);
  return Number.isNaN(d.getTime()) ? "—" : d.toLocaleDateString();
}

export function formatMgmtDateTime(value) {
  if (!value) return "—";
  const d = new Date(value);
  return Number.isNaN(d.getTime()) ? "—" : d.toLocaleString();
}

export function mgmtActionColumn({ openView, openUpdate }) {
  return {
    key: "actions",
    label: "Actions",
    render: (r) => (
      <div className="ptw-mgmt-table-actions" onClick={(e) => e.stopPropagation()}>
        <button type="button" className="ptw-mgmt-btn ptw-mgmt-btn--view" onClick={() => openView(r)}>
          View
        </button>
        <button type="button" className="ptw-mgmt-btn ptw-mgmt-btn--edit" onClick={() => openUpdate(r)}>
          Update
        </button>
      </div>
    )
  };
}
