From aaea386536fa27b0c0c0617638b1b7758c284bee Mon Sep 17 00:00:00 2001 From: barbara-chaves Date: Tue, 10 Oct 2023 16:05:53 +0200 Subject: [PATCH] Add units to analysis table individual indicators --- client/CHANGELOG.md | 2 ++ .../admin/data-upload-error/component.tsx | 6 ++--- .../analysis-table/component.tsx | 26 +++++++++---------- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/client/CHANGELOG.md b/client/CHANGELOG.md index 8be1fc18a5..85a8f8fd43 100644 --- a/client/CHANGELOG.md +++ b/client/CHANGELOG.md @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/). ### Fixed +- Add units to analysis table individual indicators [LANDGRIF-1486](https://vizzuality.atlassian.net/browse/LANDGRIF-1486) +- Fixed error message date for faled data upload [LANDGRIF-1493](https://vizzuality.atlassian.net/browse/LANDGRIF-1493) - Update password in profile form was not working as expected [LANDGRIF-1479](https://vizzuality.atlassian.net/browse/LANDGRIF-1479) ## [v1.0.0] diff --git a/client/src/containers/admin/data-upload-error/component.tsx b/client/src/containers/admin/data-upload-error/component.tsx index 6c9541c99f..a2d8ce054e 100644 --- a/client/src/containers/admin/data-upload-error/component.tsx +++ b/client/src/containers/admin/data-upload-error/component.tsx @@ -55,7 +55,7 @@ const DataUploadError: React.FC = ({ task }) => {

Upload completed

Great news! Your latest changes made on{' '} - {format(new Date(task.createdAt), 'MMM 4, yyyy HH:mm z')} have been successfully + {format(new Date(task.createdAt), 'MMM d, yyyy HH:mm z')} have been successfully uploaded.

@@ -82,7 +82,7 @@ const DataUploadError: React.FC = ({ task }) => {

Upload failed

Sorry, we couldn't upload your latest changes made on{' '} - {format(new Date(task.createdAt), 'MMM 4, yyyy HH:mm z')}. We have{' '} + {format(new Date(task.createdAt), 'MMM d, yyyy HH:mm z')}. We have{' '} reverted to the previous version to avoid data loss. Please try uploading again.

@@ -94,7 +94,7 @@ const DataUploadError: React.FC = ({ task }) => {

Upload failed

Sorry, we couldn't upload your latest changes made on{' '} - {format(new Date(task.createdAt), 'MMM 4, yyyy HH:mm z')}. We have{' '} + {format(new Date(task.createdAt), 'MMM d, yyyy HH:mm z')}. We have{' '} reverted to the previous version to avoid data loss. There had been{' '} diff --git a/client/src/containers/analysis-visualization/analysis-table/component.tsx b/client/src/containers/analysis-visualization/analysis-table/component.tsx index dd9b19c3d9..df9b49b335 100644 --- a/client/src/containers/analysis-visualization/analysis-table/component.tsx +++ b/client/src/containers/analysis-visualization/analysis-table/component.tsx @@ -275,6 +275,11 @@ const AnalysisTable = () => { [isComparison, isScenarioComparison], ); + const expanded = useMemo( + () => (indicatorId === 'all' ? null : indicators.find((i) => i.id === indicatorId)), + [indicatorId, indicators], + ); + const comparisonColumn = useCallback( (year: number): ColumnDefinition> => { const valueIsComparison = ( @@ -297,7 +302,7 @@ const AnalysisTable = () => { true >; - const unit: string = parentRowData.metadata?.unit; + const unit: string = parentRowData.metadata?.unit || expanded?.metadata?.units; const value = data.values?.find((value) => value.year === year); const isComparison = valueIsComparison(value); @@ -334,12 +339,7 @@ const AnalysisTable = () => { }, }; }, - [isComparison, isScenarioComparison, valueIsScenarioComparison], - ); - - const expandedName = useMemo( - () => (indicatorId === 'all' ? null : indicators.find((i) => i.id === indicatorId)?.name), - [indicatorId, indicators], + [expanded, isComparison, isScenarioComparison, valueIsScenarioComparison], ); const baseColumns = useMemo( @@ -348,7 +348,7 @@ const AnalysisTable = () => { id: 'name', header: () => (

- {!!expandedName ? ( + {!!expanded?.name ? ( ) : ( @@ -377,11 +377,11 @@ const AnalysisTable = () => { return (
- {!expandedName && ( + {!expanded?.name && ( )}
- {expandedName ? ( + {expanded?.name ? ( original.name ) : (
@@ -390,7 +390,7 @@ const AnalysisTable = () => {
)} - {!expandedName && isParentRow(original) && ( + {!expanded?.name && isParentRow(original) && (