Skip to content

Commit

Permalink
Merge pull request #37 from MediaComem/fix-12
Browse files Browse the repository at this point in the history
fix(12): remove number after comma
  • Loading branch information
slecorne authored Oct 20, 2022
2 parents 8c96eab + c8921e4 commit 3b853d9
Show file tree
Hide file tree
Showing 2 changed files with 12,450 additions and 11 deletions.
43 changes: 32 additions & 11 deletions src/components/recommandations/ReportGeneralInfo.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,40 @@
import { Flex, Spacer, Text } from "@chakra-ui/react";
import { useAppSelector, useCalculateImpact, useCalculateRecommandationsImpact } from "../../app/hooks";
import {
useAppSelector,
useCalculateImpact,
useCalculateRecommandationsImpact,
} from "../../app/hooks";

export default function ReportGeneralInfo() {
const impact = useCalculateImpact();
const impactWithRecommandations = useCalculateRecommandationsImpact();
const benefits = {
energy: impact.energy - impactWithRecommandations.energy,
co2: impact.co2 - impactWithRecommandations.co2
co2: impact.co2 - impactWithRecommandations.co2,
};
const nbOfVisit = useAppSelector((state) => state.project.params.nbVisit) ?? 0;
const nbOfVisit =
useAppSelector((state) => state.project.params.nbVisit) ?? 0;
const nbOfVisitDefined = nbOfVisit && nbOfVisit > 0;
const totalCO2Benef = `-${benefits.co2.toFixed(2)} ${nbOfVisitDefined ? '' : '/visit'}`;
const totalkWhBenef = `-${benefits.energy.toFixed(2)} ${nbOfVisitDefined ? '' : '/visit'}`;
const totalCO2Benef = `-${benefits.co2.toFixed(0)} ${
nbOfVisitDefined ? "" : "/visit"
}`;
const totalkWhBenef = `-${benefits.energy.toFixed(0)} ${
nbOfVisitDefined ? "" : "/visit"
}`;
return (
<Flex justify={"stretch"} align="center" minHeight={"fit-content"}>
<Flex direction={"column"} justify="center" p={2} grow={1}>
<Text fontSize={"sm"} color={"gray.500"}>Energy (KWh)</Text>
<Text fontSize={"sm"} color={"gray.500"}>
Energy (KWh)
</Text>
<Flex justify={"stretch"} align="center" minHeight={"fit-content"}>
<Text fontSize="lg" color={'gray.600'} fontWeight={"semibold"}>{impact.energy.toFixed(2)}</Text>
<Text fontSize="lg" color={"gray.600"} fontWeight={"semibold"}>
{impact.energy.toFixed(0)}
</Text>
<Spacer />
<Text fontSize="lg" color={'green.600'} fontWeight={"semibold"}>{totalkWhBenef}</Text>
<Text fontSize="lg" color={"green.600"} fontWeight={"semibold"}>
{totalkWhBenef}
</Text>
</Flex>
</Flex>
<Flex
Expand All @@ -29,11 +44,17 @@ export default function ReportGeneralInfo() {
borderLeft={"1px solid lightgray"}
grow={1}
>
<Text fontSize={"sm"} color={"gray.500"}>GWP ( kg CO2eq)</Text>
<Text fontSize={"sm"} color={"gray.500"}>
GWP ( kg CO2eq)
</Text>
<Flex justify={"stretch"} align="center" minHeight={"fit-content"}>
<Text fontSize="lg" color={'gray.600'} fontWeight={"semibold"}>{impact.co2.toFixed(2)}</Text>
<Text fontSize="lg" color={"gray.600"} fontWeight={"semibold"}>
{impact.co2.toFixed(0)}
</Text>
<Spacer />
<Text fontSize="lg" color={'green.600'} fontWeight={"semibold"}>{totalCO2Benef}</Text>
<Text fontSize="lg" color={"green.600"} fontWeight={"semibold"}>
{totalCO2Benef}
</Text>
</Flex>
</Flex>
</Flex>
Expand Down
Loading

0 comments on commit 3b853d9

Please sign in to comment.