Skip to content
This repository has been archived by the owner on Apr 15, 2019. It is now read-only.

Commit

Permalink
Use votingConst in votingBar and voteDialog
Browse files Browse the repository at this point in the history
  • Loading branch information
slaweet committed Sep 22, 2017
1 parent 50a91cf commit 9348eb9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
11 changes: 7 additions & 4 deletions src/components/voteDialog/voteDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@ import React from 'react';
import InfoParagraph from '../infoParagraph';
import ActionBar from '../actionBar';
import Fees from '../../constants/fees';
import votingConst from '../../constants/voting';
import Autocomplete from './voteAutocomplete';
import styles from './voteDialog.css';
import AuthInputs from '../authInputs';
import { authStatePrefill, authStateIsValid } from '../../utils/form';

const { maxCountOfVotes, maxCountOfVotesInOneTurn } = votingConst;

export default class VoteDialog extends React.Component {
constructor() {
super();
Expand Down Expand Up @@ -58,9 +61,9 @@ export default class VoteDialog extends React.Component {
<article className={styles.info}>
<InfoParagraph>
<p >
You can select up to 33 delegates in one voting turn.
You can select up to {maxCountOfVotesInOneTurn} delegates in one voting turn.
</p>
You can vote for up to 101 delegates in total.
You can vote for up to {maxCountOfVotes} delegates in total.
</InfoParagraph>
</article>

Expand All @@ -72,9 +75,9 @@ export default class VoteDialog extends React.Component {
label: 'Confirm',
fee: Fees.vote,
disabled: (
totalVotes > 101 ||
totalVotes > maxCountOfVotes ||
votesList.length === 0 ||
votesList.length > 33 ||
votesList.length > maxCountOfVotesInOneTurn ||
!authStateIsValid(this.state)
),
onClick: this.confirm.bind(this),
Expand Down
10 changes: 5 additions & 5 deletions src/components/voting/votingBar.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React from 'react';
import grid from 'flexboxgrid/dist/flexboxgrid.css';

import votingConst from '../../constants/voting';
import style from './votingBar.css';

const VotingBar = ({ votes }) => {
const voteMaxCount = 33;
const votedMaxCount = 101;
const { maxCountOfVotes, maxCountOfVotesInOneTurn } = votingConst;
const votedList = Object.keys(votes).filter(key => votes[key].confirmed);
const voteList = Object.keys(votes).filter(
key => votes[key].unconfirmed && !votes[key].confirmed);
Expand All @@ -27,17 +27,17 @@ const VotingBar = ({ votes }) => {
</span>
<span className={`${grid['col-sm-3']} ${grid['col-xs-12']} total-new-votes`}>
<span>Total new votes: </span>
<strong className={totalNewVotesCount > voteMaxCount && style.red}>
<strong className={totalNewVotesCount > maxCountOfVotesInOneTurn && style.red}>
{totalNewVotesCount}
</strong>
<span> / {voteMaxCount}</span>
<span> / {maxCountOfVotesInOneTurn}</span>
</span>
<span className={`${grid['col-sm-3']} ${grid['col-xs-12']} total-votes`}>
<span>Total votes: </span>
<strong className={totalVotesCount > 101 && style.red}>
{totalVotesCount}
</strong>
<span> / {votedMaxCount}</span>
<span> / {maxCountOfVotes}</span>
</span>
</div>
</div> :
Expand Down

0 comments on commit 9348eb9

Please sign in to comment.