/**
 * AboutDocument view
 *
 * Generated by coz on 2016-11-11,
 * from a template provided by apeman-asset-templates.
 *
 * @function AboutDocumentView
 */
'use strict'

import React, { Component, PropTypes as types } from 'react'
import defineDebug from 'debug'
import {
  ApView, ApViewHeader, ApViewBody, ApViewFooter
} from 'apeman-react-basic'
import tmpls from '../../templates'
import { ApMarkdown } from 'apeman-react-markdown'
import { asConnected, asView, asLocaled, asServed, forSpin, combine } from '../../wrappers'
const debug = defineDebug('project:view:about-document')

/** @lends AboutDocumentView */
class AboutDocumentView extends Component {
  // --------------------
  // Specs
  // --------------------
  static get propTypes () {
    return {
      /** Variables for template */
      vars: types.object
    }
  }

  static get defaultProps () {
    return {
      vars: {}
    }
  }

  render () {
    const s = this
    const {
      props,
      l
    } = s
    let { tmpl, vars } = props
    return (
      <ApView id='about-document-view'
              className='view'
              spinning={ props.spinning }
              way={ props.way }
      >
        <ApViewHeader onLeftTap={ s.handlePop }
                      leftText={ null }
                      leftIcon={ props.popIcon }
                      titleText={ null }
                      titleIcon={ null }
                      onRightTap={ null }
                      rightIcon={ null }
                      rightText={ null }
        />

        <ApViewBody>
          <div style={ { padding: 8 } }>
            {
              tmpl ? (
                  <ApMarkdown src={ tmpl(vars) }/>
                ) : (
                  <p className='page-alt'>{ l('alt.PAGE_NOT_FOUND') }</p>
                )
            }
          </div>
        </ApViewBody>
      </ApView>
    )
  }

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

}

export default combine(
  asServed(),
  forSpin(),
  asLocaled(),
  asView(),
  asConnected((state, { template, srvc }) => {
    const { getLang } = srvc.localeService
    return {
      tmpl: template && tmpls(`${template}_${getLang()}`)
    }
  })
)(AboutDocumentView)

