-
Notifications
You must be signed in to change notification settings - Fork 295
/
StakingInfoCountdown.tsx
124 lines (116 loc) · 4.37 KB
/
StakingInfoCountdown.tsx
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
// @flow
import React, { Component } from 'react';
import { observer } from 'mobx-react';
import { defineMessages, intlShape } from 'react-intl';
import { ButtonSkin } from 'react-polymorph/lib/skins/simple/ButtonSkin';
import ButtonLink from '../../widgets/ButtonLink';
import styles from './StakingInfoCountdown.scss';
import FullyDecentralizedEffect from '../../widgets/FullyDecentralizedEffect';
import CountdownWidget from '../../widgets/CountdownWidget';
const messages = defineMessages({
heading: {
id: 'staking.infoCountdown.heading',
defaultMessage: '!!!Alonzo upgrade',
description: 'Headline for the "Staking Info" page screen.',
},
descriptionBefore: {
id: 'staking.infoCountdown.description.before',
defaultMessage:
'!!!The ‘Alonzo’ protocol upgrade will bring highly-anticipated new smart contract capabilities to Cardano, by integrating Plutus scripts onto the blockchain. This important milestone will open up a whole new world of smart contracts, DeFi capabilities, and dApp development on Cardano.',
description: 'Info description for the "Staking Info" page screen.',
},
descriptionAfter: {
id: 'staking.infoCountdown.description.after',
defaultMessage:
'!!!The ‘Alonzo’ protocol upgrade is now live on Cardano, enabling highly-anticipated new smart contract capabilities, by integrating Plutus scripts onto the blockchain. This important milestone opens up a whole new world of smart contracts, DeFi capabilities, and dApp development on Cardano.',
description: 'Info description for the "Staking Info" page screen.',
},
countdownTitle: {
id: 'staking.infoCountdown.countdownTitle',
defaultMessage: '!!!Alonzo upgrade in',
description: 'Countdown Title for the "Staking Info" page screen.',
},
buttonLabel: {
id: 'staking.infoCountdown.buttonLabel',
defaultMessage: '!!!Learn more',
description: 'Button Label for the "Staking Info" page screen.',
},
learnMoreLinkUrl: {
id: 'staking.infoCountdown.learnMore.linkUrl',
defaultMessage:
'!!!https://iohk.io/en/blog/posts/2021/04/08/smart-contracts-%E2%80%93-here-we-come/',
description: '"Learn more" link URL in the "Staking Info" screen.',
},
});
type Props = {
startDateTime: string,
isAlonzoActivated: boolean,
stakingInfoWasOpen: boolean,
onSetStakingInfoWasOpen: Function,
onLearnMoreClick: Function,
};
@observer
export default class StakingInfoCountdown extends Component<Props> {
static defaultProps = {
percentage: 0,
};
static contextTypes = {
intl: intlShape.isRequired,
};
componentDidMount() {
this.checkIfShouldSetStakingInfoWasOpen();
}
componentDidUpdate() {
this.checkIfShouldSetStakingInfoWasOpen();
}
checkIfShouldSetStakingInfoWasOpen = () => {
const {
onSetStakingInfoWasOpen,
isAlonzoActivated,
stakingInfoWasOpen,
} = this.props;
if (isAlonzoActivated && !stakingInfoWasOpen) {
onSetStakingInfoWasOpen();
}
};
render() {
const { intl } = this.context;
const { startDateTime, onLearnMoreClick, isAlonzoActivated } = this.props;
const heading = intl.formatMessage(messages.heading);
const description = isAlonzoActivated
? messages.descriptionAfter
: messages.descriptionBefore;
const buttonLabel = intl.formatMessage(messages.buttonLabel);
return (
<div className={styles.component}>
<div className={styles.mainContent}>
<div className={styles.content}>
<div className={styles.heading}>{heading}</div>
<div className={styles.description}>
{intl.formatMessage(description)}
</div>
<div className={styles.countdownTitle}>
{intl.formatMessage(messages.countdownTitle)}
</div>
<CountdownWidget
startDateTime={isAlonzoActivated ? '0' : startDateTime}
format="DD-HH-mm-ss"
/>
<ButtonLink
className={styles.learnMoreButton}
onClick={() =>
onLearnMoreClick(intl.formatMessage(messages.learnMoreLinkUrl))
}
skin={ButtonSkin}
label={buttonLabel}
linkProps={{
className: styles.externalLinkIcon,
}}
/>
</div>
<FullyDecentralizedEffect isActive={isAlonzoActivated} />
</div>
</div>
);
}
}