Skip to content

Commit

Permalink
Merge pull request #558 from Open-Earth-Foundation/fix/manual-input-r…
Browse files Browse the repository at this point in the history
…egactor

Fix/manual input refactor
  • Loading branch information
cephaschapa committed Jul 11, 2024
2 parents cdba4a8 + be98519 commit dcbac7c
Show file tree
Hide file tree
Showing 13 changed files with 1,116 additions and 2,674 deletions.
2,232 changes: 50 additions & 2,182 deletions app/src/app/[lng]/[inventory]/data/[step]/[subsector]/page.tsx

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions app/src/app/[lng]/[inventory]/data/[step]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,7 @@ export default function AddDataSteps({
sectorId: subSector.sectorId,
subsectorId: subSector.subsectorId,
referenceNumber: subSector.referenceNumber,
subCategories: subSector.subCategories,
}),
);
router.push(
Expand Down
31 changes: 23 additions & 8 deletions app/src/components/Cards/methodology-card.tsx
Original file line number Diff line number Diff line change
@@ -1,34 +1,49 @@
import { Badge, Box, Card, Radio, Text } from "@chakra-ui/react";
import { TFunction } from "i18next";
import React, { FC, useState } from "react";
import { MethodologyValues } from "../Tabs/Activity/activity-tab";

interface MethodologyCardProps {
name: string;
methodologyId: string;
methodologyName: string;
description: string;
inputRequired: string[];
isSelected: boolean;
disabled: boolean;
t: TFunction;
handleCardSelect: (methodologyName: string) => void;
handleCardSelect: (methodologyId: MethodologyValues) => void;
}

const MethodologyCard: FC<MethodologyCardProps> = ({
name,
methodologyId,
methodologyName,
description,
inputRequired,
disabled,
t,
handleCardSelect = (_methodologyName: string) => {},
handleCardSelect = (_methodologyId: MethodologyValues) => {},
}) => {
const [isSelected, setIsSelected] = useState(false);
const handleRadioChange = () => {
setIsSelected(true);
handleCardSelect(name);
handleCardSelect({
description,
disabled,
inputRequired,
methodologyId,
methodologyName,
});
};

const handleCardClick = () => {
if (!isSelected) {
handleCardSelect(name);
handleCardSelect({
description,
disabled,
inputRequired,
methodologyId,
methodologyName,
});
}
setIsSelected(!isSelected);
};
Expand Down Expand Up @@ -74,7 +89,7 @@ const MethodologyCard: FC<MethodologyCardProps> = ({
)}
</Box>
<Text fontWeight="bold" fontSize="title.md" fontFamily="heading">
{name}
{methodologyName}
</Text>
<Text
letterSpacing="wide"
Expand All @@ -100,7 +115,7 @@ const MethodologyCard: FC<MethodologyCardProps> = ({
fontWeight="normal"
color="interactive.control"
>
{inputRequired.map((item: string, i: number) => (
{inputRequired?.map((item: string, i: number) => (
<li key={i}>{item}</li>
))}
</Box>
Expand Down
Loading

0 comments on commit dcbac7c

Please sign in to comment.