-
-
Notifications
You must be signed in to change notification settings - Fork 656
/
ProjectMembers.tsx
149 lines (132 loc) · 4.53 KB
/
ProjectMembers.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
import { Box, styled, Typography, useTheme } from '@mui/material';
import { StatusBox } from '../ProjectInsightsStats/StatusBox';
import KeyboardArrowRight from '@mui/icons-material/KeyboardArrowRight';
import { Link } from 'react-router-dom';
import type { ProjectInsightsSchemaMembers } from '../../../../../openapi';
interface IProjectMembersProps {
members: ProjectInsightsSchemaMembers;
projectId: string;
}
const NavigationBar = styled(Link)(({ theme }) => ({
display: 'flex',
justifyContent: 'space-between',
textDecoration: 'none',
color: theme.palette.text.primary,
}));
export const StyledProjectInfoWidgetContainer = styled('div')(({ theme }) => ({
display: 'flex',
flexDirection: 'column',
gap: theme.spacing(2.5),
}));
export const BarContainer = styled('div')(({ theme }) => ({
width: '100%',
height: '20px',
display: 'flex',
}));
const ActiveBar = styled('span', {
shouldForwardProp: (prop) => prop !== 'percentage',
})<{
percentage: number;
}>(({ theme, percentage }) => ({
width: `${percentage - 1}%`,
backgroundColor: theme.palette.success.border,
borderRadius: theme.shape.borderRadius,
}));
const InactiveBar = styled('span', {
shouldForwardProp: (prop) => prop !== 'percentage',
})<{
percentage: number;
}>(({ theme, percentage }) => ({
width: `${percentage - 1}%`,
backgroundColor: theme.palette.warning.border,
marginLeft: 'auto',
borderRadius: theme.shape.borderRadius,
}));
export const CountContainer = styled('div')(({ theme }) => ({
display: 'flex',
flexDirection: 'column',
gap: theme.spacing(1.5),
}));
export const CountRow = styled(NavigationBar)(({ theme }) => ({
display: 'flex',
padding: theme.spacing(0.5, 1, 0, 2),
alignItems: 'center',
gap: theme.spacing(3),
alignSelf: 'stretch',
borderRadius: theme.shape.borderRadiusMedium,
background: '#F7F7FA',
}));
const StatusWithDot = styled(Box)(({ theme }) => ({
display: 'flex',
alignItems: 'center',
gap: theme.spacing(1),
}));
const Dot = styled('span', {
shouldForwardProp: (prop) => prop !== 'color',
})<{
color?: string;
}>(({ theme, color }) => ({
height: '15px',
width: '15px',
borderRadius: '50%',
display: 'inline-block',
backgroundColor: color,
}));
export const StyledCount = styled('span')(({ theme }) => ({
fontSize: theme.typography.h1.fontSize,
fontWeight: theme.typography.fontWeightRegular,
color: theme.palette.text.primary,
}));
export const ProjectMembers = ({
members,
projectId,
}: IProjectMembersProps) => {
const { uiConfig } = useUiConfig();
const theme = useTheme();
const link = uiConfig?.versionInfo?.current?.enterprise
? `/projects/${projectId}/settings/access`
: `/admin/users`;
const { active, totalPreviousMonth, inactive } = members;
const currentMembers = active + inactive;
const change = currentMembers - (totalPreviousMonth || 0);
const activePercentage = (active / currentMembers) * 100;
const inactivePercentage = (inactive / currentMembers) * 100;
return (
<StyledProjectInfoWidgetContainer>
<NavigationBar to={link}>
<Typography variant='h3'>Project members</Typography>
<KeyboardArrowRight />
</NavigationBar>
<Box
sx={{
display: 'flex',
}}
>
<StatusBox boxText={`${currentMembers}`} change={change} />
</Box>
<BarContainer>
<ActiveBar percentage={activePercentage} />
<InactiveBar percentage={inactivePercentage} />
</BarContainer>
<CountContainer>
<CountRow to={link}>
<StatusWithDot>
<Dot color={theme.palette.success.border} />
<Box>Active</Box>
<StyledCount>{active}</StyledCount>
</StatusWithDot>
<KeyboardArrowRight />
</CountRow>
<CountRow to={link}>
<StatusWithDot>
<Dot color={theme.palette.warning.border} />
<Box>Inactive</Box>
<StyledCount>{inactive}</StyledCount>
</StatusWithDot>
<KeyboardArrowRight />
</CountRow>
</CountContainer>
</StyledProjectInfoWidgetContainer>
);
};