-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add risk cards to project simulation
- Loading branch information
Showing
8 changed files
with
190 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
app/spa/src/modules/project/components/ProjectRiskCards.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import Card, { CardType } from "../../../components/Card" | ||
import { Box } from "@mui/material" | ||
import { useTranslation } from "react-i18next" | ||
|
||
const ProjectRiskCards = ({ | ||
remainingDays, | ||
currentOperationalRisk, | ||
currentTeamRisk, | ||
}: ProjectRiskCardsProps) => { | ||
const { t } = useTranslation(["generalProjectPage"]) | ||
|
||
const currentRiskToDeadlinePercentage = ( | ||
currentOperationalRisk * 100 | ||
).toFixed(2) | ||
const currentTeamRiskPercentage = (currentTeamRisk * 100).toFixed(2) | ||
const cardTypeTeamRisk = cardTypeByRisk(currentTeamRisk) | ||
const cardTypeOperationalRisk = cardTypeByRisk(currentOperationalRisk) | ||
|
||
return ( | ||
<Box sx={{ display: "flex", my: 2 }}> | ||
<Card | ||
style={{ width: "350px", marginRight: "20px" }} | ||
title={t("cards.operational_risk")} | ||
subtitle={t("cards.operational_risk_message", { | ||
days: remainingDays, | ||
percentage: currentRiskToDeadlinePercentage, | ||
})} | ||
type={cardTypeOperationalRisk} | ||
/> | ||
|
||
<Card | ||
style={{ width: "350px" }} | ||
title={t("cards.operational_risk_team_data")} | ||
subtitle={t("cards.operational_risk_team_data_message", { | ||
risk: currentTeamRiskPercentage, | ||
})} | ||
type={cardTypeTeamRisk} | ||
/> | ||
</Box> | ||
) | ||
} | ||
|
||
type ProjectRiskCardsProps = { | ||
remainingDays: number | ||
currentOperationalRisk: number | ||
currentTeamRisk: number | ||
} | ||
|
||
const cardTypeByRisk = (risk: number) => { | ||
if (risk > 0.5 && risk <= 0.7) { | ||
return CardType.WARNING | ||
} else if (risk > 0.7) { | ||
return CardType.ERROR | ||
} | ||
|
||
return CardType.SUCCESS | ||
} | ||
|
||
export default ProjectRiskCards |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.