2024-04-18 11:20:01 +02:00
|
|
|
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
|
|
|
|
import {
|
|
|
|
StyledProjectCard,
|
|
|
|
StyledDivHeader,
|
2024-04-29 11:51:44 +02:00
|
|
|
StyledCardTitle,
|
2024-04-18 11:20:01 +02:00
|
|
|
StyledProjectCardBody,
|
2024-04-29 11:51:44 +02:00
|
|
|
StyledIconBox,
|
2024-08-27 14:11:07 +02:00
|
|
|
} from './ProjectCard.styles';
|
2024-04-18 11:20:01 +02:00
|
|
|
import { ProjectCardFooter } from './ProjectCardFooter/ProjectCardFooter';
|
2024-04-29 11:51:44 +02:00
|
|
|
import { ProjectModeBadge } from './ProjectModeBadge/ProjectModeBadge';
|
2024-07-26 10:26:16 +02:00
|
|
|
import { ProjectIcon } from 'component/common/ProjectIcon/ProjectIcon';
|
2024-08-28 18:26:41 +02:00
|
|
|
import { FavoriteAction } from './FavoriteAction/FavoriteAction';
|
|
|
|
import { Box, styled } from '@mui/material';
|
|
|
|
import { flexColumn } from 'themes/themeStyles';
|
|
|
|
import { TimeAgo } from 'component/common/TimeAgo/TimeAgo';
|
|
|
|
import { ProjectLastSeen } from './ProjectLastSeen/ProjectLastSeen';
|
|
|
|
import type { IProjectCard } from 'interfaces/project';
|
2024-04-18 11:20:01 +02:00
|
|
|
|
2024-08-28 18:26:41 +02:00
|
|
|
const StyledUpdated = styled('span')(({ theme }) => ({
|
|
|
|
color: theme.palette.text.secondary,
|
|
|
|
fontSize: theme.fontSizes.smallerBody,
|
|
|
|
}));
|
|
|
|
|
|
|
|
const StyledCount = styled('strong')(({ theme }) => ({
|
|
|
|
fontWeight: theme.typography.fontWeightMedium,
|
|
|
|
}));
|
|
|
|
|
|
|
|
const StyledInfo = styled('div')(({ theme }) => ({
|
|
|
|
display: 'flex',
|
|
|
|
justifyContent: 'space-between',
|
|
|
|
marginTop: theme.spacing(1),
|
|
|
|
fontSize: theme.fontSizes.smallerBody,
|
|
|
|
alignItems: 'flex-end',
|
|
|
|
}));
|
2024-04-18 11:20:01 +02:00
|
|
|
|
|
|
|
export const ProjectCard = ({
|
|
|
|
name,
|
|
|
|
featureCount,
|
|
|
|
health,
|
2024-08-13 14:33:11 +02:00
|
|
|
memberCount = 0,
|
2024-04-18 11:20:01 +02:00
|
|
|
onHover,
|
|
|
|
id,
|
|
|
|
mode,
|
2024-08-13 15:19:13 +02:00
|
|
|
favorite = false,
|
2024-04-29 11:51:44 +02:00
|
|
|
owners,
|
2024-08-28 18:26:41 +02:00
|
|
|
lastUpdatedAt,
|
|
|
|
lastReportedFlagUsage,
|
|
|
|
}: IProjectCard) => (
|
2024-04-29 11:51:44 +02:00
|
|
|
<StyledProjectCard onMouseEnter={onHover}>
|
|
|
|
<StyledProjectCardBody>
|
|
|
|
<StyledDivHeader>
|
|
|
|
<StyledIconBox>
|
2024-07-26 10:26:16 +02:00
|
|
|
<ProjectIcon />
|
2024-04-29 11:51:44 +02:00
|
|
|
</StyledIconBox>
|
2024-08-28 18:26:41 +02:00
|
|
|
<Box
|
|
|
|
data-loading
|
|
|
|
sx={(theme) => ({
|
|
|
|
...flexColumn,
|
|
|
|
margin: theme.spacing(1, 'auto', 1, 0),
|
|
|
|
})}
|
|
|
|
>
|
|
|
|
<StyledCardTitle lines={1} sx={{ margin: 0 }}>
|
|
|
|
{name}
|
|
|
|
</StyledCardTitle>
|
|
|
|
<ConditionallyRender
|
|
|
|
condition={Boolean(lastUpdatedAt)}
|
|
|
|
show={
|
|
|
|
<StyledUpdated>
|
|
|
|
Updated <TimeAgo date={lastUpdatedAt} />
|
|
|
|
</StyledUpdated>
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
</Box>
|
2024-04-29 11:51:44 +02:00
|
|
|
<ProjectModeBadge mode={mode} />
|
2024-08-28 18:26:41 +02:00
|
|
|
<FavoriteAction id={id} isFavorite={favorite} />
|
2024-04-29 11:51:44 +02:00
|
|
|
</StyledDivHeader>
|
2024-08-28 18:26:41 +02:00
|
|
|
<StyledInfo>
|
2024-04-29 11:51:44 +02:00
|
|
|
<div>
|
2024-08-28 18:26:41 +02:00
|
|
|
<div>
|
|
|
|
<StyledCount>{featureCount}</StyledCount> flag
|
|
|
|
{featureCount === 1 ? '' : 's'}
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<StyledCount>{health}%</StyledCount> health
|
|
|
|
</div>
|
2024-04-29 11:51:44 +02:00
|
|
|
</div>
|
2024-08-28 18:26:41 +02:00
|
|
|
<ProjectLastSeen date={lastReportedFlagUsage} />
|
|
|
|
</StyledInfo>
|
2024-04-29 11:51:44 +02:00
|
|
|
</StyledProjectCardBody>
|
2024-08-28 18:26:41 +02:00
|
|
|
<ProjectCardFooter id={id} owners={owners} memberCount={memberCount} />
|
2024-04-29 11:51:44 +02:00
|
|
|
</StyledProjectCard>
|
|
|
|
);
|