From d7f2812d99ffdd15dd0b40ea822f15a283a5e269 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 6 Jan 2025 07:05:11 +0000 Subject: [PATCH 01/17] chore(deps): update scipy requirement in /global-api Updates the requirements on [scipy](https://github.com/scipy/scipy) to permit the latest version. - [Release notes](https://github.com/scipy/scipy/releases) - [Commits](https://github.com/scipy/scipy/compare/v1.14.0rc1...v1.15.0) --- updated-dependencies: - dependency-name: scipy dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- global-api/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/global-api/requirements.txt b/global-api/requirements.txt index b717d0f33..7831ffffd 100644 --- a/global-api/requirements.txt +++ b/global-api/requirements.txt @@ -12,7 +12,7 @@ psycopg2-binary==2.9.10 pydantic-settings==2.* pytest==8.3.4 rioxarray==0.18.* -scipy==1.14.* +scipy==1.15.* shapely==2.0.6 SQLAlchemy==2.0.36 tqdm==4.67.* From d788adc1f03cb2f89dfb0584b08802abea724b6b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 6 Jan 2025 07:05:15 +0000 Subject: [PATCH 02/17] chore(deps): bump mypy from 1.14.0 to 1.14.1 in /global-api Bumps [mypy](https://github.com/python/mypy) from 1.14.0 to 1.14.1. - [Changelog](https://github.com/python/mypy/blob/master/CHANGELOG.md) - [Commits](https://github.com/python/mypy/compare/v1.14.0...v1.14.1) --- updated-dependencies: - dependency-name: mypy dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- global-api/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/global-api/requirements.txt b/global-api/requirements.txt index b717d0f33..0cf100092 100644 --- a/global-api/requirements.txt +++ b/global-api/requirements.txt @@ -5,7 +5,7 @@ fastapi==0.115.6 flake8==7.1.1 fsspec==2024.* geopandas>=0.12,<1.1 -mypy==1.14.0 +mypy==1.14.1 osmnx==2.0.0 pandas==2.2.3 psycopg2-binary==2.9.10 From e9d7d2e1e3d9dafa9ef21466efa61a79cb650825 Mon Sep 17 00:00:00 2001 From: Cephas Chapa Date: Mon, 6 Jan 2025 15:03:40 +0200 Subject: [PATCH 03/17] fix: adds translation for recent search component on onboarding --- app/src/components/recent-searches.tsx | 7 ++++--- app/src/components/steps/select-city-steps.tsx | 2 +- app/src/i18n/locales/de/onboarding.json | 4 +++- app/src/i18n/locales/en/onboarding.json | 4 +++- app/src/i18n/locales/es/onboarding.json | 4 +++- app/src/i18n/locales/pt/onboarding.json | 5 +++-- 6 files changed, 17 insertions(+), 9 deletions(-) diff --git a/app/src/components/recent-searches.tsx b/app/src/components/recent-searches.tsx index 8054659aa..48770739c 100644 --- a/app/src/components/recent-searches.tsx +++ b/app/src/components/recent-searches.tsx @@ -1,7 +1,8 @@ import { Box, Text } from "@chakra-ui/react"; +import { TFunction } from "i18next"; import React from "react"; -const RecentSearches = () => { +const RecentSearches = ({ t }: { t: TFunction }) => { const data = [ { id: 1, @@ -31,7 +32,7 @@ const RecentSearches = () => { fontSize="overline" fontFamily="heading" > - RECENT SEARCHES + {t("recent-searches-title")} {hasRecentSearches ? ( @@ -78,7 +79,7 @@ const RecentSearches = () => { lineHeight="24" letterSpacing="wide" > - You have no recent searches + {t("recent-searches-no-results")} )} diff --git a/app/src/components/steps/select-city-steps.tsx b/app/src/components/steps/select-city-steps.tsx index 19e338329..7d71bea56 100644 --- a/app/src/components/steps/select-city-steps.tsx +++ b/app/src/components/steps/select-city-steps.tsx @@ -320,7 +320,7 @@ export default function SelectCityStep({ shadow="2dp" className="h-auto max-h-[272px] transition-all duration-150 overflow-scroll flex flex-col py-3 gap-3 rounded-lg w-full absolute bg-white z-50 mt-2 border border-[1px solid #E6E7FF]" > - {!isLoading && !cityInputQuery && } + {!isLoading && !cityInputQuery && } {isLoading &&

Fetching Cities...

} {isSuccess && cities && diff --git a/app/src/i18n/locales/de/onboarding.json b/app/src/i18n/locales/de/onboarding.json index 4bef4d6af..5f94b27ad 100644 --- a/app/src/i18n/locales/de/onboarding.json +++ b/app/src/i18n/locales/de/onboarding.json @@ -68,5 +68,7 @@ "start-inventory": "Startinventar", "city-boundary-info": "Falls die geografische Grenze nicht korrekt ist <0><1>Kontaktieren Sie uns", "unselected-city-boundary-heading": "Suchen und wählen Sie die Stadt aus, die auf der Karte angezeigt werden soll", - "unselected-city-boundary-description": "Sie können die geografische Grenze für Ihren Bestand überprüfen" + "unselected-city-boundary-description": "Sie können die geografische Grenze für Ihren Bestand überprüfen", + "recent-searches-title": "Letzte Suchen", + "recent-searches-no-results": "Sie haben keine kürzlichen Suchen" } diff --git a/app/src/i18n/locales/en/onboarding.json b/app/src/i18n/locales/en/onboarding.json index 2111505ab..0caddb993 100644 --- a/app/src/i18n/locales/en/onboarding.json +++ b/app/src/i18n/locales/en/onboarding.json @@ -68,5 +68,7 @@ "start-inventory": "Start Inventory", "city-boundary-info": "In case the geographical boundary is not the right one <0><1>Contact Us", "unselected-city-boundary-heading": "Search and select the city to be shown on the map", - "unselected-city-boundary-description": "You will be able to check the geographical boundary for your inventory" + "unselected-city-boundary-description": "You will be able to check the geographical boundary for your inventory", + "recent-searches-title": "Recent Searches", + "recent-searches-no-results": "You have no recent searches" } diff --git a/app/src/i18n/locales/es/onboarding.json b/app/src/i18n/locales/es/onboarding.json index d7911e81b..f64e222f1 100644 --- a/app/src/i18n/locales/es/onboarding.json +++ b/app/src/i18n/locales/es/onboarding.json @@ -69,5 +69,7 @@ "start-inventory": "Inicio de Inventario", "city-boundary-info": "En caso de que el límite geográfico no sea el correcto <0><1>Contáctenos", "unselected-city-boundary-heading": "Busque y seleccione la ciudad que se mostrará en el mapa", - "unselected-city-boundary-description": "Podrá verificar el límite geográfico de su inventario" + "unselected-city-boundary-description": "Podrá verificar el límite geográfico de su inventario", + "recent-searches-title": "Búsquedas recientes", + "recent-searches-no-results": "No tienes búsquedas recientes" } diff --git a/app/src/i18n/locales/pt/onboarding.json b/app/src/i18n/locales/pt/onboarding.json index 5ca971550..9750bf445 100644 --- a/app/src/i18n/locales/pt/onboarding.json +++ b/app/src/i18n/locales/pt/onboarding.json @@ -68,6 +68,7 @@ "start-inventory": "Iniciar Inventário", "city-boundary-info": "Caso a fronteira geográfica não seja a correta <0><1>Contate-nos", "unselected-city-boundary-heading": "Pesquise e selecione a cidade a ser exibida no mapa", - "unselected-city-boundary-description": "Você poderá verificar a fronteira geográfica do seu inventário" - + "unselected-city-boundary-description": "Você poderá verificar a fronteira geográfica do seu inventário", + "recent-searches-title": "Pesquisas Recentes", + "recent-searches-no-results": "Você não tem pesquisas recentes" } From a2f5b588c37816587066932341fd9bab37b1045d Mon Sep 17 00:00:00 2001 From: Cephas Chapa Date: Mon, 6 Jan 2025 15:20:03 +0200 Subject: [PATCH 04/17] fix(ui): adds translation function to translate label correctly --- app/src/components/Modals/delete-inventory-modal.tsx | 2 +- app/src/components/password-input.tsx | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/src/components/Modals/delete-inventory-modal.tsx b/app/src/components/Modals/delete-inventory-modal.tsx index 191f4f017..84cf172b5 100644 --- a/app/src/components/Modals/delete-inventory-modal.tsx +++ b/app/src/components/Modals/delete-inventory-modal.tsx @@ -192,7 +192,7 @@ const DeleteInventoryModal: FC = ({ error={errors.password} register={register} t={t} - name="Password" + name={t("password")} /> - {t(error.message)} + {t(error.message!)} )} From 56c9a37e0d4b50f98dfa99c6aeb2f2d192b07b7f Mon Sep 17 00:00:00 2001 From: thehighestprimenumber Date: Mon, 6 Jan 2025 13:04:41 -0300 Subject: [PATCH 05/17] [ON-3215] debug GLOBAL_API_URL --- app/src/backend/OpenClimateService.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/backend/OpenClimateService.ts b/app/src/backend/OpenClimateService.ts index c40fc45f5..80c456756 100644 --- a/app/src/backend/OpenClimateService.ts +++ b/app/src/backend/OpenClimateService.ts @@ -1,5 +1,6 @@ import { EmissionsForecastData } from "@/util/types"; import { GLOBAL_API_URL } from "@/services/api"; +import { logger } from "@/services/logger"; export type GrowthRatesResponse = Omit; @@ -10,8 +11,8 @@ export const getGrowthRatesFromOC = async ( try { const URL = `${GLOBAL_API_URL}/api/v0/ghgi/emissions_forecast/city/${encodeURIComponent(locode)}/${forecastYear}`; const response = await fetch(URL); - - console.info(`getGrowthRatesFromOC Status: ${response.status}`); + logger.info(`getGrowthRatesFromOC URL: ${URL}`); + logger.info(`getGrowthRatesFromOC Status: ${response.status}`); const data = await response.json(); return { ...data, From 1cbe7bd179a982569af33924fd43da84fb909134 Mon Sep 17 00:00:00 2001 From: Cephas Chapa <42181542+cephaschapa@users.noreply.github.com> Date: Tue, 7 Jan 2025 12:54:16 +0200 Subject: [PATCH 06/17] Update password-input.tsx removes unsafe error message access --- app/src/components/password-input.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/components/password-input.tsx b/app/src/components/password-input.tsx index d65ed7f10..e36406766 100644 --- a/app/src/components/password-input.tsx +++ b/app/src/components/password-input.tsx @@ -188,7 +188,7 @@ export default function PasswordInput({ letterSpacing="wide" color="content.tertiary" > - {t(error.message!)} + {t(error.message)} )} From cd077e0f8f1c5c3184b6102cad448249eec57b31 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 7 Jan 2025 13:42:47 +0000 Subject: [PATCH 07/17] chore(deps): bump osmnx from 2.0.0 to 2.0.1 in /global-api Bumps [osmnx](https://github.com/gboeing/osmnx) from 2.0.0 to 2.0.1. - [Changelog](https://github.com/gboeing/osmnx/blob/main/CHANGELOG.md) - [Commits](https://github.com/gboeing/osmnx/compare/v2.0.0...v2.0.1) --- updated-dependencies: - dependency-name: osmnx dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- global-api/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/global-api/requirements.txt b/global-api/requirements.txt index 6e6687f24..834f95a67 100644 --- a/global-api/requirements.txt +++ b/global-api/requirements.txt @@ -6,7 +6,7 @@ flake8==7.1.1 fsspec==2024.* geopandas>=0.12,<1.1 mypy==1.14.1 -osmnx==2.0.0 +osmnx==2.0.1 pandas==2.2.3 psycopg2-binary==2.9.10 pydantic-settings==2.* From 75efef2c26c0a840f4cda414151dc82e12ce6260 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 7 Jan 2025 09:46:41 -0500 Subject: [PATCH 08/17] chore: v0.39.0-rc.0 Signed-off-by: Evan Prodromou --- app/package-lock.json | 4 ++-- app/package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/package-lock.json b/app/package-lock.json index 946a6403c..f5d5c8dfd 100644 --- a/app/package-lock.json +++ b/app/package-lock.json @@ -1,12 +1,12 @@ { "name": "city-catalyst", - "version": "0.39.0-dev.0", + "version": "0.39.0-rc.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "city-catalyst", - "version": "0.39.0-dev.0", + "version": "0.39.0-rc.0", "dependencies": { "@ai-sdk/openai": "^1.0.8", "@chakra-ui/icons": "^2.1.0", diff --git a/app/package.json b/app/package.json index 5b4c6b20c..7dcdc7d03 100644 --- a/app/package.json +++ b/app/package.json @@ -1,6 +1,6 @@ { "name": "city-catalyst", - "version": "0.39.0-dev.0", + "version": "0.39.0-rc.0", "private": true, "type": "module", "scripts": { From a5b6e01267c0beb142d7b6cd460736322e3feb7f Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 7 Jan 2025 09:47:14 -0500 Subject: [PATCH 09/17] chore: v0.40.0-dev.0 Signed-off-by: Evan Prodromou --- app/package-lock.json | 4 ++-- app/package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/package-lock.json b/app/package-lock.json index f5d5c8dfd..0b1bf6384 100644 --- a/app/package-lock.json +++ b/app/package-lock.json @@ -1,12 +1,12 @@ { "name": "city-catalyst", - "version": "0.39.0-rc.0", + "version": "0.40.0-dev.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "city-catalyst", - "version": "0.39.0-rc.0", + "version": "0.40.0-dev.0", "dependencies": { "@ai-sdk/openai": "^1.0.8", "@chakra-ui/icons": "^2.1.0", diff --git a/app/package.json b/app/package.json index 7dcdc7d03..e0ce293a0 100644 --- a/app/package.json +++ b/app/package.json @@ -1,6 +1,6 @@ { "name": "city-catalyst", - "version": "0.39.0-rc.0", + "version": "0.40.0-dev.0", "private": true, "type": "module", "scripts": { From 95d2c87432d76af3bea6bad6059d77c06c4d1c3b Mon Sep 17 00:00:00 2001 From: thehighestprimenumber Date: Fri, 3 Jan 2025 12:14:38 -0300 Subject: [PATCH 10/17] [ON-3141] add colors --- app/src/util/constants.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/src/util/constants.ts b/app/src/util/constants.ts index e8feba72a..bb9f6a889 100644 --- a/app/src/util/constants.ts +++ b/app/src/util/constants.ts @@ -28,6 +28,7 @@ export interface ISector { scopes: number[]; }; }; + color: string; } export const getSectorsForInventory = (inventoryType?: InventoryType) => { @@ -65,6 +66,7 @@ export const SECTORS: ISector[] = [ name: "stationary-energy", description: "stationary-energy-description", icon: TbBuildingCommunity, + color: "#5785F4", inventoryTypes: { [InventoryTypeEnum.GPC_BASIC]: { scopes: [1, 2] }, [InventoryTypeEnum.GPC_BASIC_PLUS]: { scopes: [1, 2, 3] }, @@ -77,6 +79,7 @@ export const SECTORS: ISector[] = [ name: "transportation", description: "transportation-description", icon: BsTruck, + color: "#F17105", inventoryTypes: { [InventoryTypeEnum.GPC_BASIC]: { scopes: [1, 2] }, [InventoryTypeEnum.GPC_BASIC_PLUS]: { scopes: [1, 2, 3] }, @@ -89,6 +92,7 @@ export const SECTORS: ISector[] = [ name: "waste", description: "waste-description", icon: PiTrashLight, + color: "#25AC4B", inventoryTypes: { [InventoryTypeEnum.GPC_BASIC]: { scopes: [1, 3] }, [InventoryTypeEnum.GPC_BASIC_PLUS]: { scopes: [1, 3] }, @@ -101,6 +105,7 @@ export const SECTORS: ISector[] = [ name: "ippu", description: "ippu-description", icon: LiaIndustrySolid, + color: "#BFA937", testId: "ippu-sector-card", inventoryTypes: { [InventoryTypeEnum.GPC_BASIC]: { scopes: [] }, @@ -113,6 +118,7 @@ export const SECTORS: ISector[] = [ name: "afolu", description: "afolu-description", icon: PiPlant, + color: "#F5D949", testId: "afolu-sector-card", inventoryTypes: { [InventoryTypeEnum.GPC_BASIC]: { scopes: [] }, @@ -121,5 +127,7 @@ export const SECTORS: ISector[] = [ }, ]; +export const allSectorColors = SECTORS.map((sector) => sector.color); + export const getReferenceNumberByName = (name: keyof ISector) => findBy("name", name)?.referenceNumber; From 89515e4646063e1e1d60ea86d83d0de3c0cf4b42 Mon Sep 17 00:00:00 2001 From: thehighestprimenumber Date: Fri, 3 Jan 2025 12:14:46 -0300 Subject: [PATCH 11/17] [ON-3141] in EmissionBySectorChart.tsx --- .../InventoryResultTab/EmissionBySectorChart.tsx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/app/src/app/[lng]/[inventory]/InventoryResultTab/EmissionBySectorChart.tsx b/app/src/app/[lng]/[inventory]/InventoryResultTab/EmissionBySectorChart.tsx index 2ebf68ee9..a451d9ea1 100644 --- a/app/src/app/[lng]/[inventory]/InventoryResultTab/EmissionBySectorChart.tsx +++ b/app/src/app/[lng]/[inventory]/InventoryResultTab/EmissionBySectorChart.tsx @@ -1,6 +1,6 @@ import { SectorEmission } from "@/util/types"; import { ResponsiveBar } from "@nivo/bar"; -import { SECTORS } from "@/util/constants"; +import { allSectorColors, SECTORS } from "@/util/constants"; import { convertKgToKiloTonnes, convertKgToTonnes } from "@/util/helpers"; import { useTranslation } from "@/i18n/client"; import { toKebabCaseModified } from "@/app/[lng]/[inventory]/InventoryResultTab/index"; @@ -46,8 +46,6 @@ const EmissionBySectorChart: React.FC = ({ toKebabCaseModified(sector.name), ); - const colors = ["#5785F4", "#F17105", "#25AC4B", "#BFA937", "#F5D949"]; - return (
@@ -80,7 +78,7 @@ const EmissionBySectorChart: React.FC = ({ )} valueScale={{ type: "linear", min: 0, max: "auto" }} indexScale={{ type: "band", round: true }} - colors={colors} + colors={allSectorColors} borderColor={{ from: "color", modifiers: [["darker", 1.6]], @@ -136,7 +134,7 @@ const EmissionBySectorChart: React.FC = ({ > Date: Fri, 3 Jan 2025 12:41:44 -0300 Subject: [PATCH 12/17] [ON-3141] in TopEmissionsWidget.tsx --- .../InventoryResultTab/TopEmissionsWidget.tsx | 11 +++++++---- app/src/components/SegmentedProgress.tsx | 8 +------- app/src/util/constants.ts | 2 ++ 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/app/src/app/[lng]/[inventory]/InventoryResultTab/TopEmissionsWidget.tsx b/app/src/app/[lng]/[inventory]/InventoryResultTab/TopEmissionsWidget.tsx index b1e648baf..8689e11d2 100644 --- a/app/src/app/[lng]/[inventory]/InventoryResultTab/TopEmissionsWidget.tsx +++ b/app/src/app/[lng]/[inventory]/InventoryResultTab/TopEmissionsWidget.tsx @@ -31,6 +31,7 @@ import { SegmentedProgressValues, } from "@/components/SegmentedProgress"; import { EmptyStateCardContent } from "@/app/[lng]/[inventory]/InventoryResultTab/EmptyStateCardContent"; +import { allSectorColors, SECTORS } from "@/util/constants"; const EmissionsTable = ({ topEmissions, @@ -96,11 +97,12 @@ const TopEmissionsWidget = ({ function getPercentagesForProgress(): SegmentedProgressValues[] { const bySector: SectorEmission[] = results?.totalEmissions.bySector ?? []; - return bySector.map(({ sectorName, co2eq, percentage }) => { + return SECTORS.map(({ name }) => { + const sector = bySector.find((sector) => sector.sectorName === name)!; return { - name: sectorName, - value: co2eq, - percentage: percentage, + name, + value: sector?.co2eq || 0, + percentage: sector?.percentage || 0, } as SegmentedProgressValues; }); } @@ -147,6 +149,7 @@ const TopEmissionsWidget = ({ values={getPercentagesForProgress()} total={results?.totalEmissions.total} t={t} + colors={allSectorColors} showLabels showHover /> diff --git a/app/src/components/SegmentedProgress.tsx b/app/src/components/SegmentedProgress.tsx index 5820676fb..72ad781f8 100644 --- a/app/src/components/SegmentedProgress.tsx +++ b/app/src/components/SegmentedProgress.tsx @@ -25,13 +25,7 @@ export type SegmentedProgressValues = export function SegmentedProgress({ values, - colors = [ - "interactive.connected", - "interactive.tertiary", - "interactive.secondary", - "sentiment.negativeDefault", - "interactive.control", - ], + colors = ["interactive.connected", "interactive.tertiary"], max = 1, height = 4, showLabels = false, diff --git a/app/src/util/constants.ts b/app/src/util/constants.ts index bb9f6a889..0b090744d 100644 --- a/app/src/util/constants.ts +++ b/app/src/util/constants.ts @@ -128,6 +128,8 @@ export const SECTORS: ISector[] = [ ]; export const allSectorColors = SECTORS.map((sector) => sector.color); +export const getSectorByName = (name: string) => + SECTORS.find((s) => s.name === name); export const getReferenceNumberByName = (name: keyof ISector) => findBy("name", name)?.referenceNumber; From 6f96d2e2aac19350e1920e44368d62305409489d Mon Sep 17 00:00:00 2001 From: thehighestprimenumber Date: Mon, 6 Jan 2025 20:08:07 -0300 Subject: [PATCH 13/17] [ON-3141] save colours in theme --- app/src/lib/app-theme.ts | 8 ++++++++ app/src/util/constants.ts | 11 ++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/app/src/lib/app-theme.ts b/app/src/lib/app-theme.ts index f890dcd94..2cd8b4e41 100644 --- a/app/src/lib/app-theme.ts +++ b/app/src/lib/app-theme.ts @@ -15,6 +15,14 @@ export const appTheme = extendTheme({ alternative: "#001EA7", }, + sectors: { + I: "#575BF4", + II: "#DF2222", + III: "#F28C37", + IV: "#2D0D58", + V: "#CC6B1D", + }, + semantic: { success: "#24BE00", successOverlay: "#EFFDE5", diff --git a/app/src/util/constants.ts b/app/src/util/constants.ts index 0b090744d..799d01473 100644 --- a/app/src/util/constants.ts +++ b/app/src/util/constants.ts @@ -3,6 +3,7 @@ import { PiPlant, PiTrashLight } from "react-icons/pi"; import { TbBuildingCommunity } from "react-icons/tb"; import { IconBaseProps } from "react-icons"; import { LiaIndustrySolid } from "react-icons/lia"; +import { appTheme } from "@/lib/app-theme"; // Import the appTheme export const maxPopulationYearDifference = 5; @@ -66,7 +67,7 @@ export const SECTORS: ISector[] = [ name: "stationary-energy", description: "stationary-energy-description", icon: TbBuildingCommunity, - color: "#5785F4", + color: appTheme.colors.sectors["stationary-energy"], inventoryTypes: { [InventoryTypeEnum.GPC_BASIC]: { scopes: [1, 2] }, [InventoryTypeEnum.GPC_BASIC_PLUS]: { scopes: [1, 2, 3] }, @@ -79,7 +80,7 @@ export const SECTORS: ISector[] = [ name: "transportation", description: "transportation-description", icon: BsTruck, - color: "#F17105", + color: appTheme.colors.sectors["transportation"], inventoryTypes: { [InventoryTypeEnum.GPC_BASIC]: { scopes: [1, 2] }, [InventoryTypeEnum.GPC_BASIC_PLUS]: { scopes: [1, 2, 3] }, @@ -92,7 +93,7 @@ export const SECTORS: ISector[] = [ name: "waste", description: "waste-description", icon: PiTrashLight, - color: "#25AC4B", + color: appTheme.colors.sectors["waste"], inventoryTypes: { [InventoryTypeEnum.GPC_BASIC]: { scopes: [1, 3] }, [InventoryTypeEnum.GPC_BASIC_PLUS]: { scopes: [1, 3] }, @@ -105,7 +106,7 @@ export const SECTORS: ISector[] = [ name: "ippu", description: "ippu-description", icon: LiaIndustrySolid, - color: "#BFA937", + color: appTheme.colors.sectors["ippu"], testId: "ippu-sector-card", inventoryTypes: { [InventoryTypeEnum.GPC_BASIC]: { scopes: [] }, @@ -118,7 +119,7 @@ export const SECTORS: ISector[] = [ name: "afolu", description: "afolu-description", icon: PiPlant, - color: "#F5D949", + color: appTheme.colors.sectors["afolu"], testId: "afolu-sector-card", inventoryTypes: { [InventoryTypeEnum.GPC_BASIC]: { scopes: [] }, From 8e36b5fafb441e5e29b295f70f4d235e6626ae27 Mon Sep 17 00:00:00 2001 From: thehighestprimenumber Date: Tue, 7 Jan 2025 11:23:17 -0300 Subject: [PATCH 14/17] [ON-3141] save colours in theme --- app/src/lib/app-theme.ts | 18 +++++++++++++----- app/src/util/constants.ts | 16 +++++++++------- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/app/src/lib/app-theme.ts b/app/src/lib/app-theme.ts index 2cd8b4e41..29613b674 100644 --- a/app/src/lib/app-theme.ts +++ b/app/src/lib/app-theme.ts @@ -1,5 +1,13 @@ import { extendTheme, theme } from "@chakra-ui/react"; +export enum SectorColors { + I = "#575BF4", + II = "#DF2222", + III = "#F28C37", + IV = "#2D0D58", + V = "#CC6B1D", +} + export const appTheme = extendTheme({ colors: { brand: { @@ -16,11 +24,11 @@ export const appTheme = extendTheme({ }, sectors: { - I: "#575BF4", - II: "#DF2222", - III: "#F28C37", - IV: "#2D0D58", - V: "#CC6B1D", + I: SectorColors.I, + II: SectorColors.II, + III: SectorColors.III, + IV: SectorColors.IV, + V: SectorColors.V, }, semantic: { diff --git a/app/src/util/constants.ts b/app/src/util/constants.ts index 799d01473..5af1b4354 100644 --- a/app/src/util/constants.ts +++ b/app/src/util/constants.ts @@ -3,7 +3,7 @@ import { PiPlant, PiTrashLight } from "react-icons/pi"; import { TbBuildingCommunity } from "react-icons/tb"; import { IconBaseProps } from "react-icons"; import { LiaIndustrySolid } from "react-icons/lia"; -import { appTheme } from "@/lib/app-theme"; // Import the appTheme +import { appTheme, SectorColors } from "@/lib/app-theme"; // Import the appTheme export const maxPopulationYearDifference = 5; @@ -67,7 +67,7 @@ export const SECTORS: ISector[] = [ name: "stationary-energy", description: "stationary-energy-description", icon: TbBuildingCommunity, - color: appTheme.colors.sectors["stationary-energy"], + color: SectorColors.I, inventoryTypes: { [InventoryTypeEnum.GPC_BASIC]: { scopes: [1, 2] }, [InventoryTypeEnum.GPC_BASIC_PLUS]: { scopes: [1, 2, 3] }, @@ -80,7 +80,7 @@ export const SECTORS: ISector[] = [ name: "transportation", description: "transportation-description", icon: BsTruck, - color: appTheme.colors.sectors["transportation"], + color: SectorColors.II, inventoryTypes: { [InventoryTypeEnum.GPC_BASIC]: { scopes: [1, 2] }, [InventoryTypeEnum.GPC_BASIC_PLUS]: { scopes: [1, 2, 3] }, @@ -93,7 +93,7 @@ export const SECTORS: ISector[] = [ name: "waste", description: "waste-description", icon: PiTrashLight, - color: appTheme.colors.sectors["waste"], + color: SectorColors.III, inventoryTypes: { [InventoryTypeEnum.GPC_BASIC]: { scopes: [1, 3] }, [InventoryTypeEnum.GPC_BASIC_PLUS]: { scopes: [1, 3] }, @@ -106,7 +106,7 @@ export const SECTORS: ISector[] = [ name: "ippu", description: "ippu-description", icon: LiaIndustrySolid, - color: appTheme.colors.sectors["ippu"], + color: SectorColors.IV, testId: "ippu-sector-card", inventoryTypes: { [InventoryTypeEnum.GPC_BASIC]: { scopes: [] }, @@ -119,7 +119,7 @@ export const SECTORS: ISector[] = [ name: "afolu", description: "afolu-description", icon: PiPlant, - color: appTheme.colors.sectors["afolu"], + color: SectorColors.V, testId: "afolu-sector-card", inventoryTypes: { [InventoryTypeEnum.GPC_BASIC]: { scopes: [] }, @@ -128,7 +128,9 @@ export const SECTORS: ISector[] = [ }, ]; -export const allSectorColors = SECTORS.map((sector) => sector.color); +export const allSectorColors = SECTORS.map((sector) => { + return sector.color; +}); export const getSectorByName = (name: string) => SECTORS.find((s) => s.name === name); From 00d395dd33249d2e2b0825b61d8d4897f533b617 Mon Sep 17 00:00:00 2001 From: thehighestprimenumber Date: Tue, 7 Jan 2025 11:23:56 -0300 Subject: [PATCH 15/17] [ON-3141] apply colors to EmissionsForecastChart.tsx --- .../EmissionsForecast/EmissionsForecastChart.tsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app/src/app/[lng]/[inventory]/InventoryResultTab/EmissionsForecast/EmissionsForecastChart.tsx b/app/src/app/[lng]/[inventory]/InventoryResultTab/EmissionsForecast/EmissionsForecastChart.tsx index 0e4137644..5b0e64e16 100644 --- a/app/src/app/[lng]/[inventory]/InventoryResultTab/EmissionsForecast/EmissionsForecastChart.tsx +++ b/app/src/app/[lng]/[inventory]/InventoryResultTab/EmissionsForecast/EmissionsForecastChart.tsx @@ -1,6 +1,11 @@ import { EmissionsForecastData } from "@/util/types"; import { TFunction } from "i18next/typescript/t"; -import { getReferenceNumberByName, SECTORS, ISector } from "@/util/constants"; +import { + getReferenceNumberByName, + SECTORS, + ISector, + allSectorColors, +} from "@/util/constants"; import { Badge, Box, @@ -55,7 +60,6 @@ export const EmissionsForecastChart = ({ const data = convertToLineChartData(forecast); - const colors = ["#FFAB51", "#5162FF", "#51ABFF", "#D45252", "#CFAE53"]; return ( convertKgToTonnes(value), }} - colors={colors} + colors={allSectorColors} tooltip={({ point }) => { const year = point.data.x; const sumOfYs = data.reduce((sum, series) => { @@ -122,7 +126,7 @@ export const EmissionsForecastChart = ({ {series.id} From 1792dc44b8b33a3a4bbd80dc80e51b9f7ff5a3f5 Mon Sep 17 00:00:00 2001 From: thehighestprimenumber Date: Tue, 7 Jan 2025 12:47:33 -0300 Subject: [PATCH 16/17] [ON-3100] add growth rate to tooltip --- .../EmissionsForecastChart.tsx | 35 ++++++++++++------- app/src/backend/OpenClimateService.ts | 3 +- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/app/src/app/[lng]/[inventory]/InventoryResultTab/EmissionsForecast/EmissionsForecastChart.tsx b/app/src/app/[lng]/[inventory]/InventoryResultTab/EmissionsForecast/EmissionsForecastChart.tsx index 5b0e64e16..7306bac63 100644 --- a/app/src/app/[lng]/[inventory]/InventoryResultTab/EmissionsForecast/EmissionsForecastChart.tsx +++ b/app/src/app/[lng]/[inventory]/InventoryResultTab/EmissionsForecast/EmissionsForecastChart.tsx @@ -1,10 +1,10 @@ import { EmissionsForecastData } from "@/util/types"; import { TFunction } from "i18next/typescript/t"; import { + allSectorColors, getReferenceNumberByName, - SECTORS, ISector, - allSectorColors, + SECTORS, } from "@/util/constants"; import { Badge, @@ -15,11 +15,13 @@ import { Tbody, Td, Text, + Tfoot, Th, + Thead, Tr, } from "@chakra-ui/react"; +import { convertKgToTonnes, toKebabCase } from "@/util/helpers"; import { ResponsiveLine } from "@nivo/line"; -import { convertKgToTonnes } from "@/util/helpers"; interface LineChartData { id: string; @@ -108,6 +110,14 @@ export const EmissionsForecastChart = ({ + + + + + + + + {data.map((series, index) => { const yearData = series.data.find( @@ -117,9 +127,11 @@ export const EmissionsForecastChart = ({ ? ((yearData.y / sumOfYs) * 100).toFixed(2) : 0; const sectorRefNo = getReferenceNumberByName( - point.serieId as keyof ISector, + toKebabCase(point.serieId as string) as keyof ISector, ); - + const yearGrowthRates = + yearData && forecast.growthRates[yearData.x as string]; + const growthRate = yearGrowthRates?.[sectorRefNo!]; return ( - + ); })} + + + - +
{t("sector")}{t("rate")}%{t("total-emissions")}
@@ -131,13 +143,7 @@ export const EmissionsForecastChart = ({ /> {series.id} - { - forecast.growthRates[point.data.x as number]?.[ - sectorRefNo! - ] - } - {growthRate} {percentage}% {convertKgToTonnes( @@ -147,12 +153,15 @@ export const EmissionsForecastChart = ({
{t("total")} {convertKgToTonnes(sumOfYs)}
diff --git a/app/src/backend/OpenClimateService.ts b/app/src/backend/OpenClimateService.ts index 80c456756..4513b4564 100644 --- a/app/src/backend/OpenClimateService.ts +++ b/app/src/backend/OpenClimateService.ts @@ -11,8 +11,7 @@ export const getGrowthRatesFromOC = async ( try { const URL = `${GLOBAL_API_URL}/api/v0/ghgi/emissions_forecast/city/${encodeURIComponent(locode)}/${forecastYear}`; const response = await fetch(URL); - logger.info(`getGrowthRatesFromOC URL: ${URL}`); - logger.info(`getGrowthRatesFromOC Status: ${response.status}`); + logger.info(`${URL} Response Status: ${response.status}`); const data = await response.json(); return { ...data, From 4c0a7f869bbed553068c6e6d44734cc895a90437 Mon Sep 17 00:00:00 2001 From: thehighestprimenumber Date: Tue, 7 Jan 2025 15:36:22 -0300 Subject: [PATCH 17/17] [ON-3141] chore: fix build --- app/src/components/password-input.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/components/password-input.tsx b/app/src/components/password-input.tsx index e36406766..2b095c252 100644 --- a/app/src/components/password-input.tsx +++ b/app/src/components/password-input.tsx @@ -188,7 +188,7 @@ export default function PasswordInput({ letterSpacing="wide" color="content.tertiary" > - {t(error.message)} + {t(error.message || "")}
)}