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

import React from 'react'
import {
  ApForm,
  ApFieldSet,
  withForm
} from 'apeman-react-basic'
import defineDebug from 'debug'
import { clone } from 'asobj'
import PasswordField from '../fields/password_field'
import SubmitField from '../fields/submit_field'

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

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