diff options
author | 2021-08-13 00:45:01 +0530 | |
---|---|---|
committer | 2021-08-13 00:45:01 +0530 | |
commit | 2d27d5e66649d4f5baf127a53ee5ae524eae3a59 (patch) | |
tree | c592ea219ac8cd987fc367f57b54034c450ab2ab /src/features/delayApp/Component.js | |
parent | Ferdi v5.6.0 (diff) | |
parent | 5.6.1-nightly.24 [skip ci] (diff) | |
download | ferdium-app-2d27d5e66649d4f5baf127a53ee5ae524eae3a59.tar.gz ferdium-app-2d27d5e66649d4f5baf127a53ee5ae524eae3a59.tar.zst ferdium-app-2d27d5e66649d4f5baf127a53ee5ae524eae3a59.zip |
chore: merge from nightly branch into release branch in prep for next beta
Diffstat (limited to 'src/features/delayApp/Component.js')
-rw-r--r-- | src/features/delayApp/Component.js | 120 |
1 files changed, 0 insertions, 120 deletions
diff --git a/src/features/delayApp/Component.js b/src/features/delayApp/Component.js deleted file mode 100644 index 6471240ab..000000000 --- a/src/features/delayApp/Component.js +++ /dev/null | |||
@@ -1,120 +0,0 @@ | |||
1 | import React, { Component } from 'react'; | ||
2 | import PropTypes from 'prop-types'; | ||
3 | import { inject, observer } from 'mobx-react'; | ||
4 | import { defineMessages, intlShape } from 'react-intl'; | ||
5 | import injectSheet from 'react-jss'; | ||
6 | |||
7 | import { Button } from '@meetfranz/forms'; | ||
8 | |||
9 | import { config } from './constants'; | ||
10 | import styles from './styles'; | ||
11 | import UserStore from '../../stores/UserStore'; | ||
12 | import UIStore from '../../stores/UIStore'; | ||
13 | import { FeatureStore } from '../utils/FeatureStore'; | ||
14 | |||
15 | const messages = defineMessages({ | ||
16 | headline: { | ||
17 | id: 'feature.delayApp.headline', | ||
18 | defaultMessage: '!!!Please purchase license to skip waiting', | ||
19 | }, | ||
20 | headlineTrial: { | ||
21 | id: 'feature.delayApp.trial.headline', | ||
22 | defaultMessage: '!!!Get the free Franz Professional 14 day trial and skip the line', | ||
23 | }, | ||
24 | action: { | ||
25 | id: 'feature.delayApp.upgrade.action', | ||
26 | defaultMessage: '!!!Upgrade Franz', | ||
27 | }, | ||
28 | actionTrial: { | ||
29 | id: 'feature.delayApp.trial.action', | ||
30 | defaultMessage: '!!!Yes, I want the free 14 day trial of Franz Professional', | ||
31 | }, | ||
32 | text: { | ||
33 | id: 'feature.delayApp.text', | ||
34 | defaultMessage: '!!!Ferdi will continue in {seconds} seconds.', | ||
35 | }, | ||
36 | }); | ||
37 | |||
38 | export default @inject('stores', 'actions') @injectSheet(styles) @observer class DelayApp extends Component { | ||
39 | static propTypes = { | ||
40 | // eslint-disable-next-line | ||
41 | classes: PropTypes.object.isRequired, | ||
42 | }; | ||
43 | |||
44 | static contextTypes = { | ||
45 | intl: intlShape, | ||
46 | }; | ||
47 | |||
48 | state = { | ||
49 | countdown: config.delayDuration, | ||
50 | }; | ||
51 | |||
52 | countdownInterval = null; | ||
53 | |||
54 | countdownIntervalTimeout = 1000; | ||
55 | |||
56 | componentDidMount() { | ||
57 | this.countdownInterval = setInterval(() => { | ||
58 | this.setState(prevState => ({ | ||
59 | countdown: prevState.countdown - this.countdownIntervalTimeout, | ||
60 | })); | ||
61 | |||
62 | if (this.state.countdown <= 0) { | ||
63 | // reload(); | ||
64 | clearInterval(this.countdownInterval); | ||
65 | } | ||
66 | }, this.countdownIntervalTimeout); | ||
67 | } | ||
68 | |||
69 | componentWillUnmount() { | ||
70 | clearInterval(this.countdownInterval); | ||
71 | } | ||
72 | |||
73 | handleCTAClick() { | ||
74 | const { actions, stores } = this.props; | ||
75 | const { hadSubscription } = stores.user.data; | ||
76 | const { defaultTrialPlan } = stores.features.features; | ||
77 | |||
78 | if (!hadSubscription) { | ||
79 | actions.user.activateTrial({ planId: defaultTrialPlan }); | ||
80 | } else { | ||
81 | actions.ui.openSettings({ path: 'user' }); | ||
82 | } | ||
83 | } | ||
84 | |||
85 | render() { | ||
86 | const { classes, stores } = this.props; | ||
87 | const { intl } = this.context; | ||
88 | |||
89 | const { hadSubscription } = stores.user.data; | ||
90 | |||
91 | return ( | ||
92 | <div className={`${classes.container}`}> | ||
93 | <h1 className={classes.headline}>{intl.formatMessage(hadSubscription ? messages.headline : messages.headlineTrial)}</h1> | ||
94 | <Button | ||
95 | label={intl.formatMessage(hadSubscription ? messages.action : messages.actionTrial)} | ||
96 | className={classes.button} | ||
97 | buttonType="inverted" | ||
98 | onClick={this.handleCTAClick.bind(this)} | ||
99 | busy={stores.user.activateTrialRequest.isExecuting} | ||
100 | /> | ||
101 | <p className="footnote"> | ||
102 | {intl.formatMessage(messages.text, { | ||
103 | seconds: this.state.countdown / 1000, | ||
104 | })} | ||
105 | </p> | ||
106 | </div> | ||
107 | ); | ||
108 | } | ||
109 | } | ||
110 | |||
111 | DelayApp.wrappedComponent.propTypes = { | ||
112 | stores: PropTypes.shape({ | ||
113 | user: PropTypes.instanceOf(UserStore).isRequired, | ||
114 | features: PropTypes.instanceOf(FeatureStore).isRequired, | ||
115 | }).isRequired, | ||
116 | actions: PropTypes.shape({ | ||
117 | ui: PropTypes.instanceOf(UIStore).isRequired, | ||
118 | user: PropTypes.instanceOf(UserStore).isRequired, | ||
119 | }).isRequired, | ||
120 | }; | ||