/**
 * SelectField component
 *
 * Generated by coz on 2016-12-30,
 * from a template provided by apeman-asset-templates.
 *
 * @function SelectField
 */
'use strict'

import React from 'react'
import defineDebug from 'debug'
import {
  ApField,
  ApFieldLabel,
  ApFieldValue,
  ApSelect
} from 'apeman-react-basic'

const debug = defineDebug('project:fragment:select-field')

/** @lends SelectField */
const SelectField = ({
  id,
  name,
  label,
  value,
  options,
  onUpdate
}) => (
  <ApField className='select-field'>
    <ApFieldLabel htmlFor={ id }>
      { label }
    </ApFieldLabel>
    <ApFieldValue>
      <ApSelect id={ id }
                value={ value }
                name={ name }
                options={ options }
                onChange={ (e) => onUpdate({ [name]: e.target.value }) }
      />
    </ApFieldValue>
  </ApField>
)

export default SelectField
