Skip to content

Commit

Permalink
eslint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ashutoshpw committed Oct 1, 2024
1 parent b859d72 commit f3cd725
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 56 deletions.
111 changes: 57 additions & 54 deletions src/modules/lite/explorer/components/VoteDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,64 +111,67 @@ export const VoteDetails: React.FC<{
</TitleContainer>
<GraphicsContainer container>
{choices &&
choices.map((choice: Choice, index) => (
<LinearContainer container direction="column" style={{ gap: 20 }} key={`'option-'${index}`}>
<Grid item container direction="row" alignItems="center">
<Grid item xs={12} lg={6} sm={6}>
<Typography color="textPrimary" variant="body2">
{choice.name}
</Typography>
</Grid>
<Grid item xs={12} lg={6} sm={6} container justifyContent={isMobileSmall ? "flex-start" : "flex-end"}>
{choice && choice.walletAddresses ? (
choices.map((choice: Choice, index) => {
const pollWeight = calculateWeight(
poll?.totalSupplyAtReferenceBlock,
calculateChoiceTotal(choice.walletAddresses, tokenData?.decimals),
tokenData?.decimals
)
.dp(2, 1)
.toNumber()

const pollWeightXtz = calculateWeight(
poll?.totalSupplyAtReferenceBlock,
calculateChoiceTotal(choice.walletAddresses, isXTZ ? 6 : tokenData?.decimals),
isXTZ ? 6 : tokenData?.decimals
)
.dp(2, 1)
.toString()

const calculatedChoiceTotalCount = numbro(
calculateChoiceTotal(choice.walletAddresses, isXTZ ? 6 : tokenData?.decimals)
).format(formatConfig)

const tokenSymbol = !isMobile
? nFormatter(calculateChoiceTotal(choice.walletAddresses, isXTZ ? 6 : tokenData?.decimals), 1)
: calculatedChoiceTotalCount

const linearProgressValue = !poll?.isXTZ ? pollWeight : calculateWeightXTZ(choice, totalXTZ)
return (
<LinearContainer container direction="column" style={{ gap: 20 }} key={`'option-'${index}`}>
<Grid item container direction="row" alignItems="center">
<Grid item xs={12} lg={6} sm={6}>
<Typography color="textPrimary" variant="body2">
{choice.walletAddresses.length} Voters -{" "}
{!isMobile
? nFormatter(calculateChoiceTotal(choice.walletAddresses, isXTZ ? 6 : tokenData?.decimals), 1)
: numbro(calculateChoiceTotal(choice.walletAddresses, isXTZ ? 6 : tokenData?.decimals)).format(
formatConfig
)}{" "}
{isXTZ ? "XTZ" : tokenData?.symbol}
{choice.name}
</Typography>
) : null}
</Grid>
</Grid>
<Grid item container direction="row" alignItems="center">
<Grid item xs={10} lg={11} sm={11}>
<LinearProgress
style={{ width: "100%", marginRight: "4px" }}
color="secondary"
value={
!poll?.isXTZ
? calculateWeight(
poll?.totalSupplyAtReferenceBlock,
calculateChoiceTotal(choice.walletAddresses, tokenData?.decimals),
tokenData?.decimals
)
.dp(2, 1)
.toNumber()
: calculateWeightXTZ(choice, totalXTZ)
}
variant="determinate"
/>
</Grid>
<Grid item xs={12} lg={6} sm={6} container justifyContent={isMobileSmall ? "flex-start" : "flex-end"}>
{choice && choice.walletAddresses ? (
<Typography color="textPrimary" variant="body2">
{choice.walletAddresses.length} Voters - {tokenSymbol} {isXTZ ? "XTZ" : tokenData?.symbol}
</Typography>
) : null}
</Grid>
</Grid>
<Grid item xs={2} lg={1} sm={1} container justifyContent="flex-end">
<Typography color="textPrimary" variant="body2">
{!poll?.isXTZ
? calculateWeight(
poll?.totalSupplyAtReferenceBlock,
calculateChoiceTotal(choice.walletAddresses, isXTZ ? 6 : tokenData?.decimals),
isXTZ ? 6 : tokenData?.decimals
)
.dp(2, 1)
.toString()
: numbro(calculateWeightXTZ(choice, totalXTZ)).format(formatConfig)}
%
</Typography>
<Grid item container direction="row" alignItems="center">
<Grid item xs={10} lg={11} sm={11}>
<LinearProgress
style={{ width: "100%", marginRight: "4px" }}
color="secondary"
value={linearProgressValue}
variant="determinate"
/>
</Grid>
<Grid item xs={2} lg={1} sm={1} container justifyContent="flex-end">
<Typography color="textPrimary" variant="body2">
{!poll?.isXTZ ? pollWeightXtz : numbro(calculateWeightXTZ(choice, totalXTZ)).format(formatConfig)}
%
</Typography>
</Grid>
</Grid>
</Grid>
</LinearContainer>
))}
</LinearContainer>
)
})}

<LegendContainer container direction="row">
<Grid item container direction="row" xs={12} sm={6} md={6} lg={6} style={{ gap: 10 }}>
Expand Down
7 changes: 5 additions & 2 deletions src/services/lite/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,14 @@ export const calculateProposalTotal = (choices: Choice[], decimals: any) => {
}

const getUsers = (options: Choice[]) => {
console.log("options", options)
const addresses: string[] = []

options.map(option => {
return option.walletAddresses.map(wallet => addresses.push(wallet.address))
options.forEach(option => {
// TODO: ashutoshpw - Replace with wallet.address
option.walletAddresses.forEach(wallet => addresses.push((wallet as any)?._id))
})
// debugger

return new Set(addresses)
}
Expand Down

0 comments on commit f3cd725

Please sign in to comment.