Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: [on 3484] fix total emissions included #1170

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion app/src/app/[lng]/[inventory]/data/[step]/SourceDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@ export function SourceDrawer({
<TitleMedium>{t("disaggregated-analysis")}</TitleMedium>
{sourceData?.records && (
<SourceDrawerActivityTable
sectorId={sector?.sectorId}
activities={sourceData.records}
t={t}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,15 @@ import { Overline } from "@/components/Texts/Overline";
interface SourceDrawerActivityTableProps {
activities: DataSourceActivityDataRecord[];
t: TFunction;
sectorId: string | undefined;
}

export function SourceDrawerActivityTable({
activities,
t,
sectorId,
}: SourceDrawerActivityTableProps) {
const getTotalEmissions = () => {
const emissions = activities.reduce((acc, activity) => {
return (
acc +
activity.gases.reduce((acc, gas) => {
return acc + gas.emissions_value_100yr;
}, 0)
);
const getTotalEmissions = (activity: DataSourceActivityDataRecord) => {
const emissions = activity.gases.reduce((acc, gas) => {
return acc + gas.emissions_value_100yr;
}, 0);
return convertKgToTonnes(emissions);
};
Expand All @@ -57,7 +50,7 @@ export function SourceDrawerActivityTable({
.map((e) => t(e))
.join(" > ")}
</BodyMedium>
<TitleSmall>{`${t("total")} ${getTotalEmissions()}`}</TitleSmall>
<TitleSmall>{`${t("total")} ${getTotalEmissions(activity)}`}</TitleSmall>
</HStack>
</AccordionItemTrigger>
<AccordionItemContent>
Expand Down
3 changes: 2 additions & 1 deletion app/src/i18n/locales/en/dashboard.json
Original file line number Diff line number Diff line change
Expand Up @@ -174,5 +174,6 @@
"afolu-land": "Land",
"rate": "rate",
"sector": "sector",
"an-error-occurred": "An error occurred"
"an-error-occurred": "An error occurred",
"error-fetching-sector-breakdown": "Error fetching sector breakdown"
}
Loading