Skip to content

Commit

Permalink
Merge pull request #387 from Open-Earth-Foundation/fix/third-party-units
Browse files Browse the repository at this point in the history
Show error if population is missing for downscaled data sources on SourceDrawer
  • Loading branch information
lemilonkh committed Mar 29, 2024
2 parents 8fe2247 + f161dfa commit 1180bc7
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 17 deletions.
27 changes: 18 additions & 9 deletions app/src/app/[lng]/[inventory]/data/[step]/SourceDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,13 @@ export function SourceDrawer({
t: TFunction;
}) {
const emissionsData = sourceData?.totals?.emissions?.co2eq_100yr;
// TODO scale this down for country data sources
const totalEmissions = emissionsData
let totalEmissions = emissionsData
? ((Number(emissionsData) * sourceData?.scaleFactor) / 1000).toFixed(2)
: "?";
if (sourceData?.issue) {
totalEmissions = "?";
}

return (
<Drawer
isOpen={isOpen}
Expand All @@ -84,7 +87,7 @@ export function SourceDrawer({
<DrawerBody className="space-y-6 overflow-auto" px={0}>
<Icon as={MdHomeWork} boxSize={9} />
<Heading
size="sm"
size="title.sm"
color="content.link"
textTransform="uppercase"
letterSpacing="1.25px"
Expand All @@ -94,7 +97,7 @@ export function SourceDrawer({
{source.subcategoryId ? "Scope Data" : "Sub-sector Data"}
</Heading>
<Heading
size="sm"
size="title.sm"
color="content.tertiary"
textTransform="uppercase"
letterSpacing="1.25px"
Expand All @@ -114,7 +117,7 @@ export function SourceDrawer({
{source.datasetName}
</Heading>

<Heading size="sm">
<Heading size="title.sm">
{source.subCategory?.referenceNumber ||
source.subSector?.referenceNumber}{" "}
{source.subCategory?.subcategoryName ||
Expand All @@ -141,7 +144,7 @@ export function SourceDrawer({
</Link>
</Text>

<Heading size="sm">
<Heading size="title.sm">
{t("total-emissions-included")}{" "}
<Tooltip
hasArrow
Expand Down Expand Up @@ -171,6 +174,12 @@ export function SourceDrawer({
</Text>
</HStack>

{sourceData?.issue && (
<Text color="semantic.danger" size="body.sm" mt={-4}>
{t("error")}: {t(sourceData?.issue)}
</Text>
)}

<Flex
direction="row"
my={4}
Expand Down Expand Up @@ -244,13 +253,13 @@ export function SourceDrawer({
</Flex>

<Stack className="space-y-4">
<Heading size="sm">{t("inside-dataset")}</Heading>
<Heading size="title.sm">{t("inside-dataset")}</Heading>
<Text color="content.tertiary">
{source.datasetDescription}
</Text>
<chakra.hr borderColor="border.neutral" />
<Heading
size="sm"
size="title.sm"
verticalAlign="baseline"
lineHeight="24px"
fontSize="16px"
Expand All @@ -274,7 +283,7 @@ export function SourceDrawer({
{source.methodologyDescription}
</Text>
<Heading
size="sm"
size="title.sm"
verticalAlign="baseline"
lineHeight="24px"
fontSize="16px"
Expand Down
4 changes: 2 additions & 2 deletions app/src/app/api/v0/datasource/[inventoryId]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ export const GET = apiHandler(async (_req: NextRequest, { params }) => {
!population.countryPopulation ||
!population.regionPopulation
) {
// City is missing population/ region population/ country population for the inventory year
populationIssue = "missing_population";
// City is missing population/ region population/ country population for a year close to the inventory year
populationIssue = "missing-population"; // translation key
} else {
countryPopulationScaleFactor =
population.population / population.countryPopulation;
Expand Down
9 changes: 7 additions & 2 deletions app/src/i18n/locales/de/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,18 @@
"files-uploaded": "Dateien hochgeladen",
"add-custom": "Benutzerdefiniert",
"save-missing-scope-info": "Speichern oder fehlende Informationen ausfüllen, bevor Sie fortfahren.",
"disconnect-data": "Datenquelle trennen",

"error": "Fehler",
"missing-population": "Der Stadt fehlt die Bevölkerungszahl/ Regionsbevölkerungszahl/ Landesbevölkerungszahl für ein Jahr nahe dem Inventarjahr",

"transform-data-description": "Lorem ipsum dolor sit amet, qui minim labore adipisicing minim sint cillum sint consectetur cupidatat.",
"file-context": "Erzählen Sie uns mehr über diese Datei",
"file-data-subtitle": "Welche Art von Daten enthält sie?",
"file-data-description": "Wählen Sie aus den folgenden Optionen. Dies wird uns helfen, diese Informationen besser zu identifizieren und in Ihre Bestandsaufnahme aufzunehmen.",
"select-subsector-label": "Untersektoren auswählen",
"scopes": "Bereiche",
"cancel": "Abbrechen",
"upload": "Hochladen",
"select-placeholder": "Wählen Sie die Untersektoren aus, die in dieser Datei enthalten sind",
"disconnect-data": "Datenquelle trennen"
"select-placeholder": "Wählen Sie die Untersektoren aus, die in dieser Datei enthalten sind"
}
9 changes: 7 additions & 2 deletions app/src/i18n/locales/en/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,18 @@
"city": "City",
"inside-dataset": "What's inside this dataset",
"transform-data-heading": "How do we transform this data?",
"transform-data-description": "Lorem ipsum dolor sit amet, qui minim labore adipisicing minim sint cillum sint consectetur cupidatat.",
"disconnect-data": "Disconnect Data",

"error": "Error",
"missing-population": "City is missing population/ region population/ country population for a year close to the inventory year",

"file-context": "Tell Us More About This File",
"file-data-subtitle": "What type of data is contained in it?",
"file-data-description": " Choose from the options below. This will help us to better identify and include this information in your inventory.",
"select-subsector-label": "Select Sub-sectors",
"scopes": "Scopes",
"cancel": "Cancel",
"upload": "Upload",
"select-placeholder": "Select the sub-sectors included in this file",
"disconnect-data": "Disconnect Data"
"select-placeholder": "Select the sub-sectors included in this file"
}
9 changes: 7 additions & 2 deletions app/src/i18n/locales/es/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@
"files-uploaded": "Archivos subidos",
"add-custom": "Agregar personalizado",
"save-missing-scope-info": "Guarde o complete la información faltante antes de continuar.",
"disconnect-data": "Desconectar fuente de datos",

"error": "Error",
"missing-population": "A la ciudad le falta población/población de región/población de país para un año cercano al año del inventario",

"transform-data-description": "Lorem ipsum dolor sit amet, qui minim labore adipisicing minim sint cillum sint consectetur cupidatat.",
"file-context": "Cuéntanos más sobre este archivo",
"file-data-subtitle": "¿Qué tipo de datos contiene?",
"file-data-description": "Elija entre las opciones a continuación. Esto nos ayudará a identificar e incluir mejor esta información en su inventario.",
Expand All @@ -122,6 +128,5 @@
"cancel": "Cancelar",
"upload": "Subir",
"select-placeholder": "Seleccione los subsectores incluidos en este archivo",
"mark-as-completed": "Marcar como completado",
"disconnect-data": "Desconectar fuente de datos"
"mark-as-completed": "Marcar como completado"
}

0 comments on commit 1180bc7

Please sign in to comment.