Skip to content
Snippets Groups Projects
Commit 17c4eeef authored by Quoc Huy Nguyen Dinh's avatar Quoc Huy Nguyen Dinh
Browse files

Closes #36

- handle governance expiry date back in 1969/1970
- handle expired governance
parent c839efce
No related branches found
No related tags found
2 merge requests!137Closes #36,!133Fix: Governance expiry warning should have proper year at all times
......@@ -5,14 +5,13 @@ import { FormattedHTMLMessage } from 'app/Translator';
class WitnessVoteExpiryWarning extends React.Component {
render() {
let governance_vote_expiration_ts =
this.props.governance_vote_expiration_ts !== undefined
? this.props.governance_vote_expiration_ts
: new Date(new Date().setFullYear(new Date().getFullYear() + 1))
.toISOString()
.split('.')[0];
const { governance_vote_expiration_ts } = this.props;
const governance_vote_expiration_time = governance_vote_expiration_ts !== undefined
? governance_vote_expiration_ts
: new Date(new Date().setFullYear(new Date().getFullYear() + 1)).toISOString().split('.')[0];
const now = Moment();
const expiryDate = Moment(`${governance_vote_expiration_ts}Z`);
const expiryDate = Moment(`${governance_vote_expiration_time}Z`);
const expiryYear = parseInt(expiryDate.format('YYYY'));
const expiryDiff = expiryDate.diff(now, 'months');
if (expiryDiff > 3 || !expiryDiff || !expiryDate) {
......@@ -24,14 +23,32 @@ class WitnessVoteExpiryWarning extends React.Component {
<div className="column">
<div className="callout alert">
<p>
<FormattedHTMLMessage
className="primary"
id="g.governanceExpiryWarning"
params={{
date: expiryDate.format('ll'),
duration: '1 year',
}}
/>
{expiryYear >= 2016 && expiryDiff > 0 && (
<FormattedHTMLMessage
className="primary"
id="g.governanceExpiryWarning"
params={{
date: expiryDate.format('ll'),
duration: '1 year',
}}
/>
)}
{expiryYear >= 2016 && expiryDiff <= 0 && (
<FormattedHTMLMessage
className="primary"
id="g.governanceExpired"
params={{
date: expiryDate.format('ll'),
duration: '1 year',
}}
/>
)}
{expiryYear < 2016 && (
<FormattedHTMLMessage
className="primary"
id="g.pleaseVoteForWitnesses"
/>
)}
</p>
</div>
</div>
......
......@@ -237,7 +237,9 @@
"cannot_encrypt_memo": "cannot encrypt memo with current login method",
"rcLevel": "Resource Credits (RC) level: %(rc_percent)s%%.",
"rcFullIn": "Full in %(duration)s",
"governanceExpiryWarning": "Witness votes auto-expire %(duration)s after your last governance transaction. Your present votes will expire on %(date)s. Please <a href=\"/~witnesses\">update your Witness votes</a> to reset."
"governanceExpiryWarning": "Witness votes auto-expire %(duration)s after your last governance transaction. Your present votes will expire on %(date)s. Please <a href=\"/~witnesses\">update your Witness votes</a> to reset.",
"governanceExpired": "Your Witnesses votes have expired on %(date)s. Please <a href=\"/~witnesses\">update your Witness votes</a> to reset.",
"pleaseVoteForWitnesses": "It looks like you have not yet voted for Witnesses, you can do so on the <a href=\"/~witnesses\">Witnesses page</a>"
},
"navigation": {
"about": "About Hive",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment