import PropTypes from 'prop-types'
import ObjectInfo from '../../common/ObjectInfo'
import NewObjectForm from '../../common/NewObjectForm'
import WizardView from '../../common/WizardView'

const NewDocumentPrinter = ({ onOk, defaultValues }) => {
  return (
    <NewObjectForm
      type={'documentPrinter'}
      defaultValues={{ active: true, global: false, ...defaultValues }}
    >
      {({ handleSubmit, submitLoading, objectData, formValid }) => {
        const steps = [
          {
            title: 'Required',
            key: 'required',
            content: (
              <ObjectInfo
                type='documentPrinter'
                column={1}
                bordered={false}
                isEditing={true}
                required={true}
                labelWidth={100}
                objectData={objectData}
              />
            )
          },
          {
            title: 'Optional',
            key: 'optional',
            content: (
              <ObjectInfo
                type='documentPrinter'
                column={1}
                bordered={false}
                isEditing={true}
                required={false}
                labelWidth={125}
                visibleProperties={{ content: false, testObject: false }}
                objectData={objectData}
              />
            )
          },
          {
            title: 'Summary',
            key: 'summary',
            content: (
              <ObjectInfo
                type='documentPrinter'
                column={1}
                bordered={false}
                visibleProperties={{
                  _id: false,
                  _reference: false,
                  createdAt: false,
                  connectedAt: false,
                  state: false,
                  online: false,
                  updatedAt: false
                }}
                labelWidth={130}
                isEditing={false}
                objectData={objectData}
              />
            )
          }
        ]

        return (
          <WizardView
            steps={steps}
            loading={submitLoading}
            formValid={formValid}
            title='New Document Printer'
            onSubmit={async () => {
              const result = await handleSubmit()
              if (result) {
                onOk()
              }
            }}
          />
        )
      }}
    </NewObjectForm>
  )
}

NewDocumentPrinter.propTypes = {
  onOk: PropTypes.func.isRequired,
  reset: PropTypes.bool,
  defaultValues: PropTypes.object
}

export default NewDocumentPrinter
