Skip to content

Commit

Permalink
Add units to analysis table individual indicators
Browse files Browse the repository at this point in the history
  • Loading branch information
barbara-chaves authored and davidsingal committed Oct 11, 2023
1 parent a994182 commit 385f39e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
2 changes: 2 additions & 0 deletions client/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
### Fixed

- Enable map popup for h3 contextual layers [LANDGRIF-1484](https://vizzuality.atlassian.net/browse/LANDGRIF-1484)
- 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]
Expand Down
6 changes: 3 additions & 3 deletions client/src/containers/admin/data-upload-error/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const DataUploadError: React.FC<DataUploadErrorProps> = ({ task }) => {
<h3>Upload completed</h3>
<p className="text-gray-500">
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.
</p>
</>
Expand All @@ -82,7 +82,7 @@ const DataUploadError: React.FC<DataUploadErrorProps> = ({ task }) => {
<h3>Upload failed</h3>
<p className="text-gray-500">
Sorry, we couldn&apos;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{' '}
<strong className="text-gray-900">reverted to the previous version</strong> to avoid
data loss. Please try uploading again.
</p>
Expand All @@ -94,7 +94,7 @@ const DataUploadError: React.FC<DataUploadErrorProps> = ({ task }) => {
<h3>Upload failed</h3>
<p className="text-gray-500">
Sorry, we couldn&apos;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{' '}
<strong className="text-gray-900">reverted to the previous version</strong> to avoid
data loss. There had been{' '}
<strong className="text-gray-900">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
<Mode extends ComparisonMode>(year: number): ColumnDefinition<ImpactRowType<Mode>> => {
const valueIsComparison = (
Expand All @@ -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);
Expand Down Expand Up @@ -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(
Expand All @@ -348,15 +348,15 @@ const AnalysisTable = () => {
id: 'name',
header: () => (
<div>
{!!expandedName ? (
{!!expanded?.name ? (
<Button
className="pt-1 pb-1 pr-0 pl-0 border-0 bg-transparent"
variant="transparent"
onClick={handleExitExpanded}
>
<div className="flex text-gray-900 text-sm text-start font-semibold max-w-[200px] whitespace-normal">
<ArrowLeftIcon className="mr-3.5 w-4 h-4" />
{expandedName}
{expanded.name}
</div>
</Button>
) : (
Expand All @@ -377,11 +377,11 @@ const AnalysisTable = () => {

return (
<div className="py-5 flex gap-4">
{!expandedName && (
{!expanded?.name && (
<InformationCircleIcon className="w-4 h-4 text-gray-900 shrink-0" />
)}
<div>
{expandedName ? (
{expanded?.name ? (
original.name
) : (
<div className="block font-semibold">
Expand All @@ -390,7 +390,7 @@ const AnalysisTable = () => {
</div>
)}

{!expandedName && isParentRow(original) && (
{!expanded?.name && isParentRow(original) && (
<Button
variant="white"
className="mt-4"
Expand Down Expand Up @@ -429,7 +429,7 @@ const AnalysisTable = () => {
},
...years.map((year) => comparisonColumn<Mode>(year as number)),
],
[years, expandedName, handleExitExpanded, indicators, handleExpandRow, comparisonColumn],
[years, expanded?.name, handleExitExpanded, indicators, handleExpandRow, comparisonColumn],
);

const tableProps = useMemo(
Expand Down

0 comments on commit 385f39e

Please sign in to comment.