Skip to content

Commit ae73c1d

Browse files
authored
Merge pull request #3654 from IntersectMBO/fix/3192-proposals-title-missing-from-detail-pages
fix(#3192): fix missing proposals dashboard title
2 parents 1aa41e9 + f57b314 commit ae73c1d

File tree

2 files changed

+31
-8
lines changed

2 files changed

+31
-8
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ changes.
1717

1818
### Fixed
1919

20+
- Fix displaying proposals title in details page [Issue 3192](https://github.com/IntersectMBO/govtool/issues/3192)
21+
2022
### Changed
2123

2224
### Removed

govtool/frontend/src/pages/Dashboard.tsx

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ import { Box } from "@mui/material";
44

55
import { Background, ScrollToManage } from "@atoms";
66
import {
7+
BUDGET_DISCUSSION_PATHS,
78
CONNECTED_NAV_ITEMS,
89
DRAWER_WIDTH,
910
OUTCOMES_PATHS,
1011
PATHS,
12+
PDF_PATHS,
1113
} from "@consts";
1214
import { useCardano } from "@context";
1315
import { useScreenDimension, useTranslation } from "@hooks";
@@ -34,18 +36,37 @@ export const Dashboard = () => {
3436
return outcomesNavItem ?? "";
3537
}
3638

39+
if (path.startsWith(BUDGET_DISCUSSION_PATHS.budgetDiscussion)) {
40+
const budgetNavItem = findNavItem(
41+
CONNECTED_NAV_ITEMS,
42+
BUDGET_DISCUSSION_PATHS.budgetDiscussion,
43+
);
44+
45+
return budgetNavItem ?? "";
46+
}
47+
48+
if (path.startsWith(PDF_PATHS.proposalDiscussion)) {
49+
const proposalDiscussionNavItem = findNavItem(
50+
CONNECTED_NAV_ITEMS,
51+
PDF_PATHS.proposalDiscussion,
52+
);
53+
54+
return proposalDiscussionNavItem ?? "";
55+
}
3756
return findNavItem(CONNECTED_NAV_ITEMS, path) ?? "";
3857
};
3958

40-
const findNavItem = (items: NavItem[], targetPath: string): string | null => (
41-
items.reduce<string | null>((result, item) => (
42-
result ?? (
43-
targetPath === item.navTo
59+
const findNavItem = (items: NavItem[], targetPath: string): string | null =>
60+
items.reduce<string | null>(
61+
(result, item) =>
62+
result ??
63+
(targetPath === item.navTo
4464
? item.label
45-
: (item.childNavItems ? findNavItem(item.childNavItems, targetPath) : null)
46-
)
47-
), null)
48-
);
65+
: item.childNavItems
66+
? findNavItem(item.childNavItems, targetPath)
67+
: null),
68+
null,
69+
);
4970

5071
useEffect(() => {
5172
if (divRef.current && pathname !== PATHS.dashboardGovernanceActions) {

0 commit comments

Comments
 (0)