Skip to content

Commit

Permalink
chore: fix ts errors
Browse files Browse the repository at this point in the history
  • Loading branch information
MSzalowski committed Aug 22, 2024
1 parent 7d7c1d6 commit b7d28e5
Show file tree
Hide file tree
Showing 7 changed files with 117 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ export const DashboardGovernanceActionDetails = () => {
</Box>
) : data || state ? (
<GovernanceActionDetailsCard
abstainVotes={
state ? state.abstainVotes : data.proposal.dRepAbstainVotes
dRepAbstainVotes={
state ? state.dRepAbstainVotes : data.proposal.dRepAbstainVotes
}
createdDate={state ? state.createdDate : data.proposal.createdDate}
createdEpochNo={
Expand All @@ -122,7 +122,7 @@ export const DashboardGovernanceActionDetails = () => {
isVoter={
voter?.isRegisteredAsDRep || voter?.isRegisteredAsSoleVoter
}
noVotes={state ? state.noVotes : data.proposal.dRepNoVotes}
dRepNoVotes={state ? state.dRepNoVotes : data.proposal.dRepNoVotes}
type={type}
label={label}
title={title}
Expand All @@ -132,7 +132,9 @@ export const DashboardGovernanceActionDetails = () => {
abstract={state ? state?.abstract : data.proposal?.abstract}
motivation={state ? state?.motivation : data.proposal?.motivation}
rationale={state ? state?.rationale : data.proposal?.rationale}
yesVotes={state ? state.yesVotes : data.proposal.dRepYesVotes}
dRepYesVotes={
state ? state.dRepYesVotes : data.proposal.dRepYesVotes
}
voteFromEP={data?.vote?.vote}
voteUrlFromEP={data?.vote?.url}
voteDateFromEP={data?.vote?.date}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@ import { EpochParams, MetadataValidationStatus } from "@models";
import { GovernanceActionType } from "@/types/governanceAction";

type GovernanceActionDetailsCardProps = {
abstainVotes: number;
createdDate: string;
createdEpochNo: number;
expiryDate: string;
expiryEpochNo: number;
noVotes: number;
type: GovernanceActionType;
label: string;
details?: ActionDetailsType;
Expand All @@ -25,7 +23,6 @@ type GovernanceActionDetailsCardProps = {
abstract?: string;
motivation?: string;
rationale?: string;
yesVotes: number;
links?: string[];
govActionId: string;
isDataMissing: null | MetadataValidationStatus;
Expand All @@ -37,15 +34,18 @@ type GovernanceActionDetailsCardProps = {
voteEpochNoFromEP?: number;
isInProgress?: boolean;
protocolParams: EpochParams | null;
dRepAbstainVotes: number;
dRepNoVotes: number;
dRepYesVotes: number;
};

export const GovernanceActionDetailsCard = ({
abstainVotes,
dRepAbstainVotes,
createdDate,
createdEpochNo,
expiryDate,
expiryEpochNo,
noVotes,
dRepNoVotes,
details,
url,
type,
Expand All @@ -55,7 +55,7 @@ export const GovernanceActionDetailsCard = ({
abstract,
motivation,
rationale,
yesVotes,
dRepYesVotes,
isDashboard,
isVoter,
voteFromEP,
Expand Down Expand Up @@ -121,9 +121,9 @@ export const GovernanceActionDetailsCard = ({
/>
<GovernanceActionDetailsCardVotes
setIsVoteSubmitted={setIsVoteSubmitted}
abstainVotes={abstainVotes}
noVotes={noVotes}
yesVotes={yesVotes}
abstainVotes={dRepAbstainVotes}
noVotes={dRepNoVotes}
yesVotes={dRepYesVotes}
expiryDate={expiryDate}
expiryEpochNo={expiryEpochNo}
isVoter={isVoter}
Expand Down
14 changes: 10 additions & 4 deletions govtool/frontend/src/pages/GovernanceActionDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,10 @@ export const GovernanceActionDetails = () => {
) : data || state ? (
<Box data-testid="governance-action-details">
<GovernanceActionDetailsCard
abstainVotes={
state ? state.abstainVotes : data.proposal.dRepAbstainVotes
dRepAbstainVotes={
state
? state.dRepAbstainVotes
: data.proposal.dRepAbstainVotes
}
createdDate={
state ? state.createdDate : data.proposal.createdDate
Expand All @@ -151,7 +153,9 @@ export const GovernanceActionDetails = () => {
expiryEpochNo={
state ? state.expiryEpochNo : data.proposal.expiryEpochNo
}
noVotes={state ? state.noVotes : data.proposal.dRepNoVotes}
dRepNoVotes={
state ? state.dRepNoVotes : data.proposal.dRepNoVotes
}
type={type}
label={label}
title={title}
Expand All @@ -165,7 +169,9 @@ export const GovernanceActionDetails = () => {
state ? state?.rationale : data.proposal?.rationale
}
links={state ? state?.references : data.proposal?.references}
yesVotes={state ? state.yesVotes : data.proposal.dRepYesVotes}
dRepYesVotes={
state ? state.dRepYesVotes : data.proposal.dRepYesVotes
}
govActionId={fullProposalId}
protocolParams={
state ? state.protocolParams : data.proposal.protocolParams
Expand Down
10 changes: 10 additions & 0 deletions govtool/frontend/src/stories/GovernanceAction.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ const commonArgs = {
type: "exampleType",
metadataValid: true,
metadataStatus: null,
dRepYesVotes: 1,
dRepNoVotes: 0,
dRepAbstainVotes: 0,
ccYesVotes: 0,
ccNoVotes: 0,
ccAbstainVotes: 0,
poolYesVotes: 0,
poolNoVotes: 0,
poolAbstainVotes: 0,
protocolParams: null,
};

export const GovernanceActionCardComponent: Story = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,26 @@ type Story = StoryObj<typeof meta>;
const commonArgs = {
abstainVotes: 1000000,
createdDate: new Date().toISOString(),
createdEpochNo: 1000000,
expiryEpochNo: 1000001,
expiryDate: new Date().toISOString(),
noVotes: 1000000,
label: "Info Action",
type: GovernanceActionType.InfoAction,
url: "https://exampleurl.com",
yesVotes: 1000000,
createdEpochNo: 302,
expiryEpochNo: 350,
govActionId: "exampleId1232312312312",
isDataMissing: null,
title: "Example title",
dRepYesVotes: 1000000,
dRepNoVotes: 302,
dRepAbstainVotes: 350,
poolYesVotes: 1,
poolNoVotes: 0,
poolAbstainVotes: 2,
ccYesVotes: 1,
ccNoVotes: 0,
ccAbstainVotes: 2,
protocolParams: null,
};

async function assertTooltip(tooltip: HTMLElement, expectedText: RegExp) {
Expand Down
52 changes: 40 additions & 12 deletions govtool/frontend/src/stories/GovernanceActionVoted.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,16 @@ export const GovernanceVotedOnCardComponent: Story = {
txHash: "exampleHash",
url: "https://example.com",
metadataHash: "exampleHash",
yesVotes: 1,
noVotes: 0,
abstainVotes: 2,
dRepYesVotes: 1,
dRepNoVotes: 0,
dRepAbstainVotes: 2,
poolYesVotes: 1,
poolNoVotes: 0,
poolAbstainVotes: 2,
ccYesVotes: 1,
ccNoVotes: 0,
ccAbstainVotes: 2,
protocolParams: null,
},
},
},
Expand Down Expand Up @@ -112,9 +119,16 @@ export const GovernanceVotedOnCardAbstain: Story = {
txHash: "exampleHash",
url: "https://example.com",
metadataHash: "exampleHash",
yesVotes: 1,
noVotes: 0,
abstainVotes: 2,
dRepYesVotes: 1,
dRepNoVotes: 0,
dRepAbstainVotes: 2,
poolYesVotes: 1,
poolNoVotes: 0,
poolAbstainVotes: 2,
ccYesVotes: 1,
ccNoVotes: 0,
ccAbstainVotes: 2,
protocolParams: null,
},
},
},
Expand Down Expand Up @@ -151,9 +165,16 @@ export const GovernanceVotedOnCardYes: Story = {
txHash: "exampleHash",
url: "https://example.com",
metadataHash: "exampleHash",
yesVotes: 1,
noVotes: 0,
abstainVotes: 2,
dRepYesVotes: 1,
dRepNoVotes: 0,
dRepAbstainVotes: 2,
poolYesVotes: 1,
poolNoVotes: 0,
poolAbstainVotes: 2,
ccYesVotes: 1,
ccNoVotes: 0,
ccAbstainVotes: 2,
protocolParams: null,
},
},
},
Expand Down Expand Up @@ -190,9 +211,16 @@ export const GovernanceVotedOnCardNo: Story = {
txHash: "exampleHash",
url: "https://example.com",
metadataHash: "exampleHash",
yesVotes: 1,
noVotes: 0,
abstainVotes: 2,
dRepYesVotes: 1,
dRepNoVotes: 0,
dRepAbstainVotes: 2,
poolYesVotes: 1,
poolNoVotes: 0,
poolAbstainVotes: 2,
ccYesVotes: 1,
ccNoVotes: 0,
ccAbstainVotes: 2,
protocolParams: null,
},
},
},
Expand Down
39 changes: 30 additions & 9 deletions govtool/frontend/src/utils/tests/removeDuplicatedProposals.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,22 @@ const uniqueProposals = [
url: "https://bit.ly/3zCH2HL",
metadataHash:
"1111111111111111111111111111111111111111111111111111111111111111",
yesVotes: 0,
noVotes: 0,
abstainVotes: 81528377728,
dRepYesVotes: 0,
dRepNoVotes: 0,
dRepAbstainVotes: 81528377728,
poolYesVotes: 0,
poolNoVotes: 0,
poolAbstainVotes: 123123,
ccYesVotes: 0,
ccNoVotes: 0,
ccAbstainVotes: 4324,
title: "Proposal 1322 Title",
about: "This is about Proposal 1322",
metadataStatus: null,
metadataValid: false,
motivation: "Motivation behind Proposal 1322",
rationale: "Rationale for Proposal 1322",
protocolParams: null,
},
{
id: "1338",
Expand All @@ -44,15 +51,22 @@ const uniqueProposals = [
url: "https://bit.ly/3zCH2HL",
metadataHash:
"2222222222222222222222222222222222222222222222222222222222222222",
yesVotes: 0,
noVotes: 0,
abstainVotes: 81528377728,
dRepYesVotes: 0,
dRepNoVotes: 0,
dRepAbstainVotes: 81528377728,
poolYesVotes: 0,
poolNoVotes: 0,
poolAbstainVotes: 123123,
ccYesVotes: 0,
ccNoVotes: 0,
ccAbstainVotes: 4324,
title: "Proposal 1338 Title",
about: "This is about Proposal 1338",
metadataStatus: null,
metadataValid: false,
motivation: "Motivation behind Proposal 1338",
rationale: "Rationale for Proposal 1338",
protocolParams: null,
},
{
id: "1335",
Expand All @@ -70,15 +84,22 @@ const uniqueProposals = [
url: "https://bit.ly/3zCH2HL",
metadataHash:
"3333333333333333333333333333333333333333333333333333333333333333",
yesVotes: 3175400714,
noVotes: 0,
abstainVotes: 81528377728,
dRepYesVotes: 0,
dRepNoVotes: 0,
dRepAbstainVotes: 81528377728,
poolYesVotes: 0,
poolNoVotes: 0,
poolAbstainVotes: 123123,
ccYesVotes: 0,
ccNoVotes: 0,
ccAbstainVotes: 4324,
title: "Proposal 1335 Title",
about: "This is about Proposal 1335",
metadataStatus: null,
metadataValid: false,
motivation: "Motivation behind Proposal 1335",
rationale: "Rationale for Proposal 1335",
protocolParams: null,
},
];

Expand Down

0 comments on commit b7d28e5

Please sign in to comment.