diff options
Diffstat (limited to 'src/containers/subscription')
-rw-r--r-- | src/containers/subscription/SubscriptionFormScreen.js | 99 | ||||
-rw-r--r-- | src/containers/subscription/SubscriptionPopupScreen.js | 41 |
2 files changed, 0 insertions, 140 deletions
diff --git a/src/containers/subscription/SubscriptionFormScreen.js b/src/containers/subscription/SubscriptionFormScreen.js deleted file mode 100644 index e5c8207be..000000000 --- a/src/containers/subscription/SubscriptionFormScreen.js +++ /dev/null | |||
@@ -1,99 +0,0 @@ | |||
1 | import React, { Component } from 'react'; | ||
2 | import { BrowserWindow, getCurrentWindow } from '@electron/remote'; | ||
3 | import PropTypes from 'prop-types'; | ||
4 | import { inject, observer } from 'mobx-react'; | ||
5 | |||
6 | import PaymentStore from '../../stores/PaymentStore'; | ||
7 | |||
8 | import SubscriptionForm from '../../components/subscription/SubscriptionForm'; | ||
9 | import TrialForm from '../../components/subscription/TrialForm'; | ||
10 | import UserStore from '../../stores/UserStore'; | ||
11 | import FeaturesStore from '../../stores/FeaturesStore'; | ||
12 | import AppStore from '../../stores/AppStore'; | ||
13 | |||
14 | export default @inject('stores', 'actions') @observer class SubscriptionFormScreen extends Component { | ||
15 | static propTypes = { | ||
16 | onCloseWindow: PropTypes.func, | ||
17 | } | ||
18 | |||
19 | static defaultProps = { | ||
20 | onCloseWindow: () => null, | ||
21 | } | ||
22 | |||
23 | async openBrowser() { | ||
24 | const { | ||
25 | stores, | ||
26 | onCloseWindow, | ||
27 | } = this.props; | ||
28 | |||
29 | const { | ||
30 | user, | ||
31 | features, | ||
32 | } = stores; | ||
33 | |||
34 | let hostedPageURL = features.features.planSelectionURL; | ||
35 | hostedPageURL = user.getAuthURL(hostedPageURL); | ||
36 | |||
37 | const paymentWindow = new BrowserWindow({ | ||
38 | parent: getCurrentWindow(), | ||
39 | modal: true, | ||
40 | title: '🔒 Franz Supporter License', | ||
41 | width: 800, | ||
42 | height: window.innerHeight - 100, | ||
43 | maxWidth: 800, | ||
44 | minWidth: 600, | ||
45 | webPreferences: { | ||
46 | nodeIntegration: true, | ||
47 | webviewTag: true, | ||
48 | enableRemoteModule: true, | ||
49 | contextIsolation: false, | ||
50 | }, | ||
51 | }); | ||
52 | paymentWindow.loadURL(`file://${__dirname}/../../index.html#/payment/${encodeURIComponent(hostedPageURL)}`); | ||
53 | |||
54 | paymentWindow.on('closed', () => { | ||
55 | onCloseWindow(); | ||
56 | }); | ||
57 | } | ||
58 | |||
59 | render() { | ||
60 | const { | ||
61 | actions, | ||
62 | stores, | ||
63 | } = this.props; | ||
64 | |||
65 | const { data: user } = stores.user; | ||
66 | |||
67 | if (user.hadSubscription) { | ||
68 | return ( | ||
69 | <SubscriptionForm | ||
70 | plan={stores.payment.plan} | ||
71 | selectPlan={() => this.openBrowser()} | ||
72 | isActivatingTrial={stores.user.activateTrialRequest.isExecuting || stores.user.getUserInfoRequest.isExecuting} | ||
73 | /> | ||
74 | ); | ||
75 | } | ||
76 | |||
77 | return ( | ||
78 | <TrialForm | ||
79 | plan={stores.payment.plan} | ||
80 | activateTrial={() => actions.user.activateTrial({ planId: stores.features.features.defaultTrialPlan })} | ||
81 | showAllOptions={() => this.openBrowser()} | ||
82 | isActivatingTrial={stores.user.activateTrialRequest.isExecuting || stores.user.getUserInfoRequest.isExecuting} | ||
83 | /> | ||
84 | ); | ||
85 | } | ||
86 | } | ||
87 | |||
88 | SubscriptionFormScreen.wrappedComponent.propTypes = { | ||
89 | actions: PropTypes.shape({ | ||
90 | app: PropTypes.instanceOf(AppStore).isRequired, | ||
91 | payment: PropTypes.instanceOf(PaymentStore).isRequired, | ||
92 | user: PropTypes.instanceOf(UserStore).isRequired, | ||
93 | }).isRequired, | ||
94 | stores: PropTypes.shape({ | ||
95 | payment: PropTypes.instanceOf(PaymentStore).isRequired, | ||
96 | user: PropTypes.instanceOf(UserStore).isRequired, | ||
97 | features: PropTypes.instanceOf(FeaturesStore).isRequired, | ||
98 | }).isRequired, | ||
99 | }; | ||
diff --git a/src/containers/subscription/SubscriptionPopupScreen.js b/src/containers/subscription/SubscriptionPopupScreen.js deleted file mode 100644 index 43966b6a4..000000000 --- a/src/containers/subscription/SubscriptionPopupScreen.js +++ /dev/null | |||
@@ -1,41 +0,0 @@ | |||
1 | import React, { Component } from 'react'; | ||
2 | import PropTypes from 'prop-types'; | ||
3 | import { inject, observer } from 'mobx-react'; | ||
4 | |||
5 | import SubscriptionPopup from '../../components/subscription/SubscriptionPopup'; | ||
6 | import { isDevMode } from '../../environment'; | ||
7 | |||
8 | export default @inject('stores', 'actions') @observer class SubscriptionPopupScreen extends Component { | ||
9 | state = { | ||
10 | complete: false, | ||
11 | }; | ||
12 | |||
13 | completeCheck(event) { | ||
14 | const { url } = event; | ||
15 | |||
16 | if ((url.includes('recurly') && url.includes('confirmation')) || ((url.includes('meetfranz') || isDevMode) && url.includes('success'))) { | ||
17 | this.setState({ | ||
18 | complete: true, | ||
19 | }); | ||
20 | } | ||
21 | } | ||
22 | |||
23 | render() { | ||
24 | return ( | ||
25 | <SubscriptionPopup | ||
26 | url={this.props.router.params.url} | ||
27 | closeWindow={() => window.close()} | ||
28 | completeCheck={e => this.completeCheck(e)} | ||
29 | isCompleted={this.state.complete} | ||
30 | /> | ||
31 | ); | ||
32 | } | ||
33 | } | ||
34 | |||
35 | SubscriptionPopupScreen.wrappedComponent.propTypes = { | ||
36 | router: PropTypes.shape({ | ||
37 | params: PropTypes.shape({ | ||
38 | url: PropTypes.string.isRequired, | ||
39 | }).isRequired, | ||
40 | }).isRequired, | ||
41 | }; | ||