Page / Route
Homepage (/)
Selected Location
No response
Bug Description
Description
When fetching waterbody data, the helper transformName in getWaterbodyData.jsx does not behave as documented for names without parentheses. The comment says that if there are no parentheses, the name should be repeated twice, but the code currently only keeps it once. This changes the generated layer names and can cause vector layer fetches to fail.
File
src/actions/getWaterbodyData.jsx
Buggy code
const transformName = (name) => {
if (!name) return "";
// Extract base + alias from parentheses
const match = name.match(/^(.+?)\s*((.+?))$/);
let parts = [];
if (match) {
const main = match[1];
const alias = match[2];
parts = [main, alias];
} else {
// no parentheses → repeat twice
parts = [name];
}
return parts
.map((p) =>
p
.replace(/[^\w\s-]/g, "") // remove special chars
.replace(/\s+/g, "") // Space
.replace(/+/g, "") // collapse _
.replace(/^|$/g, "") // trim _
.toLowerCase()
)
.join("");
};
Issue
The comment states: // no parentheses → repeat twice
The implementation uses parts = [name];, so the name is only used once.
As a result, districts/blocks without an alias produce different dist / blk strings than intended, leading to mismatched wbLayerName, mwsLayerName, and possibly failed getVectorLayers calls.
Expected behavior
For a name without parentheses (e.g. "Some District"), transformName should behave as if the name appeared twice, so the resulting key follows the same convention as when a (alias) is present.
Example:
Input: "Some District"
Expected parts: ["Some District", "Some District"]
Expected output (after normalization): "some_district_some_district"
Actual behavior
Input: "Some District"
Actual parts: ["Some District"]
Actual output: "some_district"
This mismatch can cause layer name construction like:
const wbLayerName = surface_waterbodies_${dist}_${blk};
to differ from the backend’s expected naming scheme.
Proposed fix
Change the else branch to actually repeat the name:
} else {
// no parentheses → repeat twice
parts = [name, name];
}
This makes the behavior consistent with the comment and with the assumed naming convention for districts/blocks without an alias
Steps to Reproduce
Start the app and navigate to any view that triggers getWaterbodyData (e.g. the KYL dashboard / waterbody map view).
Select a district and block whose names do NOT contain parentheses, e.g. "Some District" instead of "Some District (Alias)".
Trigger the waterbody data fetch (for example, by selecting a waterbody or loading the waterbody layer for that district/block).
Observe in the network/dev tools or logs that the constructed layer names use only the single normalized name (e.g. some_district) instead of the repeated form (e.g. some_district_some_district), and that the corresponding vector layer fails to load or returns no features because the backend expects the repeated-name format.
Expected Behavior
When getWaterbodyData is called with a district or block name without parentheses, the transformName helper should:
Treat the name as if it appeared twice (as documented by the comment),
Normalize both copies and join them with an underscore,
Produce layer keys that match the backend naming convention (e.g. "Some District" → "some_district_some_district"),
so that wbLayerName, mwsLayerName, and related layer identifiers correctly match existing vector layers and the waterbody data loads successfully.
Filters Applied
No response
Screenshots / Logs
No response
Browser
None
Page / Route
Homepage (/)
Selected Location
No response
Bug Description
Description
When fetching waterbody data, the helper transformName in getWaterbodyData.jsx does not behave as documented for names without parentheses. The comment says that if there are no parentheses, the name should be repeated twice, but the code currently only keeps it once. This changes the generated layer names and can cause vector layer fetches to fail.
File
src/actions/getWaterbodyData.jsx
Buggy code
const transformName = (name) => {
if (!name) return "";
// Extract base + alias from parentheses
const match = name.match(/^(.+?)\s*((.+?))$/);
let parts = [];
if (match) {
const main = match[1];
const alias = match[2];
parts = [main, alias];
} else {
// no parentheses → repeat twice
parts = [name];
}
return parts
.map((p) =>
p
.replace(/[^\w\s-]/g, "") // remove special chars
.replace(/\s+/g, "") // Space
.replace(/+/g, "") // collapse _
.replace(/^|$/g, "") // trim _
.toLowerCase()
)
.join("");
};
Issue
The comment states: // no parentheses → repeat twice
The implementation uses parts = [name];, so the name is only used once.
As a result, districts/blocks without an alias produce different dist / blk strings than intended, leading to mismatched wbLayerName, mwsLayerName, and possibly failed getVectorLayers calls.
Expected behavior
For a name without parentheses (e.g. "Some District"), transformName should behave as if the name appeared twice, so the resulting key follows the same convention as when a (alias) is present.
Example:
Input: "Some District"
Expected parts: ["Some District", "Some District"]
Expected output (after normalization): "some_district_some_district"
Actual behavior
Input: "Some District"
Actual parts: ["Some District"]
Actual output: "some_district"
This mismatch can cause layer name construction like:
const wbLayerName =
surface_waterbodies_${dist}_${blk};to differ from the backend’s expected naming scheme.
Proposed fix
Change the else branch to actually repeat the name:
} else {
// no parentheses → repeat twice
parts = [name, name];
}
This makes the behavior consistent with the comment and with the assumed naming convention for districts/blocks without an alias
Steps to Reproduce
Start the app and navigate to any view that triggers getWaterbodyData (e.g. the KYL dashboard / waterbody map view).
Select a district and block whose names do NOT contain parentheses, e.g. "Some District" instead of "Some District (Alias)".
Trigger the waterbody data fetch (for example, by selecting a waterbody or loading the waterbody layer for that district/block).
Observe in the network/dev tools or logs that the constructed layer names use only the single normalized name (e.g. some_district) instead of the repeated form (e.g. some_district_some_district), and that the corresponding vector layer fails to load or returns no features because the backend expects the repeated-name format.
Expected Behavior
When getWaterbodyData is called with a district or block name without parentheses, the transformName helper should:
Treat the name as if it appeared twice (as documented by the comment),
Normalize both copies and join them with an underscore,
Produce layer keys that match the backend naming convention (e.g. "Some District" → "some_district_some_district"),
so that wbLayerName, mwsLayerName, and related layer identifiers correctly match existing vector layers and the waterbody data loads successfully.
Filters Applied
No response
Screenshots / Logs
No response
Browser
None