import React from "react"
import { ModalConfimProps } from "../interface"
import "./index.css"

import { Modal as AuiModal } from "@atomintl/aui-next"
import ModalHead from "@components/Modal/Head"
import ModalContent from "@components/Modal/Content"
import ModalActions from "@components/Modal/Actions"

export const ntsConfirm = (props: ModalConfimProps) => {
  const { hideHead, hideActions, content, onCancel, onOk, onClose, classes } = props

  return AuiModal.confirm({
    header: hideHead ? null : <ModalHead {...props} className={classes?.head} />,

    onClose,

    content: () => <ModalContent classes={classes}>{content}</ModalContent>,

    footer: hideActions ? null : (
      <ModalActions {...props} className={classes?.actions} onCancel={onCancel} onOk={onOk} />
    ),
    PaperProps: { className: "nts-modal-body-hw-center" }
  })
}

export { ModalConfimProps } from "../interface"

export function withConfirm(props: ModalConfimProps): ModalConfimProps {
  return {
    type: "confirm",
    ...props
  }
}

// class NtsConfirm {
//   constructor() {}

//   confirm(props: ModalConfimProps) {
//     const { hideHead, hideActions, content, onCancel, onOk, onClose, classes } = props

//     return AuiModal.confirm({
//       title: hideHead ? null : <ModalHead {...props} className={classes?.head} />,

//       onClose,

//       content: () => <ModalContent classes={classes}>{content}</ModalContent>,

//       footer: hideActions ? null : (
//         <ModalActions {...props} className={classes?.actions} onCancel={onCancel} onOk={onOk} />
//       ),
//       PaperProps: { className: "nts-modal-body-hw-center" }
//     })
//   }
// }

// export default new NtsConfirm()
