@@ -6,9 +6,10 @@ import {
66 generatePath ,
77} from "react-router-dom" ;
88import { Box , CircularProgress , Link } from "@mui/material" ;
9+ import { AxiosError } from "axios" ;
910
1011import { Background , Typography } from "@atoms" ;
11- import { ICONS , PATHS } from "@consts" ;
12+ import { ICONS , OUTCOMES_PATHS , PATHS } from "@consts" ;
1213import { useCardano } from "@context" ;
1314import {
1415 useGetProposalQuery ,
@@ -45,18 +46,28 @@ export const GovernanceActionDetails = () => {
4546 const fullProposalId = txHash && getFullGovActionId ( txHash , index ) ;
4647 const shortenedGovActionId = txHash && getShortenedGovActionId ( txHash , index ) ;
4748
48- const { data, isLoading } = useGetProposalQuery (
49+ const { data, isLoading, error } = useGetProposalQuery (
4950 fullProposalId ?? "" ,
5051 ! state ?. proposal ,
5152 ) ;
5253 const proposal = ( data ?? state ) ?. proposal ;
5354
5455 useEffect ( ( ) => {
55- if ( isEnabled && getItemFromLocalStorage ( `${ WALLET_LS_KEY } _stake_key` ) ) {
56+ const isProposalNotFound =
57+ ( error as AxiosError ) ?. response ?. data ===
58+ `Proposal with id: ${ fullProposalId } not found` ;
59+ if ( isProposalNotFound && fullProposalId ) {
60+ navigate (
61+ OUTCOMES_PATHS . governanceActionOutcomes . replace ( ":id" , fullProposalId ) ,
62+ ) ;
63+ } else if (
64+ isEnabled &&
65+ getItemFromLocalStorage ( `${ WALLET_LS_KEY } _stake_key` )
66+ ) {
5667 const { pathname } = window . location ;
5768 navigate ( `/connected${ pathname } ` ) ;
5869 }
59- } , [ isEnabled ] ) ;
70+ } , [ isEnabled , error ] ) ;
6071
6172 return (
6273 < Background opacity = { 0.7 } >
0 commit comments