2024-04-18 11:20:01 +02:00
|
|
|
import { DEFAULT_PROJECT_ID } from 'hooks/api/getters/useDefaultProject/useDefaultProjectId';
|
|
|
|
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
|
|
|
|
import {
|
|
|
|
StyledProjectCard,
|
|
|
|
StyledDivHeader,
|
|
|
|
StyledBox,
|
2024-04-29 11:51:44 +02:00
|
|
|
StyledCardTitle,
|
2024-04-18 11:20:01 +02:00
|
|
|
StyledDivInfo,
|
|
|
|
StyledParagraphInfo,
|
|
|
|
StyledProjectCardBody,
|
2024-04-29 11:51:44 +02:00
|
|
|
StyledIconBox,
|
2024-04-18 11:20:01 +02:00
|
|
|
} from './NewProjectCard.styles';
|
|
|
|
import { ProjectCardFooter } from './ProjectCardFooter/ProjectCardFooter';
|
2024-04-29 11:51:44 +02:00
|
|
|
import { ProjectModeBadge } from './ProjectModeBadge/ProjectModeBadge';
|
|
|
|
import type { ProjectSchemaOwners } from 'openapi';
|
2024-07-26 10:26:16 +02:00
|
|
|
import { ProjectIcon } from 'component/common/ProjectIcon/ProjectIcon';
|
2024-08-13 15:19:13 +02:00
|
|
|
import { FavoriteAction } from './ProjectCardFooter/FavoriteAction/FavoriteAction';
|
2024-04-18 11:20:01 +02:00
|
|
|
|
|
|
|
interface IProjectCardProps {
|
|
|
|
name: string;
|
|
|
|
featureCount: number;
|
|
|
|
health: number;
|
2024-08-13 14:33:11 +02:00
|
|
|
memberCount?: number;
|
2024-04-18 11:20:01 +02:00
|
|
|
id: string;
|
|
|
|
onHover: () => void;
|
2024-08-13 15:19:13 +02:00
|
|
|
favorite?: boolean;
|
2024-04-18 11:20:01 +02:00
|
|
|
mode: string;
|
2024-04-29 11:51:44 +02:00
|
|
|
owners?: ProjectSchemaOwners;
|
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,
|
|
|
|
}: IProjectCardProps) => (
|
|
|
|
<StyledProjectCard onMouseEnter={onHover}>
|
|
|
|
<StyledProjectCardBody>
|
|
|
|
<StyledDivHeader>
|
|
|
|
<StyledIconBox>
|
2024-07-26 10:26:16 +02:00
|
|
|
<ProjectIcon />
|
2024-04-29 11:51:44 +02:00
|
|
|
</StyledIconBox>
|
|
|
|
<StyledBox data-loading>
|
|
|
|
<StyledCardTitle>{name}</StyledCardTitle>
|
|
|
|
</StyledBox>
|
|
|
|
<ProjectModeBadge mode={mode} />
|
|
|
|
</StyledDivHeader>
|
|
|
|
<StyledDivInfo>
|
|
|
|
<div>
|
|
|
|
<StyledParagraphInfo data-loading>
|
|
|
|
{featureCount}
|
|
|
|
</StyledParagraphInfo>
|
|
|
|
<p data-loading>{featureCount === 1 ? 'flag' : 'flags'}</p>
|
|
|
|
</div>
|
|
|
|
<ConditionallyRender
|
|
|
|
condition={id !== DEFAULT_PROJECT_ID}
|
|
|
|
show={
|
|
|
|
<div>
|
|
|
|
<StyledParagraphInfo data-loading>
|
|
|
|
{memberCount}
|
|
|
|
</StyledParagraphInfo>
|
|
|
|
<p data-loading>
|
|
|
|
{memberCount === 1 ? 'member' : 'members'}
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
<div>
|
|
|
|
<StyledParagraphInfo data-loading>
|
|
|
|
{health}%
|
|
|
|
</StyledParagraphInfo>
|
|
|
|
<p data-loading>healthy</p>
|
|
|
|
</div>
|
|
|
|
</StyledDivInfo>
|
|
|
|
</StyledProjectCardBody>
|
2024-08-13 15:19:13 +02:00
|
|
|
<ProjectCardFooter id={id} owners={owners}>
|
|
|
|
<FavoriteAction id={id} isFavorite={favorite} />
|
2024-04-29 11:51:44 +02:00
|
|
|
</ProjectCardFooter>
|
|
|
|
</StyledProjectCard>
|
|
|
|
);
|