aboutsummaryrefslogtreecommitdiffstats
path: root/src/containers/subscription
diff options
context:
space:
mode:
Diffstat (limited to 'src/containers/subscription')
-rw-r--r--src/containers/subscription/SubscriptionFormScreen.js99
-rw-r--r--src/containers/subscription/SubscriptionPopupScreen.js41
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 @@
1import React, { Component } from 'react';
2import { BrowserWindow, getCurrentWindow } from '@electron/remote';
3import PropTypes from 'prop-types';
4import { inject, observer } from 'mobx-react';
5
6import PaymentStore from '../../stores/PaymentStore';
7
8import SubscriptionForm from '../../components/subscription/SubscriptionForm';
9import TrialForm from '../../components/subscription/TrialForm';
10import UserStore from '../../stores/UserStore';
11import FeaturesStore from '../../stores/FeaturesStore';
12import AppStore from '../../stores/AppStore';
13
14export 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
88SubscriptionFormScreen.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 @@
1import React, { Component } from 'react';
2import PropTypes from 'prop-types';
3import { inject, observer } from 'mobx-react';
4
5import SubscriptionPopup from '../../components/subscription/SubscriptionPopup';
6import { isDevMode } from '../../environment';
7
8export 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
35SubscriptionPopupScreen.wrappedComponent.propTypes = {
36 router: PropTypes.shape({
37 params: PropTypes.shape({
38 url: PropTypes.string.isRequired,
39 }).isRequired,
40 }).isRequired,
41};