Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#1875] add missing testIds for submitted votes #2077

Merged
merged 1 commit into from
Sep 25, 2024
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: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ changes.

### Fixed

-
- Add missing testIds for submitted votes [Issue 1875](https://github.com/IntersectMBO/govtool/issues/1875)

### Changed

Expand Down
165 changes: 85 additions & 80 deletions govtool/frontend/src/components/molecules/VotesSubmitted.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Box, Typography } from "@mui/material";
import { Box } from "@mui/material";

import { IMAGES } from "@consts";
import { VotePill } from "@atoms";
import { Typography, VotePill } from "@atoms";
import { useTranslation } from "@hooks";
import { correctAdaFormat } from "@utils";
import { SubmittedVotesData } from "@models";
Expand All @@ -10,27 +10,6 @@ type Props = {
votes: SubmittedVotesData;
};

const Vote = ({
vote,
value,
}: {
vote: "yes" | "no" | "abstain";
value: string | number;
}) => (
<Box sx={{ alignItems: "center", display: "flex", flexWrap: "wrap" }}>
<VotePill vote={vote} maxWidth={82} />
<Typography
fontSize="16px"
sx={{
marginLeft: "12px",
wordBreak: "break-all",
}}
>
{value}
</Typography>
</Box>
);

export const VotesSubmitted = ({
votes: {
dRepYesVotes,
Expand Down Expand Up @@ -83,67 +62,93 @@ export const VotesSubmitted = ({
sx={{
display: "flex",
flexDirection: "column",
gap: "12px",
gap: 4.5,
}}
>
<Typography
sx={{
fontSize: "18px",
fontWeight: "600",
lineHeight: "24px",
}}
>
{t("govActions.dReps")}
</Typography>
<Vote vote="yes" value={`₳ ${correctAdaFormat(dRepYesVotes)}`} />
<Vote
vote="abstain"
value={`₳ ${correctAdaFormat(dRepAbstainVotes)}`}
<VotesGroup
type="dReps"
yesVotes={dRepYesVotes}
noVotes={dRepNoVotes}
abstainVotes={dRepAbstainVotes}
/>
<VotesGroup
type="sPos"
yesVotes={poolYesVotes}
noVotes={poolNoVotes}
abstainVotes={poolAbstainVotes}
/>
<VotesGroup
type="ccCommittee"
yesVotes={ccYesVotes}
noVotes={ccNoVotes}
abstainVotes={ccAbstainVotes}
/>
<Vote vote="no" value={`₳ ${correctAdaFormat(dRepNoVotes)}`} />
<Box
sx={{
display: "flex",
flexDirection: "column",
gap: "12px",
mt: "24px",
}}
>
<Typography
sx={{
fontSize: "18px",
fontWeight: "600",
lineHeight: "24px",
}}
>
{t("govActions.sPos")}
</Typography>
<Vote vote="yes" value={poolYesVotes} />
<Vote vote="abstain" value={poolAbstainVotes} />
<Vote vote="no" value={poolNoVotes} />
<Box
sx={{
display: "flex",
flexDirection: "column",
gap: "12px",
mt: "24px",
}}
>
<Typography
sx={{
fontSize: "18px",
fontWeight: "600",
lineHeight: "24px",
}}
>
{t("govActions.ccCommittee")}
</Typography>
<Vote vote="yes" value={ccYesVotes} />
<Vote vote="abstain" value={ccAbstainVotes} />
<Vote vote="no" value={ccNoVotes} />
</Box>
</Box>
</Box>
</Box>
);
};

type VotesGroupProps = {
type: "ccCommittee" | "dReps" | "sPos";
yesVotes: number;
noVotes: number;
abstainVotes: number;
};

const VotesGroup = ({
type,
yesVotes,
noVotes,
abstainVotes,
}: VotesGroupProps) => {
const { t } = useTranslation();
return (
<Box
sx={{
display: "flex",
flexDirection: "column",
gap: "12px",
}}
>
<Typography
sx={{
fontSize: "18px",
fontWeight: "600",
lineHeight: "24px",
}}
>
{t(`govActions.${type}`)}
</Typography>
<Vote type={type} vote="yes" value={yesVotes} />
<Vote type={type} vote="abstain" value={abstainVotes} />
<Vote type={type} vote="no" value={noVotes} />
</Box>
);
};

type VoteProps = {
type: "ccCommittee" | "dReps" | "sPos";
vote: "yes" | "no" | "abstain";
value: number;
};
const Vote = ({ type, vote, value }: VoteProps) => (
<Box
sx={{
alignItems: "center",
display: "flex",
flexWrap: "wrap",
columnGap: 1.5,
}}
>
<VotePill vote={vote} maxWidth={82} />
<Typography
data-testid={`submitted-votes-${type}-${vote}`}
sx={{
fontSize: 16,
wordBreak: "break-all",
}}
>
{type === "dReps" ? `₳ ${correctAdaFormat(value)}` : value}
</Typography>
</Box>
);
Loading