/**
 * SigninForm component
 *
 * Generated by coz on 8/17/2016,
 * from a template provided by apeman-asset-templates.
 *
 * @function SigninForm
 */
'use strict'

import React from 'react'
import defineDebug from 'debug'
import {
  ApSigninForm
} from 'apeman-react-handy'

import { clone } from 'asobj'
import { asLocaled, asServed, combine } from '../../wrappers'

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

/** @lends SigninForm */
const SigninForm = (props) => {
  const noop = () => null
  const {
    onSubmit = noop,
    onSocial = noop,
    onSignup = noop,
    onRecover = noop,
    hideSocial = false,
    labels = {},
    errors = {}
  } = props
  let formProps = clone(props, {
    without: [
      'l',
      'labels',
      'errors',
      'hideSocial',
      'onSocial'
    ]
  })
  let buttons = {
    twitter: () => onSocial('twitter'),
    google: () => onSocial('google'),
    facebook: () => onSocial('facebook')
  }
  return (
    <ApSigninForm { ...formProps }
                  centered
                  className='signin-form'
                  onSubmit={ onSubmit }
                  labels={ labels }
                  errors={ errors }
                  buttons={ !hideSocial && buttons }
                  menu={ {
                    signup: onSignup,
                    recover: onRecover
                  } }
    />
  )
}

export default combine(
  asLocaled.proxy(),
  asServed.proxy()
)(SigninForm)
