Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ changes.

### Added

- Add redirection to outcomes when proposal is not found [Issue 3230](https://github.com/IntersectMBO/govtool/issues/3230)

### Fixed

- Fix post-vote navigation to governance action list [Issue 3242](https://github.com/IntersectMBO/govtool/issues/3242)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { useEffect } from "react";
import {
useNavigate,
useLocation,
useParams,
generatePath,
} from "react-router-dom";
import { Box, CircularProgress, Link, Typography } from "@mui/material";
import { AxiosError } from "axios";

import { ICONS, PATHS } from "@consts";
import { ICONS, OUTCOMES_PATHS, PATHS } from "@consts";
import { useCardano } from "@context";
import {
useGetProposalQuery,
Expand Down Expand Up @@ -42,13 +44,24 @@ export const DashboardGovernanceActionDetails = () => {
const shortenedGovActionId =
txHash && getShortenedGovActionId(txHash, +index);

const { data, isLoading } = useGetProposalQuery(
const { data, isLoading, error } = useGetProposalQuery(
fullProposalId ?? "",
!state?.proposal || !state?.vote,
);
const proposal = (data ?? state)?.proposal;
const vote = (data ?? state)?.vote;

useEffect(() => {
const isProposalNotFound =
(error as AxiosError)?.response?.data ===
`Proposal with id: ${fullProposalId} not found`;
if (isProposalNotFound && fullProposalId) {
navigate(
OUTCOMES_PATHS.governanceActionOutcomes.replace(":id", fullProposalId),
);
}
}, [error]);

return (
<Box
px={isMobile ? 2 : 4}
Expand Down
3 changes: 2 additions & 1 deletion govtool/frontend/src/hooks/queries/useGetProposalQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { getProposal } from "@services";
export const useGetProposalQuery = (proposalId: string, enabled?: boolean) => {
const { dRepID } = useCardano();

const { data, isLoading, refetch, isRefetching } = useQuery(
const { data, isLoading, refetch, isRefetching, error } = useQuery(
[QUERY_KEYS.useGetProposalKey, dRepID, proposalId],
() => getProposal(proposalId, dRepID),
{
Expand All @@ -21,5 +21,6 @@ export const useGetProposalQuery = (proposalId: string, enabled?: boolean) => {
isLoading,
refetch,
isFetching: isRefetching,
error,
};
};