diff options
Diffstat (limited to 'src/containers/subscription/SubscriptionFormScreen.js')
-rw-r--r-- | src/containers/subscription/SubscriptionFormScreen.js | 99 |
1 files changed, 0 insertions, 99 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 | }; | ||