import React, { Component } from 'react'
import { actionTypes, actions } from '../actions'
import { connect } from 'react-redux'
import { withRouter } from 'react-router-dom'
import { createPost } from 'actions-api'
import SelectField from 'material-ui/SelectField'
import MenuItem from 'material-ui/MenuItem'
import TextField from 'material-ui/TextField'
import Drawer from 'material-ui/Drawer'
import v from 'actions-validations'
import inputs from 'actions-client-inputs'
import op from 'object-path'

// Application
export const initState = {
  fields: { category: 'EVENT', meta: {} },
  errors: {},
  results: []
}

export const reducer = (state = initState, { type, payload }) => {
  switch (type) {
    case actionTypes.ADMIN_POST_UPDATE_VALUE:
      let newValues = {}
      op.set(newValues, payload.name, payload.value)
      return Object.assign({}, state, {
        fields: Object.assign({}, state.fields, newValues)
      });
    case actionTypes.ADMIN_POST_FORM_RESET:
      return Object.assign({}, initState);
    case actionTypes.ADMIN_POST_FORM_ERROR:
      return Object.assign({}, state, { errors:payload })
    default:return state
  }
}


// Content
export default class Admin extends React.Component {

  logout() {
    return <button className="fr" onClick={this.props.logout}>Logout</button>
  }

  render() {
    return <div>
      Hi
    </div>
  }
}

// export default withRouter(connect(state => state, actions)(Home))
