import React, { PureComponent } from 'react'
import CommentItem, { CommentItemData } from './CommentItem';
import { Divider } from 'antd';
import styles from './CommentList.less';

interface IP {
  list: Array<CommentItemData>;
  topDivider: boolean;
  onChangeListItem({ commentId, changeProp }: { commentId: string; changeProp: any; }): any;
}

interface IS {

}

export default class CommentList extends PureComponent<IP, IS> {
  render() {
    return (
      <div className={styles.wrapper}>
        {this.props.topDivider ? <Divider /> : null}
        {this.props.list.map((i, index) => {
          return (
            <>
              <CommentItem data={i} onChangeListItem={this.props.onChangeListItem} />
              {index === this.props.list.length - 1 ? null : <Divider />}
            </>
          )
        })}
      </div>
    )
  }
}
