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

import React from 'react'
import defineDebug from 'debug'
import Card from './card'
import ThreadLink from '../links/thread_link'
import PostCardStyle from '../styles/post_card_style'
import { asPure, asServed, asLocaled, combine } from '../../wrappers'

const debug = defineDebug('project:fragment:post-card')

/** @lends PostCard */
const PostCard = ({
  l,
  srvc,
  post
}) => {
  const { userNameString, dateString } = srvc.localeService
  let styleElm = (
    <PostCardStyle prefix={ `#post-card-${post.id}` }
                   color={ post.thread.color }/>
  )
  return (
    <Card className='post-card'
          styleElm={ styleElm }
          image={ post.image}
          id={ `post-card-${post.id}` }
          info={ {
            [ l('labels.POST_TEXT') ]: post.text,
            [ l('labels.POST_SUBMITTER') ]: userNameString(post.submitter),
            [ l('labels.POST_AT') ]: dateString(post.createdAt),
            [ l('labels.POST_THREAD') ]: (<ThreadLink thread={ post.thread }/> )
          } }
    >
    </Card>
  )
}

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