import React, { Component } from 'react';
import { Link } from 'react-router-dom';
import './activity.css';
import { getImageUrl } from 'educoder';


class ActivityItem extends Component {
  render() {
    const { projectsId ,owner } = this.props.match.params;
    const { item } = this.props;
    return (
      <div className="activity_item">
        <div className="flex1">
          {/* 如果是版本发布 */}
          {item.trend_type === "VersionRelease" ?
          <p className="itemLine">
            <Link to={`/${owner}/${projectsId}/releases`} className="color-blue font-16">{item.name}</Link>
            <span className="activity_type">{item.trend_type}</span>
          </p >
          :
          // 如果是任务
          item.trend_type === "Issue" ?
            <p className="itemLine">
              <Link to={`/${owner}/${projectsId}/issues/${item.trend_id}`} className="color-blue font-16">{item.name}</Link>
              <span className="activity_type">{item.trend_type}</span>
            </p >
            :
            // 如果是合并请求
            <p className="itemLine">
              <Link to={`/${owner}/${projectsId}/pulls/${item.trend_id}`} className="color-blue font-16">{item.name}</Link>
              <span className="activity_type">{item.trend_type}</span>
            </p >
          }
          <p className="itemLine mt10">
            <Link to={`/${item && item.user_login}`} className="show-user-link">
              <img alt="" src={getImageUrl(`/${item.user_avatar}`)} className="createImage" />
              <span className="mr20">{item.user_name}</span>
            </Link>
            {item.created_at && <span className="color-grey-9">创建于<span className="ml2 color-grey-6">{item.created_at}</span></span>}
          </p >
        </div>
      </div>
    )
  }
}
export default ActivityItem;