/**
 * AdminTop view
 *
 * Generated by coz on 10/29/2016,
 * from a template provided by apeman-asset-templates.
 *
 * @function AdminTopView
 */
'use strict'

import React, { Component, PropTypes as types } from 'react'
import defineDebug from 'debug'
import {
  ApView, ApViewBody,
  ApButton
} from 'apeman-react-basic'
import { asView, asConnected, asLocaled, asServed, forSpin, combine } from '../../wrappers'

const debug = defineDebug('project:view:admin-top')

/** @lends AdminTopView */
class AdminTopView extends Component {
  // --------------------
  // Specs
  // --------------------
  static get propTypes () {
    return {}
  }

  static get defaultProps () {
    return {}
  }

  render () {
    const s = this
    const {
      props,
      l
    } = s
    return (
      <ApView id='admin-top-view'
              className='view'
              spinning={ props.spinning }
              way={ props.way }
      >
        <ApViewBody>
          <div className='admin-menu'>
            {
              [
                [ l('buttons.SHOW_USER_MANAGE'), s.handleUser ],
                [ l('buttons.SHOW_NEWS_MANAGE'), s.handleNews ],
                [ l('buttons.SHOW_REPORT_MANAGE'), s.handleReport ],
                [ l('buttons.SHOW_SERVER_MANAGE'), s.handleServer ]
              ].map(([ title, onTap ]) => (
                <div className='admin-menu-item' key={ title }>
                  <ApButton onTap={ onTap }> { title } </ApButton>
                </div>
              ))
            }
          </div>
        </ApViewBody>
      </ApView>
    )
  }

  // --------------------
  // Lifecycle
  // --------------------

  componentWillMount () {
    debug('willMount')
    const s = this
  }

  componentDidMount () {
    debug('didMount')
    const s = this
  }

  componentWillUnmount () {
    debug('willUnmount')
    const s = this
  }

  // --------------------
  // Handlers
  // --------------------

  handleUser () {
    const s = this
    s.handlePush('AdminUserList')
  }

  handleNews () {
    const s = this
    s.handlePush('AdminNewsList')
  }

  handleReport () {
    const s = this
    s.handlePush('AdminReportList')
  }

  handleServer () {
    const s = this
    s.handlePush('AdminServerInfo')
  }

  // --------------------
  // For redux
  // --------------------
  static mapStateToProps (state, ownProps) {
    return {}
  }

}

export default combine(
  asLocaled(),
  forSpin(),
  asView(),
  asConnected(),
  asServed()
)(AdminTopView)
