Skip to content

Commit 4e74470

Browse files
authored
fix: 1142 improve frontend consistency (#1170)
1 parent 642f25e commit 4e74470

File tree

6 files changed

+28
-26
lines changed

6 files changed

+28
-26
lines changed

frontend/src/__test__/components/SpatialCheckbox.test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ describe("SpatialCheckbox", () => {
2323

2424
// Check if the checkbox is in the document
2525
const button = screen.getByRole("button", {
26-
name: /click to view this opening's map activity/i,
26+
name: /Click to view this opening on the map/i,
2727
});
2828
expect(button).toBeInTheDocument();
2929
});
@@ -38,7 +38,7 @@ describe("SpatialCheckbox", () => {
3838
);
3939

4040
const button = screen.getByRole("button", {
41-
name: /click to view this opening's map activity/i,
41+
name: /Click to view this opening on the map/i,
4242
});
4343
expect(button).toHaveClass("spatial-checkbox-checked");
4444
});
@@ -53,7 +53,7 @@ describe("SpatialCheckbox", () => {
5353
);
5454

5555
const button = screen.getByRole("button", {
56-
name: /click to view this opening's map activity/i,
56+
name: /Click to view this opening on the map/i,
5757
});
5858

5959
// Simulate a click on the button

frontend/src/components/OpeningDetails/OpeningForestCover/ForestCoverExpandedRow/ForestManagement/LayerTable.tsx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
TableHead, TableHeader, TableRow
66
} from "@carbon/react";
77
import { TreeFallRisk } from "@carbon/icons-react";
8-
import { NOT_APPLICABLE, PLACE_HOLDER, UNIQUE_CHARACTERS_UNICODE } from "@/constants";
8+
import { PLACE_HOLDER, UNIQUE_CHARACTERS_UNICODE } from "@/constants";
99
import { OpeningForestCoverDamageDto, OpeningForestCoverLayerDto } from "@/services/OpenApi";
1010
import { codeDescriptionToDisplayText } from "@/utils/multiSelectUtils";
1111
import { DamageAgentTableHeader, LayerTableHeaders } from "./constants";
@@ -112,10 +112,10 @@ const LayerTable = ({ layer }: LayerTableProps) => {
112112
{/* Stems */}
113113
<TableCell className="default-table-cell">
114114
<ul className="cell-content-list">
115-
<li>Total stems: {layer.totalStems ? `${layer.totalStems} (st/ha)` : NOT_APPLICABLE}</li>
116-
<li>Total well spaced: {layer.totalWellSpaced ? `${layer.totalWellSpaced} (st/ha)` : NOT_APPLICABLE}</li>
117-
<li>Well spaced: {layer.wellSpaced ? `${layer.wellSpaced} (st/ha)` : NOT_APPLICABLE}</li>
118-
<li>Free growing: {layer.freeGrowing ? `${layer.freeGrowing} (st/ha)` : NOT_APPLICABLE}</li>
115+
<li>Total stems: {layer.totalStems ? `${layer.totalStems} (st/ha)` : PLACE_HOLDER}</li>
116+
<li>Total well spaced: {layer.totalWellSpaced ? `${layer.totalWellSpaced} (st/ha)` : PLACE_HOLDER}</li>
117+
<li>Well spaced: {layer.wellSpaced ? `${layer.wellSpaced} (st/ha)` : PLACE_HOLDER}</li>
118+
<li>Free growing: {layer.freeGrowing ? `${layer.freeGrowing} (st/ha)` : PLACE_HOLDER}</li>
119119
</ul>
120120
</TableCell>
121121
</TableRow>
@@ -174,7 +174,11 @@ const LayerTable = ({ layer }: LayerTableProps) => {
174174
</Column>
175175
</>
176176
)
177-
: null
177+
: (
178+
<Column sm={4} md={8} lg={16}>
179+
<p>No damage agent data available for this layer.</p>
180+
</Column>
181+
)
178182
}
179183

180184
</Grid>

