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

const NewDocumentSize = ({ onOk, defaultValues }) => {
  return (
    <NewObjectForm
      type={'documentSize'}
      defaultValues={{ infiniteHeight: false, ...defaultValues }}
    >
      {({ handleSubmit, submitLoading, objectData, formValid }) => {
        const steps = [
          {
            title: 'Required',
            key: 'required',
            content: (
              <ObjectInfo
                type='documentSize'
                column={1}
                bordered={false}
                isEditing={true}
                required={true}
                objectData={objectData}
                labelWidth={120}
              />
            )
          },
          {
            title: 'Summary',
            key: 'summary',
            content: (
              <ObjectInfo
                type='documentSize'
                column={1}
                bordered={false}
                visibleProperties={{
                  _id: false,
                  _reference: false,
                  createdAt: false,
                  updatedAt: false
                }}
                labelWidth={120}
                isEditing={false}
                objectData={objectData}
              />
            )
          }
        ]
        return (
          <WizardView
            steps={steps}
            loading={submitLoading}
            formValid={formValid}
            title='New Document Size'
            onSubmit={async () => {
              const result = await handleSubmit()
              if (result) {
                onOk()
              }
            }}
          />
        )
      }}
    </NewObjectForm>
  )
}

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

export default NewDocumentSize
