diff --git a/CHANGELOG.md b/CHANGELOG.md index d17360837..d8fd79dac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,8 @@ changes. ### Fixed +- Fix missing redirect to outcomes on wallet disconnected state [Issue 3230](https://github.com/IntersectMBO/govtool/issues/3230) + ### Changed ### Removed diff --git a/govtool/frontend/src/pages/GovernanceActionDetails.tsx b/govtool/frontend/src/pages/GovernanceActionDetails.tsx index 50beb50b4..6718a175a 100644 --- a/govtool/frontend/src/pages/GovernanceActionDetails.tsx +++ b/govtool/frontend/src/pages/GovernanceActionDetails.tsx @@ -6,9 +6,10 @@ import { generatePath, } from "react-router-dom"; import { Box, CircularProgress, Link } from "@mui/material"; +import { AxiosError } from "axios"; import { Background, Typography } from "@atoms"; -import { ICONS, PATHS } from "@consts"; +import { ICONS, OUTCOMES_PATHS, PATHS } from "@consts"; import { useCardano } from "@context"; import { useGetProposalQuery, @@ -45,18 +46,28 @@ export const GovernanceActionDetails = () => { const fullProposalId = txHash && getFullGovActionId(txHash, index); const shortenedGovActionId = txHash && getShortenedGovActionId(txHash, index); - const { data, isLoading } = useGetProposalQuery( + const { data, isLoading, error } = useGetProposalQuery( fullProposalId ?? "", !state?.proposal, ); const proposal = (data ?? state)?.proposal; useEffect(() => { - if (isEnabled && getItemFromLocalStorage(`${WALLET_LS_KEY}_stake_key`)) { + const isProposalNotFound = + (error as AxiosError)?.response?.data === + `Proposal with id: ${fullProposalId} not found`; + if (isProposalNotFound && fullProposalId) { + navigate( + OUTCOMES_PATHS.governanceActionOutcomes.replace(":id", fullProposalId), + ); + } else if ( + isEnabled && + getItemFromLocalStorage(`${WALLET_LS_KEY}_stake_key`) + ) { const { pathname } = window.location; navigate(`/connected${pathname}`); } - }, [isEnabled]); + }, [isEnabled, error]); return (