Skip to content

Commit

Permalink
Merge pull request #892 from betagouv/fiche_reseau_valeurs_zero
Browse files Browse the repository at this point in the history
Vérification de valeur pour afficher les infos du réseau
  • Loading branch information
totakoko authored Oct 15, 2024
2 parents e63dbd7 + 4bd1099 commit cd6696a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
9 changes: 4 additions & 5 deletions src/components/Network/Network.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import HoverableIcon from '@components/Hoverable/HoverableIcon';
import Map from '@components/Map/Map';
import Link from '@components/ui/Link';
import Text from '@components/ui/Text';
import { isDefined } from '@utils/core';
import { getConso } from 'src/services/Map/conso';
import { createMapConfiguration } from 'src/services/Map/map-configuration';
import { Network } from 'src/types/Summary/Network';
Expand Down Expand Up @@ -92,9 +93,7 @@ const NetworkPanel = ({
<div>
<b>Taux d’EnR&R</b>
</div>
<div>
{network['Taux EnR&R'] !== null && network['Taux EnR&R'] !== undefined ? `${network['Taux EnR&R']}%` : 'Non connu'}
</div>
<div>{isDefined(network['Taux EnR&R']) ? `${network['Taux EnR&R']}%` : 'Non connu'}</div>
</BoxContent>
)}
<BoxContent>
Expand All @@ -104,7 +103,7 @@ const NetworkPanel = ({
ACV : en analyse du cycle de vie (émissions directes et indirectes).
</HoverableIcon>
</div>
<div>{network['contenu CO2 ACV'] ? `${network['contenu CO2 ACV'] * 1000} g CO2/kWh` : 'Non connu'}</div>
<div>{isDefined(network['contenu CO2 ACV']) ? `${network['contenu CO2 ACV'] * 1000} g CO2/kWh` : 'Non connu'}</div>
</BoxContent>
<BoxContent>
<div>
Expand All @@ -113,7 +112,7 @@ const NetworkPanel = ({
Émissions directes
</HoverableIcon>
</div>
<div>{network['contenu CO2'] ? `${network['contenu CO2'] * 1000} g CO2/kWh` : 'Non connu'}</div>
<div>{isDefined(network['contenu CO2']) ? `${network['contenu CO2'] * 1000} g CO2/kWh` : 'Non connu'}</div>
</BoxContent>
</BlueBox>
)}
Expand Down
4 changes: 3 additions & 1 deletion src/services/Map/conso.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { isDefined } from '@utils/core';

export const getConso = (conso: number) => {
if (conso !== null && conso !== undefined) {
if (isDefined(conso)) {
if (conso > 1000) {
return `${(conso / 1000).toFixed(2)} GWh`;
}
Expand Down

0 comments on commit cd6696a

Please sign in to comment.