diff --git a/src/components/BallotCard.jsx b/src/components/BallotCard.jsx index 4c7b70a..fd0691b 100644 --- a/src/components/BallotCard.jsx +++ b/src/components/BallotCard.jsx @@ -1,6 +1,6 @@ import React from 'react'; import moment from 'moment'; -import { observable, action, computed, autorun } from "mobx"; +import { observable, action, computed } from "mobx"; import { inject, observer } from "mobx-react"; import { toAscii } from "../helpers"; import { constants } from "../constants"; @@ -18,7 +18,6 @@ export class BallotCard extends React.Component { @observable progress; @observable totalVoters; @observable isFinalized; - @observable isFiltered; @computed get votesForNumber() { let votes = (this.totalVoters + this.progress) / 2; @@ -197,22 +196,36 @@ export class BallotCard extends React.Component { this.getIsFinalized(); } - hideCard = () => { - let { commonStore } = this.props; - let hideCard = commonStore.isActiveFilter && this.isFinalized; - if (commonStore.searchTerm) { - if (commonStore.searchTerm.length == 0) return hideCard; - if (String(this.creator).toLowerCase().includes(commonStore.searchTerm)) return (hideCard && false); - } else { - return hideCard; - } + componentDidMount() { + this.interval = setInterval(() => { + this.calcTimeToFinish() + }, 1000) + } + componentWillUnmount() { + window.clearInterval(this.interval); + } + + showCard = () => { + let { commonStore } = this.props; + let show = commonStore.isActiveFilter ? !this.isFinalized : true; + return show; + } + + isCreatorPattern = () => { + let { commonStore } = this.props; + if (commonStore.searchTerm) { + if (commonStore.searchTerm.length > 0) { + const isCreatorPattern = String(this.creator).toLowerCase().includes(commonStore.searchTerm) + return isCreatorPattern; + } + } return true; } render () { - let { contractsStore, ballotStore, votingType, children } = this.props; - let ballotClass = this.hideCard() ? "ballots-i display-none" : "ballots-i"; + let { contractsStore, votingType, children, isSearchPattern } = this.props; + let ballotClass = (this.showCard() && (this.isCreatorPattern() || isSearchPattern)) ? "ballots-i" : "ballots-i display-none"; let threshold switch(votingType) { case "votingToChangeKeys": @@ -224,6 +237,9 @@ export class BallotCard extends React.Component { case "votingToChangeProxy": threshold = contractsStore.proxyBallotThreshold break; + default: + threshold = contractsStore.keysBallotThreshold + break; } return (
Action
diff --git a/src/components/BallotMinThresholdCard.jsx b/src/components/BallotMinThresholdCard.jsx index d658e30..ec2029e 100644 --- a/src/components/BallotMinThresholdCard.jsx +++ b/src/components/BallotMinThresholdCard.jsx @@ -1,14 +1,8 @@ import React from 'react'; -import moment from 'moment'; -import { observable, action, computed } from "mobx"; +import { observable, action } from "mobx"; import { inject, observer } from "mobx-react"; -import { toAscii } from "../helpers"; -import { constants } from "../constants"; -import swal from 'sweetalert2'; import { BallotCard } from './BallotCard'; -const ACCEPT = 1; -const REJECT = 2; @inject("commonStore", "contractsStore", "routing") @observer export class BallotMinThresholdCard extends React.Component { @@ -26,25 +20,19 @@ export class BallotMinThresholdCard extends React.Component { this.getProposedValue(this.props.id); } - hideCard = () => { + isSearchPattern = () => { let { commonStore } = this.props; - let hideCard = commonStore.isActiveFilter && this.isFinalized; if (commonStore.searchTerm) { - if (commonStore.searchTerm.length == 0) return hideCard; - if (String(this.proposedValue).toLowerCase().includes(commonStore.searchTerm)) return (hideCard && false); - if (String(this.creator).toLowerCase().includes(commonStore.searchTerm)) return (hideCard && false); - } else { - return hideCard; + const isProposedValuePattern = String(this.proposedValue).toLowerCase().includes(commonStore.searchTerm) + return (isProposedValuePattern); } - return true; } render () { - let { contractsStore, id } = this.props; - let ballotClass = this.hideCard() ? "ballots-i display-none" : "ballots-i"; + let { id } = this.props; return ( -Proposed min threshold
@@ -54,71 +42,6 @@ export class BallotMinThresholdCard extends React.Component {Name
-{this.creator}
-{this.startTime}
-Proposed min threshold
-{this.proposedValue}
-Time
-{this.timeToFinish}
-To close
-No
-Votes: {this.votesAgainstNumber}
-{this.votesAgainstPercents}%
-Yes
-Votes: {this.votesForNumber}
-{this.votesForPercents}%
-{constants.CARD_FINALIZE_DESCRIPTION}
-Contract type
@@ -66,78 +61,5 @@ export class BallotProxyCard extends React.Component {Name
-{this.creator}
-{this.startTime}
-Contract type
-{ballotStore.ProxyBallotType[this.contractType]}
-Proposed contract address
-{this.proposedAddress}
-Time
-{this.timeToFinish}
-To close
-No
-Votes: {this.votesAgainstNumber}
-{this.votesAgainstPercents}%
-Yes
-Votes: {this.votesForNumber}
-{this.votesForPercents}%
-{constants.CARD_FINALIZE_DESCRIPTION}
-