Skip to content

Commit f6d4f67

Browse files
authored
Merge pull request #2520 from IntersectMBO/fix/2511-typeerror-cannot-read-properties-of-undefined-reading-length
fix(#2511): fix app crash on governance action details page
2 parents 44d2ca0 + 579c2e9 commit f6d4f67

11 files changed

+27
-16
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ changes.
1919
- Fix mzero parsing error on fetching the /proposal/list [Issue 2446](https://github.com/IntersectMBO/govtool/issues/2446)
2020
- Fix scaling gov action votes on lower resolutions
2121
- Fix storing url missing length validation [Issue 2044](https://github.com/IntersectMBO/govtool/issues/2044)
22+
- Fix governance action details page crash on missing data [Issue 2511](https://github.com/IntersectMBO/govtool/issues/2511)
2223

2324
### Changed
2425

govtool/frontend/src/components/molecules/GovernanceActionDetailsCardLinks.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,13 @@ export const GovernanceActionDetailsCardLinks = ({
3434
>
3535
{t("govActions.supportingLinks")}
3636
</Typography>
37-
{links.map(({ uri, label }) => (
38-
<Box display="flex" flexDirection="column" overflow="hidden">
37+
{links?.map(({ uri, label }) => (
38+
<Box
39+
key={`${label}-${uri}-label`}
40+
display="flex"
41+
flexDirection="column"
42+
overflow="hidden"
43+
>
3944
{label && (
4045
<Typography
4146
data-testid={`${label}-${uri}-label`}

govtool/frontend/src/components/molecules/GovernanceActionDetailsCardVotes.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ type GovernanceActionCardVotesProps = {
1313
isDashboard?: boolean;
1414
isInProgress?: boolean;
1515
isVoter?: boolean;
16-
vote?: ProposalVote;
16+
vote?: ProposalVote | null;
1717
proposal: ProposalData;
1818
};
1919

govtool/frontend/src/components/molecules/GovernanceVotedOnCard.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,12 @@ export const GovernanceVotedOnCard = ({ votedProposal, inProgress }: Props) => {
121121
isCopyButton
122122
isSliderCard
123123
/>
124-
<GovernanceActionCardMyVote voteTxHash={vote.txHash} vote={vote.vote} />
124+
{vote && (
125+
<GovernanceActionCardMyVote
126+
voteTxHash={vote.txHash}
127+
vote={vote.vote}
128+
/>
129+
)}
125130
</Box>
126131
<Box
127132
bgcolor="white"

govtool/frontend/src/components/molecules/VoteActionForm.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { VoteContextModalState, SubmittedVotesModalState } from "../organisms";
1919
type VoteActionFormProps = {
2020
setIsVoteSubmitted: Dispatch<SetStateAction<boolean>>;
2121
isInProgress?: boolean;
22-
previousVote?: ProposalVote;
22+
previousVote?: ProposalVote | null;
2323
proposal: ProposalData;
2424
};
2525

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export const DashboardGovernanceActionsVotedOn = ({
4242
.includes(searchPhrase.toLowerCase()),
4343
),
4444
}))
45-
.filter((entry) => entry.actions.length > 0);
45+
.filter((entry) => entry.actions?.length > 0);
4646
}
4747
return data;
4848
}, [data, searchPhrase, pendingTransaction.vote]);
@@ -70,12 +70,12 @@ export const DashboardGovernanceActionsVotedOn = ({
7070
title={getProposalTypeLabel(item.title)}
7171
navigateKey={item.title}
7272
searchPhrase={searchPhrase}
73-
dataLength={item.actions.slice(0, 6).length}
73+
dataLength={item.actions.slice(0, 6)?.length}
7474
onDashboard
7575
data={item.actions.map((action) => (
7676
<div
7777
className="keen-slider__slide"
78-
key={`${action?.proposal.id}${action.vote.vote}`}
78+
key={`${action?.proposal.id}${action.vote?.vote}`}
7979
style={{ overflow: "visible", width: "auto" }}
8080
>
8181
<GovernanceVotedOnCard

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ type GovernanceActionDetailsCardProps = {
1616
isDataMissing: null | MetadataValidationStatus;
1717
isInProgress?: boolean;
1818
isVoter?: boolean;
19-
vote?: ProposalVote;
19+
vote?: ProposalVote | null;
2020
proposal: ProposalData;
2121
};
2222

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ export const GovernanceActionDetailsCardData = ({
260260
textVariant={screenWidth > 1600 ? "longText" : "oneLine"}
261261
/>
262262

263-
{tabs.length === 1 ? (
263+
{tabs?.length === 1 ? (
264264
tabs[0].content
265265
) : (
266266
<>

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export const GovernanceActionsToVote = ({
3232

3333
return (
3434
<>
35-
{!proposals.length ? (
35+
{!proposals?.length ? (
3636
<Typography fontWeight={300} sx={{ py: 4 }}>
3737
{t("govActions.noResultsForTheSearch")}
3838
</Typography>
@@ -91,10 +91,10 @@ export const GovernanceActionsToVote = ({
9191
/>
9292
</div>
9393
))}
94-
dataLength={item.actions.slice(0, 6).length}
94+
dataLength={item.actions.slice(0, 6)?.length}
9595
filters={filters}
9696
navigateKey={item.title}
97-
notSlicedDataLength={item.actions.length}
97+
notSlicedDataLength={item.actions?.length}
9898
onDashboard={onDashboard}
9999
searchPhrase={searchPhrase}
100100
sorting={sorting}

govtool/frontend/src/hooks/forms/useVoteActionForm.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export const useVoteActionFormController = () => {
3131
};
3232

3333
type Props = {
34-
previousVote?: ProposalVote;
34+
previousVote?: ProposalVote | null;
3535
voteContextHash?: string;
3636
voteContextUrl?: string;
3737
};

0 commit comments

Comments
 (0)