2021-04-25 17:38:47 +08:00
|
|
|
|
import React, { useEffect, useState } from "react";
|
|
|
|
|
|
import Nodata from '../Nodata';
|
|
|
|
|
|
import { FlexAJ } from '../Component/layout';
|
2021-05-28 16:19:40 +08:00
|
|
|
|
import { Pagination , Popconfirm , Spin } from 'antd';
|
2021-04-25 17:38:47 +08:00
|
|
|
|
import { Link } from 'react-router-dom';
|
|
|
|
|
|
import { getImageUrl } from 'educoder';
|
2021-04-26 14:59:19 +08:00
|
|
|
|
import Axios from 'axios';
|
2021-04-25 17:38:47 +08:00
|
|
|
|
|
|
|
|
|
|
const limit = 15;
|
|
|
|
|
|
function UndoEvent(props){
|
2021-04-26 14:59:19 +08:00
|
|
|
|
const username = props.match.params.username;
|
2021-04-25 17:38:47 +08:00
|
|
|
|
const [ list , setList ] = useState(undefined);
|
|
|
|
|
|
const [ page , setPage ] = useState(1);
|
|
|
|
|
|
const [ total , setTotal ] = useState(0);
|
2021-05-28 16:19:40 +08:00
|
|
|
|
const [ isSpin , setIsSpin ] = useState(true);
|
2021-04-25 17:38:47 +08:00
|
|
|
|
|
|
|
|
|
|
useEffect(()=>{
|
2021-04-26 14:59:19 +08:00
|
|
|
|
if(username){
|
2021-05-28 16:19:40 +08:00
|
|
|
|
setIsSpin(true);
|
2021-04-26 14:59:19 +08:00
|
|
|
|
getList();
|
|
|
|
|
|
}
|
|
|
|
|
|
},[username,page])
|
2021-04-25 17:38:47 +08:00
|
|
|
|
|
2021-04-26 14:59:19 +08:00
|
|
|
|
function getList(){
|
|
|
|
|
|
const url = `/users/${username}/applied_transfer_projects.json`;
|
|
|
|
|
|
Axios.get(url,{
|
|
|
|
|
|
params:{
|
|
|
|
|
|
page,per_page:limit
|
|
|
|
|
|
}
|
|
|
|
|
|
}).then(result=>{
|
|
|
|
|
|
if(result){
|
|
|
|
|
|
setList(result.data.applied_transfer_projects);
|
|
|
|
|
|
setTotal(result.data.total_count);
|
2021-05-28 16:19:40 +08:00
|
|
|
|
setIsSpin(false);
|
2021-04-26 14:59:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
}).catch(error=>{})
|
|
|
|
|
|
}
|
2021-04-25 17:38:47 +08:00
|
|
|
|
|
2021-04-26 14:59:19 +08:00
|
|
|
|
// 接受
|
|
|
|
|
|
function acceptDivert(id){
|
|
|
|
|
|
const url = `/users/${username}/applied_transfer_projects/${id}/accept.json`;
|
|
|
|
|
|
Axios.post(url).then(result=>{
|
|
|
|
|
|
if(result && result.data){
|
|
|
|
|
|
getList();
|
2021-06-11 09:25:59 +08:00
|
|
|
|
props && props.deleteEvent("undo",1);
|
2021-04-26 14:59:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
}).catch(error=>{})
|
2021-04-25 17:38:47 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 拒绝
|
2021-04-26 14:59:19 +08:00
|
|
|
|
function revertDivert(id){
|
|
|
|
|
|
const url = `/users/${username}/applied_transfer_projects/${id}/refuse.json`;
|
|
|
|
|
|
Axios.post(url).then(result=>{
|
|
|
|
|
|
if(result && result.data){
|
|
|
|
|
|
getList();
|
2021-08-06 14:07:59 +08:00
|
|
|
|
props && props.deleteEvent("apply",1);
|
2021-04-26 14:59:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
}).catch(error=>{})
|
2021-04-25 17:38:47 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return(
|
|
|
|
|
|
<div>
|
2021-05-28 16:19:40 +08:00
|
|
|
|
<Spin spinning={isSpin}>
|
|
|
|
|
|
<div style={{minHeight:"400px"}}>
|
|
|
|
|
|
{
|
|
|
|
|
|
list && list.length > 0 ?
|
2021-04-25 17:38:47 +08:00
|
|
|
|
<ul className="notifyList">
|
|
|
|
|
|
{
|
|
|
|
|
|
list.map((i,k)=>{
|
|
|
|
|
|
return(
|
|
|
|
|
|
<li>
|
2021-04-26 16:17:04 +08:00
|
|
|
|
<Link to={`/users/${i.user && i.user.login}`}><img src={getImageUrl(`/${i.user && i.user.image_url}`)} alt="" className="notifyImg"/></Link>
|
2021-04-25 17:38:47 +08:00
|
|
|
|
<div className="notifyFlex">
|
|
|
|
|
|
<p className="notifyInfos">
|
2021-04-26 14:59:19 +08:00
|
|
|
|
<Link to={`/users/${i.login}`} className="font-15 mr20">{i.user && i.user.name}</Link>
|
|
|
|
|
|
<span className="color-grey-9">{i.time_ago}</span>
|
2021-04-25 17:38:47 +08:00
|
|
|
|
</p>
|
|
|
|
|
|
<FlexAJ>
|
2021-04-27 17:12:00 +08:00
|
|
|
|
<p className="color-grey-6">请求将仓库【<Link to={`/projects/${i.project && i.project.owner && i.project.owner.login}/${i.project && i.project.identifier}`}>{i.project && i.project.name}</Link>】
|
2021-06-02 18:22:29 +08:00
|
|
|
|
转移给【<Link to={`/users/${i.owner && i.owner.login}`}>{i.owner && i.owner.name}</Link>】,是否接受?</p>
|
2021-04-26 14:59:19 +08:00
|
|
|
|
{
|
|
|
|
|
|
i.status === "common" &&
|
|
|
|
|
|
<span>
|
|
|
|
|
|
<Popconfirm title={`确定接受仓库${i.project && i.project.name}?`} okText="确定" cancelText="取消" onConfirm={()=>acceptDivert(i.id)}>
|
|
|
|
|
|
<a className="color-blue">接受</a>
|
|
|
|
|
|
</Popconfirm>
|
|
|
|
|
|
<Popconfirm title={`确定拒绝接受仓库${i.project && i.project.name}?`} okText="确定" cancelText="取消" onConfirm={()=>revertDivert(i.id)}>
|
|
|
|
|
|
<a className="color-red ml20">拒绝</a>
|
|
|
|
|
|
</Popconfirm>
|
|
|
|
|
|
</span>
|
|
|
|
|
|
}
|
|
|
|
|
|
{
|
|
|
|
|
|
i.status === "canceled" && <span className="color-grey-9">对方已取消转移</span>
|
|
|
|
|
|
}
|
|
|
|
|
|
{
|
2021-04-26 16:17:04 +08:00
|
|
|
|
i.status === "accepted" && <span className="color-grey-9">已接受</span>
|
2021-04-26 14:59:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
{
|
|
|
|
|
|
i.status === "refused" && <span className="color-grey-9">已拒绝</span>
|
|
|
|
|
|
}
|
2021-04-25 17:38:47 +08:00
|
|
|
|
</FlexAJ>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</li>
|
|
|
|
|
|
)
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
</ul>
|
2021-05-28 16:19:40 +08:00
|
|
|
|
:
|
|
|
|
|
|
""
|
|
|
|
|
|
}
|
2021-04-25 17:38:47 +08:00
|
|
|
|
</div>
|
2021-05-28 16:19:40 +08:00
|
|
|
|
</Spin>
|
2021-04-27 17:12:00 +08:00
|
|
|
|
{list && list.length === 0 && <Nodata _html="暂无接收信息" />}
|
2021-04-25 17:38:47 +08:00
|
|
|
|
{
|
|
|
|
|
|
total > limit &&
|
|
|
|
|
|
<div className="edu-txt-center pt20 pb20">
|
|
|
|
|
|
<Pagination simple pageSize={limit} total={total} current={page} onChange={(p)=>{setPage(p)}}/>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
)
|
|
|
|
|
|
}
|
|
|
|
|
|
export default UndoEvent;
|