Skip to content

Commit

Permalink
Change voting power voting logic
Browse files Browse the repository at this point in the history
Signed-off-by: Manank Patni <[email protected]>
  • Loading branch information
Man-Jain committed Sep 15, 2023
1 parent 152011a commit 64f3e52
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/modules/lite/explorer/components/Choices.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ export const Choices: React.FC<any> = ({ choices, submitForm, isLoading, votingS
const liteDAOId = data?.liteDAOData?._id ? data?.liteDAOData?._id : id
const tokenAddress = useToken(liteDAOId)
const { data: userBalance } = useUserTokenBalance(tokenAddress)
console.log("userBalance: ", userBalance)
const canCreateProposal = userBalance && new BigNumber(userBalance).gt(0) ? true : false
console.log("canCreateProposal: ", canCreateProposal)

return (
<Grid container direction="column" style={{ gap: 30 }}>
Expand Down Expand Up @@ -193,7 +195,7 @@ export const Choices: React.FC<any> = ({ choices, submitForm, isLoading, votingS
</ChoicesContainer>
<Grid container style={{ gap: 10, marginTop: 31 }}>
{!isLoading ? (
<MainButton disabled={canCreateProposal} variant="contained" color="secondary" onClick={submitForm}>
<MainButton disabled={!canCreateProposal} variant="contained" color="secondary" onClick={submitForm}>
Create Proposal
</MainButton>
) : (
Expand Down
6 changes: 4 additions & 2 deletions src/modules/lite/explorer/pages/ProposalDetails/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import { BackButton } from "modules/lite/components/BackButton"
import { voteOnLiteProposal } from "services/services/lite/lite-services"
import { useDelegationStatus } from "services/contracts/token/hooks/useDelegationStatus"
import { useDAO } from "services/services/dao/hooks/useDAO"
import { useDelegationVoteWeight } from "services/contracts/token/hooks/useDelegationVoteWeight"
import BigNumber from "bignumber.js"

const PageContainer = styled("div")({
marginBottom: 50,
Expand Down Expand Up @@ -61,7 +63,7 @@ export const ProposalDetails: React.FC<{ id: string }> = ({ id }) => {
const community = useCommunity(id)
const poll = useSinglePoll(proposalId, id, community)
const choices = usePollChoices(poll, refresh)
const { data: delegatedTo } = useDelegationStatus(dao?.data.token.contract)
const { data: voteWeight } = useDelegationVoteWeight(dao?.data.token.contract)
const [selectedVotes, setSelectedVotes] = useState<Choice[]>([])

useEffect(() => {
Expand Down Expand Up @@ -158,7 +160,7 @@ export const ProposalDetails: React.FC<{ id: string }> = ({ id }) => {
</Grid>
{poll?.isActive === ProposalStatus.ACTIVE ? (
<Button
disabled={selectedVotes.length === 0 || !!delegatedTo}
disabled={selectedVotes.length === 0 || voteWeight?.eq(new BigNumber(0))}
variant="contained"
color="secondary"
onClick={() => saveVote()}
Expand Down

0 comments on commit 64f3e52

Please sign in to comment.