2021-01-28 11:48:21 +08:00
|
|
|
|
import React , { useEffect , useState } from 'react';
|
|
|
|
|
|
import styled from 'styled-components';
|
|
|
|
|
|
import Box from './Box';
|
|
|
|
|
|
import axios from 'axios';
|
|
|
|
|
|
import { getImageUrl } from 'educoder';
|
2021-02-02 09:31:15 +08:00
|
|
|
|
import { Link } from 'react-router-dom';
|
2021-02-02 18:26:55 +08:00
|
|
|
|
import Nodata from '../Nodata';
|
2021-01-28 11:48:21 +08:00
|
|
|
|
|
2021-09-02 14:13:16 +08:00
|
|
|
|
import CheckProfile from '../Component/ProfileModal/Profile';
|
|
|
|
|
|
|
2021-01-28 11:48:21 +08:00
|
|
|
|
const Span = styled.span`{
|
|
|
|
|
|
color:#888;
|
|
|
|
|
|
font-size:12px;
|
|
|
|
|
|
margin-right:10px;
|
|
|
|
|
|
}`
|
|
|
|
|
|
const Align = styled.div`{
|
|
|
|
|
|
display:flex;
|
|
|
|
|
|
aligin:center;
|
|
|
|
|
|
}`
|
|
|
|
|
|
const ListName = styled.div`{
|
|
|
|
|
|
font-size:14px;
|
|
|
|
|
|
color:#333;
|
|
|
|
|
|
margin-bottom:8px;
|
|
|
|
|
|
height:18px;
|
|
|
|
|
|
line-height:18px;
|
|
|
|
|
|
}`;
|
|
|
|
|
|
const ColorListName = styled.div`{
|
|
|
|
|
|
color:#5091FF;
|
|
|
|
|
|
font-size:14px;
|
|
|
|
|
|
margin-bottom:8px;
|
|
|
|
|
|
height:18px;
|
|
|
|
|
|
line-height:18px;
|
|
|
|
|
|
}`
|
|
|
|
|
|
const Img = styled.img`{
|
|
|
|
|
|
border-radius:50%;
|
|
|
|
|
|
width:45px;
|
|
|
|
|
|
height:45px;
|
|
|
|
|
|
margin-right:12px;
|
|
|
|
|
|
}`
|
2021-09-02 14:13:16 +08:00
|
|
|
|
function RightBox({ OIdentifier , history , admin , showCompeleteDialog ,completeProfile }) {
|
2021-01-28 11:48:21 +08:00
|
|
|
|
const [ memberData, setMemberData ] = useState(undefined);
|
|
|
|
|
|
const [ groupData, setGroupData ] = useState(undefined);
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(()=>{
|
|
|
|
|
|
if(OIdentifier){
|
|
|
|
|
|
getMember(OIdentifier);
|
|
|
|
|
|
getGroup(OIdentifier);
|
|
|
|
|
|
}
|
|
|
|
|
|
},[OIdentifier])
|
|
|
|
|
|
|
|
|
|
|
|
function getMember(iden){
|
|
|
|
|
|
const url = `/organizations/${iden}/organization_users.json`;
|
2021-02-03 15:53:15 +08:00
|
|
|
|
axios.get(url,{params:{limit:5}}).then(result=>{
|
2021-01-28 11:48:21 +08:00
|
|
|
|
if(result && result.data){
|
|
|
|
|
|
setMemberData(result.data);
|
|
|
|
|
|
}
|
|
|
|
|
|
}).catch(error=>{})
|
|
|
|
|
|
}
|
|
|
|
|
|
function getGroup(iden){
|
|
|
|
|
|
const url = `/organizations/${iden}/teams.json`;
|
2021-02-03 15:53:15 +08:00
|
|
|
|
axios.get(url,{params:{limit:5}}).then(result=>{
|
2021-01-28 11:48:21 +08:00
|
|
|
|
if(result && result.data){
|
|
|
|
|
|
setGroupData(result.data);
|
|
|
|
|
|
}
|
|
|
|
|
|
}).catch(error=>{})
|
|
|
|
|
|
}
|
|
|
|
|
|
return(
|
|
|
|
|
|
<div className="list-r">
|
|
|
|
|
|
{
|
|
|
|
|
|
memberData && memberData.organization_users && memberData.organization_users.length>0 ?
|
2021-08-26 14:18:14 +08:00
|
|
|
|
<Box name="组织成员" count={memberData && memberData.total_count} url={`/${OIdentifier}/member`}>
|
2021-01-28 11:48:21 +08:00
|
|
|
|
{
|
|
|
|
|
|
memberData.organization_users.map((item,key)=>{
|
|
|
|
|
|
return(
|
|
|
|
|
|
<div className="teammembers" key={key}>
|
2021-08-30 10:31:51 +08:00
|
|
|
|
<Link to={`/${item.user && item.user.login}`}><Img src={getImageUrl(`/${item.user && item.user.image_url}`)} alt="" className="m-img"/></Link>
|
2021-01-28 11:48:21 +08:00
|
|
|
|
<div>
|
2021-08-30 10:31:51 +08:00
|
|
|
|
<Link to={`/${item.user && item.user.login}`}><ListName>{item.user && item.user.name}</ListName></Link>
|
2021-01-28 11:48:21 +08:00
|
|
|
|
<Align><i className="iconfont icon-shijian color-green mr3 font-13"></i><Span>加入时间:{item.created_at}</Span></Align>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
)
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
</Box>
|
|
|
|
|
|
:""
|
|
|
|
|
|
}
|
2021-02-02 18:26:55 +08:00
|
|
|
|
<Box
|
|
|
|
|
|
name="组织团队"
|
|
|
|
|
|
count={groupData && groupData.total_count}
|
2021-09-02 14:13:16 +08:00
|
|
|
|
bottom={
|
|
|
|
|
|
admin &&
|
|
|
|
|
|
<CheckProfile
|
|
|
|
|
|
showCompeleteDialog={showCompeleteDialog}
|
|
|
|
|
|
completeProfile={completeProfile}
|
|
|
|
|
|
sureFunc={()=>history.push(`/${OIdentifier}/group/new`)}
|
|
|
|
|
|
className={"ant-btn ant-btn-primary"}
|
|
|
|
|
|
>新建团队</CheckProfile>
|
|
|
|
|
|
}
|
2021-08-26 14:18:14 +08:00
|
|
|
|
url={`/${OIdentifier}/group`}
|
2021-02-02 18:26:55 +08:00
|
|
|
|
>
|
|
|
|
|
|
{
|
|
|
|
|
|
groupData && groupData.teams && groupData.teams.length>0?
|
|
|
|
|
|
<React.Fragment>
|
|
|
|
|
|
{groupData.teams.map((item,key)=>{
|
|
|
|
|
|
return(
|
|
|
|
|
|
<div className="teammembers" key={key}>
|
|
|
|
|
|
<div>
|
2021-08-27 10:53:00 +08:00
|
|
|
|
{
|
|
|
|
|
|
(item.is_admin || item.is_member) ?
|
2021-08-30 10:39:09 +08:00
|
|
|
|
<Link to={`/${OIdentifier}/group/${item.id}`}><ColorListName>{item.name}</ColorListName></Link>
|
2021-08-27 10:53:00 +08:00
|
|
|
|
:
|
|
|
|
|
|
<ColorListName>{item.name}</ColorListName>
|
|
|
|
|
|
}
|
2021-02-02 18:26:55 +08:00
|
|
|
|
<Align>
|
|
|
|
|
|
<Span>{item.num_users}名成员</Span>
|
|
|
|
|
|
<Span>{item.num_projects}个仓库</Span>
|
|
|
|
|
|
</Align>
|
2021-01-28 11:48:21 +08:00
|
|
|
|
</div>
|
2021-02-02 18:26:55 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
)
|
|
|
|
|
|
})}
|
|
|
|
|
|
</React.Fragment>:<Nodata _html="暂无团队" small/>
|
|
|
|
|
|
}
|
|
|
|
|
|
</Box>
|
2021-01-28 11:48:21 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
)
|
|
|
|
|
|
}
|
|
|
|
|
|
export default RightBox;
|