Skip to content
Snippets Groups Projects
Commit e404138c authored by git-directory-deploy's avatar git-directory-deploy
Browse files

fix(performance): issue on sign color and handle 0 consumption variation

parent 0b884f1f
No related branches found
No related tags found
2 merge requests!777Update master to V2.0,!702Resolve "[Analyse] Pas de comparaison possible / 0 sur le gaz"
......@@ -15,6 +15,16 @@ interface FluidPerformanceIndicatorProps {
date: DateTime
}
const percentSwitch = (percentage: number) => {
if (percentage > 0) {
return `+${formatNumberValues(percentage * 100)} %`
} else if (percentage < 0) {
return `-${formatNumberValues(Math.abs(percentage) * 100)} %`
} else {
return `${formatNumberValues(percentage * 100)} %`
}
}
const FluidPerformanceIndicator: React.FC<FluidPerformanceIndicatorProps> = ({
performanceIndicator,
fluidType,
......@@ -52,22 +62,13 @@ const FluidPerformanceIndicator: React.FC<FluidPerformanceIndicatorProps> = ({
<span
className={`${
performanceIndicator?.percentageVariation &&
performanceIndicator?.percentageVariation > 0
? 'negative'
: 'positive'
performanceIndicator?.percentageVariation >= 0
? 'positive'
: 'negative'
}`}
>
{performanceIndicator?.percentageVariation ? (
performanceIndicator.percentageVariation > 0 ? (
`+${formatNumberValues(
performanceIndicator.percentageVariation * 100
)} %`
) : (
`-${formatNumberValues(
Math.abs(performanceIndicator.percentageVariation) *
100
)} %`
)
{performanceIndicator?.percentageVariation !== null ? (
percentSwitch(performanceIndicator.percentageVariation)
) : (
<>
<span className="no-comparison">
......@@ -76,7 +77,7 @@ const FluidPerformanceIndicator: React.FC<FluidPerformanceIndicatorProps> = ({
</>
)}
</span>
{performanceIndicator.percentageVariation &&
{performanceIndicator.percentageVariation !== null &&
`/ ${getPreviousMonthName(date.minus({ month: 1 }))}`}
</span>
</div>
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment