/**
 * AccountProfileForm component
 *
 * Generated by coz on 2016-10-16,
 * from a template provided by apeman-asset-templates.
 *
 * @function AccountProfileForm
 */
'use strict'

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

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

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

/** @lends AccountProfileForm */
const AccountProfileForm = (props) => {
  let {
    values,
    idOf,
    labels,
    onUpdate,
    onSubmit,
    errorList,
    errorStyle
  } = props

  let formProps = clone(props, {
    without: [ 'labels', 'onUpdate', 'onCancel', 'errors', 'isNew' ]
  })
  return (
    <ApForm { ...formProps }
            centered
            className='account-form'>
      <ApFieldSet plain>
        { errorList }
        { errorStyle }
        <TextField id={ idOf('profile_name')}
                   name='profile.name'
                   label={ labels[ 'profile.name' ] }
                   value={ values[ 'profile.name' ] }
                   onUpdate={ onUpdate }/>
        <UploadField id={ idOf('profile_image') }
                     label={ labels[ 'profile.image' ] }
                     name='profile.image'
                     value={ values[ 'profile.image' ] }
                     onUpdate={ onUpdate }
        />
        <SubmitField id={ idOf('submit')}
                     label={ labels[ 'submit' ] }
                     onSubmit={ onSubmit }
                     values={ values }
        />
      </ApFieldSet>
    </ApForm>
  )
}

export default withForm(AccountProfileForm)
