aboutsummaryrefslogtreecommitdiffstats
path: root/src/containers/subscription/SubscriptionFormScreen.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/containers/subscription/SubscriptionFormScreen.js')
-rw-r--r--src/containers/subscription/SubscriptionFormScreen.js99
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 @@
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};