/**
 * Created by vison on 16/11/30.
 */
import React from 'react';
import { Col, Row, Button } from '../../components/mxa';
import ImageLink from '../constant/imageLink';

import styles from '../styles/views/home.less';

export default class SysNotification extends React.Component {

  constructor(props) {
    super(props);
    this.state = {
    };
  }

  handleClickNotification = () => {
    console.log('click');
  };

  renderListCell = () => {
    return this.props.dataSource.map(item => {
      return (
        <Row key={item.id} type="flex" align="middle" justify="start" onClick={this.handleClickNotification} className={styles.listItem}>
          <Col className={item.isRead ? styles.badgeNull : styles.badge} />
          <Col>
            <p className={styles.notificationTitle} >{item.NODate}</p>
            <p className={styles.notificationContent} >{item.NOContent}</p>
          </Col>
        </Row>
      );
    });
  };

  renderNotifiList = () => {
    const data = this.props.dataSource;
    if (data && data.length > 0) {
      return (
        <div>
          {this.renderListCell()}
        </div>
      );
    }
    return (
      <Row type="flex" align="middle" justify="start">
        <img src={ImageLink.home_notification_null} alt="暂无消息" />
      </Row>
    );
  };

  render() {
    return (
      <div className={styles.notification} >
        <Row type="flex" align="middle" justify="start" className={styles.commonTitle}>
          <Col className={styles.highLight} />
          <span>通知消息</span>
        </Row>
        {this.renderNotifiList()}
      </div>
    );
  }
}
