-
Notifications
You must be signed in to change notification settings - Fork 97
/
votingHeader.js
95 lines (92 loc) 路 3.42 KB
/
votingHeader.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import React from 'react';
import { Link } from 'react-router-dom';
import { SecondaryButtonV2, PrimaryButtonV2 } from '../toolbox/buttons/button';
import Tooltip from '../toolbox/tooltip/tooltip';
import SignInTooltipWrapper from '../signInTooltipWrapper';
import routes from './../../constants/routes';
import votingConst from '../../constants/voting';
import {
getTotalVotesCount,
getVoteList,
getUnvoteList,
getTotalActions,
} from './../../utils/voting';
import styles from './votingHeader.css';
class VotingHeader extends React.Component {
render() {
const {
t,
votes,
toggleVotingMode,
votingModeEnabled,
} = this.props;
const voteList = getVoteList(votes);
const unvoteList = getUnvoteList(votes);
const totalActions = getTotalActions(votes);
const {
maxCountOfVotes,
fee,
} = votingConst;
return (
<div className={`${styles.wrapper}`}>
<span>
<span className={styles.box}>
<h2>{getTotalVotesCount(votes)}/{maxCountOfVotes}</h2>
<div>{t('My votes after confirmation')}</div>
</span>
{ votingModeEnabled ?
<span className={`${styles.outlinedBox} ${styles.addedVotes}`}>
<h3>{voteList.length}</h3>
<span>{t('Added votes')}</span>
</span> :
null }
{ unvoteList.length ?
<span className={`${styles.outlinedBox} ${styles.removedVotes}`}>
<h3>{unvoteList.length}</h3>
<span>{t('Removed votes')}</span>
</span> :
null }
{ votingModeEnabled ?
<span className={styles.outlinedBox}>
<h3>{totalActions}
<Tooltip className={styles.tooltip}>
<p>{t('Each time you add or remove a vote it is counted as an action. There\'s {{fee}} LSK fee per every 33 actions.', { fee })}</p>
</Tooltip>
</h3>
<span className={styles.hideInMedium}>{t('Total actions (')}</span>
<span>{t('Total fee: ')} <b>{fee * totalActions} LSK</b></span>
<span className={styles.hideInMedium}>)</span>
</span> :
null }
</span>
{ votingModeEnabled ?
<span>
<SecondaryButtonV2 onClick={toggleVotingMode} className={`cancel-voting-button ${styles.btn}`}>
{t('Cancel voting')}
</SecondaryButtonV2>
<Link to={routes.voting.path} >
<PrimaryButtonV2 className={styles.btn} disabled={totalActions === 0}>
{t('Go to Confirmation')}
</PrimaryButtonV2>
</Link>
</span> :
<span>
<SignInTooltipWrapper>
<Link to={routes.registerDelegate.path} >
<SecondaryButtonV2 className={`register-delegate ${styles.btn}`}>
{t('Register as a Delegate')}
</SecondaryButtonV2>
</Link>
</SignInTooltipWrapper>
<SignInTooltipWrapper>
<PrimaryButtonV2 onClick={toggleVotingMode} className={`start-voting-button ${styles.btn}`}>
{t('Start voting')}
</PrimaryButtonV2>
</SignInTooltipWrapper>
</span>
}
</div>
);
}
}
export default VotingHeader;