Add remove proposal (#85)

This commit is contained in:
Szymon Szlachtowicz 2021-07-06 13:12:12 +02:00 committed by GitHub
parent bbea3a13e4
commit 2b194ca741
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,8 @@
import { useContractFunction } from '@usedapp/core'
import React, { useState } from 'react'
import styled from 'styled-components'
import { timespan } from '../../helpers/timespan'
import { useContracts } from '../../hooks/useContracts'
import { CommunityDetail } from '../../models/community'
import { ButtonPrimary } from '../Button'
import { VotePropose } from '../votes/VotePropose'
@ -15,11 +17,14 @@ interface RemoveAmountPickerProps {
export function RemoveAmountPicker({ community, availableAmount, setShowConfirmModal }: RemoveAmountPickerProps) {
const [proposingAmount, setProposingAmount] = useState(0)
const disabled = proposingAmount === 0
const { votingContract } = useContracts()
const { send } = useContractFunction(votingContract, 'initializeVotingRoom')
if (community.votingHistory && community.votingHistory.length > 0) {
const lastVote = community.votingHistory[community.votingHistory.length - 1]
const lastVoteDate = lastVote.date
const disabled = proposingAmount === 0
if (community.votingHistory && timespan(lastVoteDate) < 30) {
if (timespan(lastVoteDate) < 30) {
return (
<WarningWrapRemoval>
<Warning
@ -38,6 +43,7 @@ export function RemoveAmountPicker({ community, availableAmount, setShowConfirmM
</WarningWrapRemoval>
)
}
}
if (availableAmount < 10000) {
return (
<WarningWrapRemoval>
@ -62,7 +68,13 @@ export function RemoveAmountPicker({ community, availableAmount, setShowConfirmM
setProposingAmount={setProposingAmount}
proposingAmount={proposingAmount}
/>
<VoteConfirmBtn disabled={disabled} onClick={() => setShowConfirmModal(true)}>
<VoteConfirmBtn
disabled={disabled}
onClick={async () => {
await send(0, community.publicKey)
setShowConfirmModal(true)
}}
>
Confirm vote to remove community
</VoteConfirmBtn>
</VoteProposeWrap>