Skip to content

Commit

Permalink
[TM-1283] add condition to avoid showing undefined values in error me…
Browse files Browse the repository at this point in the history
…ssagin in validation (#491)
  • Loading branch information
cesarLima1 authored Sep 16, 2024
1 parent 1e3428c commit e7c519a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/hooks/useMessageValidations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export const useMessageValidators = () => {

if (total_area_site === null) {
messages.push(t("Site Goal: A goal has not been specified."));
} else {
} else if (sum_area_site !== undefined && percentage_site !== undefined && total_area_site !== undefined) {
messages.push(
t(
"Site Goal: The sum of all site polygons {sum_area_site} ha is {percentage_site}% of total hectares to be restored for this site ({total_area_site} ha)",
Expand All @@ -128,21 +128,27 @@ export const useMessageValidators = () => {

if (total_area_project === null) {
messages.push(t("Project Goal: A goal has not been specified."));
} else {
} else if (
sum_area_project !== undefined &&
percentage_project !== undefined &&
total_area_project !== undefined
) {
messages.push(
t(
"Project Goal: The sum of all project polygons {sum_area_project} ha is {percentage_project}% of total hectares to be restored ({total_area_project} ha)",
{ sum_area_project, percentage_project, total_area_project }
)
);
}

return messages;
} catch {
return [t("Error parsing extra info.")];
}
},
[t]
);

const getFormatedExtraInfo = useMemo(
() => (extraInfo: string | undefined, criteria_id: any) => {
if (criteria_id === 12) {
Expand Down

0 comments on commit e7c519a

Please sign in to comment.