Skip to content

Commit 94683f8

Browse files
authored
Merge pull request #3254 from IntersectMBO/feat/3230-redirect-to-governance-action-outcomes-pillar-from-voting-pillar
feat(#3230): redirect to outcomes from voting pillar
2 parents cb64984 + d20d0c5 commit 94683f8

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

CHANGELOG.md

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

1313
### Added
1414

15+
- Add redirection to outcomes when proposal is not found [Issue 3230](https://github.com/IntersectMBO/govtool/issues/3230)
16+
1517
### Fixed
1618

1719
- Fix post-vote navigation to governance action list [Issue 3242](https://github.com/IntersectMBO/govtool/issues/3242)

govtool/frontend/src/components/organisms/DashboardGovernanceActionDetails.tsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1+
import { useEffect } from "react";
12
import {
23
useNavigate,
34
useLocation,
45
useParams,
56
generatePath,
67
} from "react-router-dom";
78
import { Box, CircularProgress, Link, Typography } from "@mui/material";
9+
import { AxiosError } from "axios";
810

9-
import { ICONS, PATHS } from "@consts";
11+
import { ICONS, OUTCOMES_PATHS, PATHS } from "@consts";
1012
import { useCardano } from "@context";
1113
import {
1214
useGetProposalQuery,
@@ -42,13 +44,24 @@ export const DashboardGovernanceActionDetails = () => {
4244
const shortenedGovActionId =
4345
txHash && getShortenedGovActionId(txHash, +index);
4446

45-
const { data, isLoading } = useGetProposalQuery(
47+
const { data, isLoading, error } = useGetProposalQuery(
4648
fullProposalId ?? "",
4749
!state?.proposal || !state?.vote,
4850
);
4951
const proposal = (data ?? state)?.proposal;
5052
const vote = (data ?? state)?.vote;
5153

54+
useEffect(() => {
55+
const isProposalNotFound =
56+
(error as AxiosError)?.response?.data ===
57+
`Proposal with id: ${fullProposalId} not found`;
58+
if (isProposalNotFound && fullProposalId) {
59+
navigate(
60+
OUTCOMES_PATHS.governanceActionOutcomes.replace(":id", fullProposalId),
61+
);
62+
}
63+
}, [error]);
64+
5265
return (
5366
<Box
5467
px={isMobile ? 2 : 4}

govtool/frontend/src/hooks/queries/useGetProposalQuery.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { getProposal } from "@services";
77
export const useGetProposalQuery = (proposalId: string, enabled?: boolean) => {
88
const { dRepID } = useCardano();
99

10-
const { data, isLoading, refetch, isRefetching } = useQuery(
10+
const { data, isLoading, refetch, isRefetching, error } = useQuery(
1111
[QUERY_KEYS.useGetProposalKey, dRepID, proposalId],
1212
() => getProposal(proposalId, dRepID),
1313
{
@@ -21,5 +21,6 @@ export const useGetProposalQuery = (proposalId: string, enabled?: boolean) => {
2121
isLoading,
2222
refetch,
2323
isFetching: isRefetching,
24+
error,
2425
};
2526
};

0 commit comments

Comments
 (0)