2017-08-11 19:30:12 +08:00
|
|
|
import './ProjectCard.scss';
|
|
|
|
import React, { Component } from 'react';
|
2017-08-19 15:18:55 +08:00
|
|
|
import { Card, Icon, Tooltip, message } from 'antd';
|
|
|
|
import { connect } from 'react-redux'
|
|
|
|
import { delFollow } from '../../reducer/modules/follow';
|
|
|
|
// import { Link } from 'react-router-dom';
|
2017-08-11 19:30:12 +08:00
|
|
|
import PropTypes from 'prop-types';
|
2017-08-20 17:22:04 +08:00
|
|
|
import { withRouter } from 'react-router'
|
2017-08-10 15:36:35 +08:00
|
|
|
|
2017-08-19 15:18:55 +08:00
|
|
|
@connect(
|
|
|
|
() => {
|
|
|
|
return {}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
delFollow
|
|
|
|
}
|
|
|
|
)
|
2017-08-20 17:22:04 +08:00
|
|
|
@withRouter
|
2017-08-11 17:47:25 +08:00
|
|
|
class ProjectCard extends Component {
|
2017-08-10 15:36:35 +08:00
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
}
|
|
|
|
|
|
|
|
static propTypes = {
|
2017-08-19 15:18:55 +08:00
|
|
|
projectData: PropTypes.object,
|
|
|
|
isFollowed: PropTypes.bool,
|
|
|
|
callbackResult: PropTypes.func,
|
2017-08-20 17:22:04 +08:00
|
|
|
history: PropTypes.object,
|
2017-08-19 15:18:55 +08:00
|
|
|
delFollow: PropTypes.func
|
|
|
|
}
|
|
|
|
|
|
|
|
del = () => {
|
|
|
|
console.log('del');
|
|
|
|
const id = this.props.projectData.projectid;
|
|
|
|
this.props.delFollow(id).then((res) => {
|
|
|
|
if (res.payload.data.errcode === 0) {
|
|
|
|
this.props.callbackResult();
|
|
|
|
message.success('已取消关注!');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
add() {
|
|
|
|
console.log('add');
|
2017-08-10 15:36:35 +08:00
|
|
|
}
|
2017-08-19 15:18:55 +08:00
|
|
|
// <Link to={`/project/${projectData._id}`} className="card-link">
|
|
|
|
//
|
|
|
|
// </Link>
|
2017-08-10 15:36:35 +08:00
|
|
|
|
2017-08-19 15:18:55 +08:00
|
|
|
// <Popconfirm placement="leftBottom" title={<Icon type="up" />} onConfirm={confirm} okText="确认" cancelText="取消">
|
|
|
|
// <Icon type="star-o" className="icon" onClick={this.clickHandle}/>
|
|
|
|
// </Popconfirm>
|
2017-08-10 15:36:35 +08:00
|
|
|
render() {
|
2017-08-19 15:18:55 +08:00
|
|
|
const { projectData, isFollowed } = this.props;
|
2017-08-10 15:36:35 +08:00
|
|
|
return (
|
2017-08-19 15:18:55 +08:00
|
|
|
<div className="card-container">
|
2017-08-20 17:22:04 +08:00
|
|
|
<Card bordered={false} bodyStyle={{padding: 16}} className="m-card" onClick={() => this.props.history.push('/project/' + projectData._id)}>
|
2017-08-11 19:30:12 +08:00
|
|
|
<div className="m-card-logo">
|
|
|
|
<Icon type="area-chart" className="icon" />
|
2017-08-15 12:08:59 +08:00
|
|
|
<p className="name">{projectData.name || projectData.projectname}</p>
|
2017-08-11 19:30:12 +08:00
|
|
|
</div>
|
|
|
|
</Card>
|
2017-08-19 15:18:55 +08:00
|
|
|
<div className="card-btns">
|
|
|
|
<Tooltip placement="rightTop" title={isFollowed ? '取消关注' : '添加关注'}>
|
|
|
|
<Icon type={isFollowed ? 'star' : 'star-o'} className="icon" onClick={isFollowed ? this.del : this.add}/>
|
|
|
|
</Tooltip>
|
|
|
|
</div>
|
|
|
|
</div>
|
2017-08-10 15:36:35 +08:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-08-11 17:47:25 +08:00
|
|
|
export default ProjectCard
|