import { reduxForm } from 'redux-form'

import CheckInForm from '../components/CheckInForm'
import { updateInfo, clearInfo } from '../modules/check-in'

const fields = [
  'firstName',
  'lastName',
  'socialSecurityNumber',
  'dateOfBirth',
  'phoneNumber',
  'emailAddress',

  'gender',
  'isTransexual',
  'isLGBTQ',

  'ethnicity',
  'ethnicityOther',

  'language',
  'languageOther',

  'hasBeenInFosterCare',

  'hasServedInTheMilitary',

  'primaryHealthcareLocation',

  'isHomeless',
  'lengthOfHomelessness',

  'medicalServices',
  'supportServices',
]

const validate = (values) => {
  const errors = {}
  // if (!values.firstName) {
  //   errors.firstName = 'Required'
  // }
  //
  // if (!values.lastName) {
  //   errors.lastName = 'Required'
  // }
  //
  // if (!values.dateOfBirth) {
  //   errors.dateOfBirth = 'Required'
  // }

  return errors
}


const mapStateToProps = (state) => ({
  initialValues: state.checkIn.primaryInfo,
})

const mapDispatchToProps = (dispatch) => ({
  updateInfo: (fields) => dispatch(updateInfo(fields)),
  clearInfo: () => dispatch(clearInfo()),
})

export default reduxForm({
  form: 'checkIn',
  fields,
  validate,
},
mapStateToProps,
mapDispatchToProps
)(CheckInForm)

@@ -612,19 +612,16 @@
 s = %7B%7D%0A 
- //
  if (!va
@@ -631,35 +631,32 @@
 s.firstName) %7B%0A 
- //
    errors.firstN
@@ -670,38 +670,28 @@
 Required'%0A  
-// %7D%0A  //%0A  //
+%7D%0A%0A 
  if (!values
@@ -700,27 +700,24 @@
 astName) %7B%0A 
- //
    errors.la
@@ -742,54 +742,151 @@
 '%0A  
-// %7D%0A  //%0A  //
+%7D%0A%0A  if (!values.socialSecurityNumber) %7B%0A    errors.socialSecurityNumber = 'Required'%0A  %7D else
  if (
-!
 values.
-dateOfBirth
+socialSecurityNumber.length %3C 11
 ) %7B%0A 
- //
    e
@@ -895,37 +895,200 @@
 ors.
-dateOfBirth = 'Required'%0A  //
+socialSecurityNumber = 'Incomplete'%0A  %7D%0A%0A  if (!values.phoneNumber) %7B%0A    errors.phoneNumber = 'Required'%0A  %7D else if (values.phoneNumber.length %3C 14) %7B%0A    errors.phoneNumber = 'Incomplete'%0A 
  %7D%0A%0A

use new normalizers for some validation