import React, {Component} from 'react'
import css from './post.scss'
import Panel from '../../../common/panel/panel'
import Item from './item'

class Group extends Component {
  constructor(props) {
    super(props);
    this.state = {}
  }

  getItem = () => {
    const {data: {result = []},listArr, lang, httpAgent, kw, history, karaui, closeSearchModal,onClose} = this.props
    if (listArr.length === 0) {
      return null
    }
    const li = listArr.map((v, i) => {
      return <Item key={i} {...v} onClose={onClose} lang={lang} httpAgent={httpAgent} kw={kw} history={history} karaui={karaui} closeSearchModal={closeSearchModal}/>
    })
    return <ul className={`${css.list}`}>
      {li}
    </ul>
  }

  onMore = () => {

  }


  render() {
    const {data: {count = 0}, lang, onMore,isLast,isFixed} = this.props
    if(count === 0) {
      return null
    }
    return (<Panel className={css['ks-post']} title={`${lang.msgChat}（${count > 99 ? "99+" :count}${lang.item}）`} onMore={onMore}
               lang={lang} isLast={isLast ? isLast : null} isFixed={isFixed ? isFixed : null}>
          {this.getItem()}
        </Panel>)
  }


}

export default Group;