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

const NewNote = ({ onOk, defaultValues = {} }) => {
  return (
    <NewObjectForm type={'note'} defaultValues={defaultValues}>
      {({ handleSubmit, submitLoading, objectData, formValid }) => {
        const steps = [
          {
            title: 'Required',
            key: 'required',
            content: (
              <ObjectInfo
                type='note'
                column={1}
                visibleProperties={{ 'parent._id': false }}
                bordered={false}
                isEditing={true}
                required={true}
                labelWidth='100px'
                objectData={objectData}
              />
            )
          }
        ]
        return (
          <WizardView
            steps={steps}
            showSteps={false}
            loading={submitLoading}
            formValid={formValid}
            title='New Note'
            onSubmit={async () => {
              const result = await handleSubmit()
              if (result) {
                onOk()
              }
            }}
          />
        )
      }}
    </NewObjectForm>
  )
}

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

export default NewNote
