Skip to content

Commit

Permalink
Merge pull request #1028 from Open-Earth-Foundation/fix/disable-oncli…
Browse files Browse the repository at this point in the history
…ck-action-for-disabled-methodologies

FIX(UI): prevents disbled methodologies from being clicked
  • Loading branch information
cephaschapa authored Dec 27, 2024
2 parents bc84014 + 752338c commit 64fc3ae
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 5 deletions.
28 changes: 27 additions & 1 deletion app/src/components/Cards/methodology-card.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Badge, Box, Card, Radio, Text } from "@chakra-ui/react";
import { Badge, Box, Card, Radio, Text, useToast } from "@chakra-ui/react";
import { TFunction } from "i18next";
import React, { FC, useState } from "react";
import type { Methodology } from "@/util/form-schema";
import { InfoIcon } from "@chakra-ui/icons";

interface MethodologyCardProps {
id: string;
Expand Down Expand Up @@ -29,7 +30,32 @@ const MethodologyCard: FC<MethodologyCardProps> = ({
});
};

const toast = useToast();

const handleCardClick = () => {
if (disabled) {
toast({
status: "error",
title: t("selected-methodology-disabled"),
render: ({ title }) => (
<Box
h="48px"
w="600px"
borderRadius="8px"
display="flex"
alignItems="center"
color="white"
backgroundColor="content.alternative"
gap="8px"
px="16px"
>
<InfoIcon />
<Text>{title}</Text>
</Box>
),
});
return;
}
if (!isSelected) {
handleCardSelect({
disabled,
Expand Down
3 changes: 2 additions & 1 deletion app/src/i18n/locales/de/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -1109,5 +1109,6 @@
"livestock-direct-measure-methodology-description": "Direkte Messung der Emissionen von Vieh",
"land-direct-measure-methodology-description": "Direkte Messung der Emissionen vom Land",
"aggregate-sources-and-non-co2-emission-sources-direct-measure-methodology-description": "Direkte Messung der Emissionen aus aggregierten Quellen und Nicht-CO2-Emissionen",
"emissions-from-aggregate-sources-and-non-co2-emission-sources-on-land-within-the-city-boundary-description": "Umfasst alle Emissionen aus aggregierten Quellen wie Kalkung und Harnstoffanwendung sowie nicht-CO2-Gase, die durch Landnutzungsaktivitäten innerhalb der Stadtgrenzen emittiert werden."
"emissions-from-aggregate-sources-and-non-co2-emission-sources-on-land-within-the-city-boundary-description": "Umfasst alle Emissionen aus aggregierten Quellen wie Kalkung und Harnstoffanwendung sowie nicht-CO2-Gase, die durch Landnutzungsaktivitäten innerhalb der Stadtgrenzen emittiert werden.",
"selected-methodology-disabled": "Die ausgewählte Methodik ist deaktiviert"
}
3 changes: 2 additions & 1 deletion app/src/i18n/locales/en/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -1111,5 +1111,6 @@
"livestock-direct-measure-methodology-description": "Direct measurement of emissions from livestock",
"land-direct-measure-methodology-description": "Direct measurement of emissions from land",
"aggregate-sources-and-non-co2-emission-sources-direct-measure-methodology-description": "Direct measurement of emissions from aggregate sources and non co2 emissions",
"emissions-from-aggregate-sources-and-non-co2-emission-sources-on-land-within-the-city-boundary-description": "Includes all emissions from aggregate sources such as liming and urea application, as well as non-CO2 gases emitted from land use activities within the city's boundaries."
"emissions-from-aggregate-sources-and-non-co2-emission-sources-on-land-within-the-city-boundary-description": "Includes all emissions from aggregate sources such as liming and urea application, as well as non-CO2 gases emitted from land use activities within the city's boundaries.",
"selected-methodology-disabled": "This methodology is disabled"
}
3 changes: 2 additions & 1 deletion app/src/i18n/locales/es/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -1096,5 +1096,6 @@
"livestock-direct-measure-methodology-description": "Medición directa de emisiones del ganado",
"land-direct-measure-methodology-description": "Medición directa de emisiones de la tierra",
"aggregate-sources-and-non-co2-emission-sources-direct-measure-methodology-description": "Medición directa de emisiones de fuentes agregadas y emisiones no CO2",
"emissions-from-aggregate-sources-and-non-co2-emission-sources-on-land-within-the-city-boundary-description": "Incluye todas las emisiones de fuentes agregadas como encalado y aplicación de urea, así como gases no CO2 emitidos por actividades de uso de la tierra dentro de los límites de la ciudad."
"emissions-from-aggregate-sources-and-non-co2-emission-sources-on-land-within-the-city-boundary-description": "Incluye todas las emisiones de fuentes agregadas como encalado y aplicación de urea, así como gases no CO2 emitidos por actividades de uso de la tierra dentro de los límites de la ciudad.",
"selected-methodology-disabled": "La metodología seleccionada está deshabilitada"
}
3 changes: 2 additions & 1 deletion app/src/i18n/locales/pt/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -1088,5 +1088,6 @@
"livestock-direct-measure-methodology-description": "Medição direta de emissões do gado",
"land-direct-measure-methodology-description": "Medição direta de emissões da terra",
"aggregate-sources-and-non-co2-emission-sources-direct-measure-methodology-description": "Medição direta de emissões de fontes agregadas e emissões não CO2",
"emissions-from-aggregate-sources-and-non-co2-emission-sources-on-land-within-the-city-boundary-description": "Inclui todas as emissões de fontes agregadas, como calagem e aplicação de ureia, bem como gases não CO2 emitidos por atividades de uso da terra dentro dos limites da cidade."
"emissions-from-aggregate-sources-and-non-co2-emission-sources-on-land-within-the-city-boundary-description": "Inclui todas as emissões de fontes agregadas, como calagem e aplicação de ureia, bem como gases não CO2 emitidos por atividades de uso da terra dentro dos limites da cidade.",
"selected-methodology-disabled": "Esta metodologia foi desativada"
}

0 comments on commit 64fc3ae

Please sign in to comment.