From 579c2e958eef4ab779f4566371d93bbd159e0d10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Sza=C5=82owski?= Date: Fri, 13 Dec 2024 17:36:21 +0100 Subject: [PATCH] fix(#2511): fix app crash on governance action details page --- CHANGELOG.md | 1 + .../molecules/GovernanceActionDetailsCardLinks.tsx | 9 +++++++-- .../molecules/GovernanceActionDetailsCardVotes.tsx | 2 +- .../src/components/molecules/GovernanceVotedOnCard.tsx | 7 ++++++- .../frontend/src/components/molecules/VoteActionForm.tsx | 2 +- .../organisms/DashboardGovernanceActionsVotedOn.tsx | 6 +++--- .../components/organisms/GovernanceActionDetailsCard.tsx | 2 +- .../organisms/GovernanceActionDetailsCardData.tsx | 2 +- .../src/components/organisms/GovernanceActionsToVote.tsx | 6 +++--- govtool/frontend/src/hooks/forms/useVoteActionForm.tsx | 2 +- govtool/frontend/src/models/api.ts | 4 ++-- 11 files changed, 27 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 29d1902ef..ff00f2edd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ changes. - Fix mzero parsing error on fetching the /proposal/list [Issue 2446](https://github.com/IntersectMBO/govtool/issues/2446) - Fix scaling gov action votes on lower resolutions - Fix storing url missing length validation [Issue 2044](https://github.com/IntersectMBO/govtool/issues/2044) +- Fix governance action details page crash on missing data [Issue 2511](https://github.com/IntersectMBO/govtool/issues/2511) ### Changed diff --git a/govtool/frontend/src/components/molecules/GovernanceActionDetailsCardLinks.tsx b/govtool/frontend/src/components/molecules/GovernanceActionDetailsCardLinks.tsx index 4d37dad7a..a76571396 100644 --- a/govtool/frontend/src/components/molecules/GovernanceActionDetailsCardLinks.tsx +++ b/govtool/frontend/src/components/molecules/GovernanceActionDetailsCardLinks.tsx @@ -34,8 +34,13 @@ export const GovernanceActionDetailsCardLinks = ({ > {t("govActions.supportingLinks")} - {links.map(({ uri, label }) => ( - + {links?.map(({ uri, label }) => ( + {label && ( { isCopyButton isSliderCard /> - + {vote && ( + + )} >; isInProgress?: boolean; - previousVote?: ProposalVote; + previousVote?: ProposalVote | null; proposal: ProposalData; }; diff --git a/govtool/frontend/src/components/organisms/DashboardGovernanceActionsVotedOn.tsx b/govtool/frontend/src/components/organisms/DashboardGovernanceActionsVotedOn.tsx index 5e5667109..5d4dcf134 100644 --- a/govtool/frontend/src/components/organisms/DashboardGovernanceActionsVotedOn.tsx +++ b/govtool/frontend/src/components/organisms/DashboardGovernanceActionsVotedOn.tsx @@ -42,7 +42,7 @@ export const DashboardGovernanceActionsVotedOn = ({ .includes(searchPhrase.toLowerCase()), ), })) - .filter((entry) => entry.actions.length > 0); + .filter((entry) => entry.actions?.length > 0); } return data; }, [data, searchPhrase, pendingTransaction.vote]); @@ -70,12 +70,12 @@ export const DashboardGovernanceActionsVotedOn = ({ title={getProposalTypeLabel(item.title)} navigateKey={item.title} searchPhrase={searchPhrase} - dataLength={item.actions.slice(0, 6).length} + dataLength={item.actions.slice(0, 6)?.length} onDashboard data={item.actions.map((action) => (
1600 ? "longText" : "oneLine"} /> - {tabs.length === 1 ? ( + {tabs?.length === 1 ? ( tabs[0].content ) : ( <> diff --git a/govtool/frontend/src/components/organisms/GovernanceActionsToVote.tsx b/govtool/frontend/src/components/organisms/GovernanceActionsToVote.tsx index 28777ba85..3a603668b 100644 --- a/govtool/frontend/src/components/organisms/GovernanceActionsToVote.tsx +++ b/govtool/frontend/src/components/organisms/GovernanceActionsToVote.tsx @@ -32,7 +32,7 @@ export const GovernanceActionsToVote = ({ return ( <> - {!proposals.length ? ( + {!proposals?.length ? ( {t("govActions.noResultsForTheSearch")} @@ -91,10 +91,10 @@ export const GovernanceActionsToVote = ({ />
))} - dataLength={item.actions.slice(0, 6).length} + dataLength={item.actions.slice(0, 6)?.length} filters={filters} navigateKey={item.title} - notSlicedDataLength={item.actions.length} + notSlicedDataLength={item.actions?.length} onDashboard={onDashboard} searchPhrase={searchPhrase} sorting={sorting} diff --git a/govtool/frontend/src/hooks/forms/useVoteActionForm.tsx b/govtool/frontend/src/hooks/forms/useVoteActionForm.tsx index 447204fdb..4f215199a 100644 --- a/govtool/frontend/src/hooks/forms/useVoteActionForm.tsx +++ b/govtool/frontend/src/hooks/forms/useVoteActionForm.tsx @@ -31,7 +31,7 @@ export const useVoteActionFormController = () => { }; type Props = { - previousVote?: ProposalVote; + previousVote?: ProposalVote | null; voteContextHash?: string; voteContextUrl?: string; }; diff --git a/govtool/frontend/src/models/api.ts b/govtool/frontend/src/models/api.ts index 32ef7bcc5..cbd271368 100644 --- a/govtool/frontend/src/models/api.ts +++ b/govtool/frontend/src/models/api.ts @@ -224,12 +224,12 @@ export type NewConstitutionAnchor = { }; export type VotedProposalDTO = { - vote: ProposalVote; + vote: ProposalVote | null; proposal: ProposalDataDTO; }; export type VotedProposal = { - vote: ProposalVote; + vote: ProposalVote | null; proposal: ProposalData; };