/**
 * BanForm component
 *
 * Generated by coz on 2017-01-04,
 * from a template provided by apeman-asset-templates.
 *
 * @function BanForm
 */
'use strict'

import React from 'react'
import defineDebug from 'debug'
import { clone } from 'asobj'
import {
  ApForm,
  ApText,
  ApButton,
  withForm
} from 'apeman-react-basic'
import { IconClasses } from 'ore-fol-enums'
import SelectField from '../fields/select_field'
import TextField from '../fields/text_field'
import ValueField from '../fields/value_field'
import SubmitField from '../fields/submit_field'

const debug = defineDebug('project:fragment:ban-form')
const { BAN_ICON } = IconClasses

/** @lends BanForm */
const BanForm = (props) => {
  let {
    values,
    labels,
    placeholders = {},
    target,
    types,
    onUpdate,
    onSubmit,
    errorList,
    idOf,
    errorStyle
  } = props
  let formProps = clone(props, {
    without: [
      'target',
      'types',
      'onUpdate',
      'onSubmit',
      'onCancel',
      'placeholders',
      'errors',
      'labels'
    ]
  })
  return (
    <ApForm { ...formProps }
            className='ban-form'>
      { errorList }
      { errorStyle }
      <div className="ban-form-inner">
        <SelectField id={ idOf('type') }
                     name='type'
                     value={ values.type }
                     label={ labels.type }
                     options={ types }
                     onUpdate={ onUpdate }
        />
        <ValueField id={ idOf('target')}
                    name='target'
                    value={ target }
                    label={ labels.target }
        />
        <TextField id={ idOf('reason') }
                   label={ labels.reason }
                   name='reason'
                   value={ values.reason }
                   rows={ 5 }
                   placeholder={ placeholders.ban }
                   onUpdate={ onUpdate }
        />
        <SubmitField id={ idOf('submit')}
                     label={ labels.submit }
                     onSubmit={ onSubmit }
                     values={ values }
        />
      </div>
    </ApForm>
  )
}

export default withForm(BanForm)
