/**
 * AccountEmailForm component
 *
 * Generated by coz on 2016-11-08,
 * from a template provided by apeman-asset-templates.
 *
 * @function AccountEmailForm
 */
'use strict'

import React from 'react'
import {
  ApForm,
  ApFieldSet,
  withForm
} from 'apeman-react-basic'
import defineDebug from 'debug'
import { clone } from 'asobj'

import TextField from '../fields/text_field'
import SubmitField from '../fields/submit_field'

const debug = defineDebug('project:fragment:account-email-form')

/** @lends AccountEmailForm */
const AccountEmailForm = (props) => {
  const {
    labels,
    values,
    idOf,
    onUpdate,
    onSubmit,
    errorList,
    errorStyle
  } = props
  let formProps = clone(props, {
    without: [ 'onUpdate', 'onCancel', 'errors' ]
  })
  return (
    <ApForm { ...formProps }
            centered
            className='account-email-form inline-form'
    >
      <ApFieldSet plain>
        { errorList }
        { errorStyle }
        <TextField id={ idOf('email') }
                   label={ labels.email }
                   name='email'
                   value={ values.email }
                   onUpdate={ onUpdate }
        />
        <SubmitField id={ idOf('submit')}
                     label={ labels.submit }
                     onSubmit={ onSubmit }
                     values={ values }
        />
      </ApFieldSet>
    </ApForm>
  )
}

export default withForm(AccountEmailForm)

