Skip to content

Commit dd102c0

Browse files
committed
fix: handle empty rationale states for first and revote
1 parent 4ad9f76 commit dd102c0

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

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

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,12 @@ export const VoteActionForm = ({
3636
useState<boolean>(false);
3737

3838
const { voter } = useGetVoterInfo();
39-
const { voteContextText } = useGetVoteContextTextFromFile(voteContextUrl, voteContextHash);
39+
const { voteContextText } = useGetVoteContextTextFromFile(voteContextUrl, voteContextHash) || {};
40+
41+
const finalVoteContextText =
42+
((previousVote != null || undefined) && !voteContextUrl && !voteContextHash)
43+
? ""
44+
: voteContextText;
4045

4146
const { isMobile } = useScreenDimension();
4247
const { openModal, closeModal } = useModal();
@@ -64,7 +69,7 @@ export const VoteActionForm = ({
6469
},
6570
vote: vote as Vote,
6671
confirmVote,
67-
previousRationale: isVoteChanged ? undefined : voteContextText
72+
previousRationale: isVoteChanged ? undefined : finalVoteContextText
6873
} satisfies VoteContextModalState,
6974
});
7075
};
@@ -242,7 +247,7 @@ export const VoteActionForm = ({
242247
{t("govActions.showVotes")}
243248
</Button>
244249
)}
245-
{voteContextText && (
250+
{finalVoteContextText && (
246251
<>
247252
<Typography sx={{ fontSize: "14px", fontWeight: 500 }}>{t("govActions.yourVoteRationale")}</Typography>
248253
<Box
@@ -254,7 +259,7 @@ export const VoteActionForm = ({
254259
mt: 2,
255260
}}
256261
>
257-
{voteContextText && (
262+
{finalVoteContextText && (
258263
<Box
259264
sx={{
260265
position: "relative",
@@ -281,7 +286,7 @@ export const VoteActionForm = ({
281286
}),
282287
}}
283288
>
284-
{voteContextText}
289+
{finalVoteContextText}
285290
</Typography>
286291

287292
{!showWholeVoteContext && (

0 commit comments

Comments
 (0)