/**
 * PostCommentsButton component
 *
 * Generated by coz on 2016-12-29,
 * from a template provided by apeman-asset-templates.
 *
 * @function PostCommentsButton
 */
'use strict'

import React from 'react'
import { ApButton } from 'apeman-react-basic'
import { IconClasses } from 'ore-fol-enums'
import classnames from 'classnames'
import { asPure, asLocaled, asServed, combine } from '../../wrappers'

const {
  COMMENTS_ICON
} = IconClasses

import defineDebug from 'debug'

const debug = defineDebug('project:fragment:comments-button')

/** @lends PostCommentsButton */
const PostCommentsButton = ({
  srvc,
  post,
  onTap
}) => {
  const { countString } = srvc.localeService
  const { commentsUrlForPost } = srvc.urlService

  return (
    <ApButton className='comments-button'
              onTap={ onTap }
              href={ commentsUrlForPost(post) }
              onClick={ (e) => e.preventDefault() }
    >
      <i className={ classnames('comments-button-icon', COMMENTS_ICON) }/>
      <span className="comments-button-text">
      { countString(post.commentCount) }
    </span>
    </ApButton>
  )
}

export default combine(
  asPure(),
  asLocaled.proxy(),
  asServed.proxy()
)(PostCommentsButton)