frontend/src/components/OpeningDetails/OpeningForestCover/index.tsx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
Modal
1414
} from "@carbon/react";
1515
import { CropGrowth, DiamondOutline, Layers, Popup, Search } from "@carbon/icons-react";
16-
import { NOT_APPLICABLE, PLACE_HOLDER } from "@/constants";
16+
import { PLACE_HOLDER } from "@/constants";
1717
import TableSkeleton from "@/components/TableSkeleton";
1818
import EmptySection from "@/components/EmptySection";
1919
import { StockingStatusTag } from "@/components/Tags";
@@ -155,10 +155,10 @@ const OpeningForestCover = ({
155155
<div className="opening-forest-cover-cell-multiple-lines">
156156
<span>Polygon ID: {row.polygonId}</span>
157157
<span>
158-
Standard unit: {row.standardUnitId ?? NOT_APPLICABLE}
158+
Standard unit: {row.standardUnitId ?? PLACE_HOLDER}
159159
</span>
160160
<span>
161-
Unmapped area: {row.unmappedArea.code ? codeDescriptionToDisplayText(row.unmappedArea) : NOT_APPLICABLE}
161+
Unmapped area: {row.unmappedArea.code ? codeDescriptionToDisplayText(row.unmappedArea) : PLACE_HOLDER}
162162
</span>
163163
</div>
164164
);
@@ -226,12 +226,12 @@ const OpeningForestCover = ({
226226
<span>Species: {displayText}</span>
227227
</DefinitionTooltip>
228228
)
229-
: `Species: ${NOT_APPLICABLE}`
229+
: `Species: ${PLACE_HOLDER}`
230230
}
231-
<span>Total: {row.inventoryLayer.total !== null ? `${row.inventoryLayer.total} (st/ha)` : NOT_APPLICABLE}</span>
232-
<span>Total well spaced: {row.inventoryLayer.totalWellSpaced !== null ? `${row.inventoryLayer.totalWellSpaced} (st/ha)` : NOT_APPLICABLE}</span>
233-
<span>Well spaced: {row.inventoryLayer.wellSpaced !== null ? `${row.inventoryLayer.wellSpaced} (st/ha)` : NOT_APPLICABLE}</span>
234-
<span>Free growing: {row.inventoryLayer.freeGrowing !== null ? `${row.inventoryLayer.freeGrowing} (st/ha)` : NOT_APPLICABLE}</span>
231+
<span>Total: {row.inventoryLayer.total !== null ? `${row.inventoryLayer.total} (st/ha)` : PLACE_HOLDER}</span>
232+
<span>Total well spaced: {row.inventoryLayer.totalWellSpaced !== null ? `${row.inventoryLayer.totalWellSpaced} (st/ha)` : PLACE_HOLDER}</span>
233+
<span>Well spaced: {row.inventoryLayer.wellSpaced !== null ? `${row.inventoryLayer.wellSpaced} (st/ha)` : PLACE_HOLDER}</span>
234+
<span>Free growing: {row.inventoryLayer.freeGrowing !== null ? `${row.inventoryLayer.freeGrowing} (st/ha)` : PLACE_HOLDER}</span>
235235
</div>
236236
);
237237
}
@@ -258,11 +258,11 @@ const OpeningForestCover = ({
258258
<span>Species: {displayText}</span>
259259
</DefinitionTooltip>
260260
)
261-
: `Species: ${NOT_APPLICABLE}`
261+
: `Species: ${PLACE_HOLDER}`
262262
}
263-
<span>Total well spaced: {row.silvicultureLayer.totalWellSpaced !== null ? `${row.silvicultureLayer.totalWellSpaced} (st/ha)` : NOT_APPLICABLE}</span>
264-
<span>Well spaced: {row.silvicultureLayer.wellSpaced !== null ? `${row.silvicultureLayer.wellSpaced} (st/ha)` : NOT_APPLICABLE}</span>
265-
<span>Free growing: {row.silvicultureLayer.freeGrowing !== null ? `${row.silvicultureLayer.freeGrowing} (st/ha)` : NOT_APPLICABLE}</span>
263+
<span>Total well spaced: {row.silvicultureLayer.totalWellSpaced !== null ? `${row.silvicultureLayer.totalWellSpaced} (st/ha)` : PLACE_HOLDER}</span>
264+
<span>Well spaced: {row.silvicultureLayer.wellSpaced !== null ? `${row.silvicultureLayer.wellSpaced} (st/ha)` : PLACE_HOLDER}</span>
265+
<span>Free growing: {row.silvicultureLayer.freeGrowing !== null ? `${row.silvicultureLayer.freeGrowing} (st/ha)` : PLACE_HOLDER}</span>
266266
</div>
267267
);
268268
}

frontend/src/components/SpatialCheckbox/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const SpatialCheckbox: React.FC<SpatialCheckboxProps> = ({
2020
hasIconOnly
2121
renderIcon={selectedRows.includes(rowId) ? LocationFilled : Location}
2222
onClick={() => handleRowSelection(rowId)}
23-
iconDescription="Click to view this opening's map activity"
23+
iconDescription="Click to view this opening on the map"
2424
tooltipPosition="right"
2525
kind="ghost"
2626
size="sm"

frontend/src/constants/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ export enum UNIQUE_CHARACTERS_UNICODE {
3535
PIPE = "\u007C",
3636
};
3737

38-
export const NOT_APPLICABLE = "N/A" as const;
39-
4038
export const REDIRECT_KEY = "postLoginRedirect" as const;
4139

4240
export const SELECTED_CLIENT_KEY = 'SELECTED_CLIENT' as const;

frontend/src/utils/StringUtils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { NOT_APPLICABLE } from "@/constants";
1+
import { PLACE_HOLDER } from "@/constants";
22

33
/**
44
* Converts a string to kebab-case format by replacing spaces with hyphens
@@ -35,6 +35,6 @@ export const renderLabelValueWithUnit = (
3535
value: string | number | null | undefined,
3636
unit: string
3737
): string => {
38-
const display = value ? `${value} ${unit}` : NOT_APPLICABLE;
38+
const display = value ? `${value} ${unit}` : PLACE_HOLDER;
3939
return `${label}: ${display}`;
4040
};

0 commit comments

Comments
 (0)