aboutsummaryrefslogtreecommitdiffstats
path: root/src/features/planSelection
diff options
context:
space:
mode:
Diffstat (limited to 'src/features/planSelection')
-rw-r--r--src/features/planSelection/actions.js4
-rw-r--r--src/features/planSelection/components/PlanSelection.js2
-rw-r--r--src/features/planSelection/containers/PlanSelectionScreen.js13
-rw-r--r--src/features/planSelection/store.js40
4 files changed, 11 insertions, 48 deletions
diff --git a/src/features/planSelection/actions.js b/src/features/planSelection/actions.js
index 21aa38ace..83f58bfd7 100644
--- a/src/features/planSelection/actions.js
+++ b/src/features/planSelection/actions.js
@@ -2,10 +2,6 @@ import PropTypes from 'prop-types';
2import { createActionsFromDefinitions } from '../../actions/lib/actions'; 2import { createActionsFromDefinitions } from '../../actions/lib/actions';
3 3
4export const planSelectionActions = createActionsFromDefinitions({ 4export const planSelectionActions = createActionsFromDefinitions({
5 upgradeAccount: {
6 planId: PropTypes.string.isRequired,
7 onCloseWindow: PropTypes.func.isRequired,
8 },
9 downgradeAccount: {}, 5 downgradeAccount: {},
10 hideOverlay: {}, 6 hideOverlay: {},
11}, PropTypes.checkPropTypes); 7}, PropTypes.checkPropTypes);
diff --git a/src/features/planSelection/components/PlanSelection.js b/src/features/planSelection/components/PlanSelection.js
index 1a45cf035..cf4474114 100644
--- a/src/features/planSelection/components/PlanSelection.js
+++ b/src/features/planSelection/components/PlanSelection.js
@@ -205,7 +205,7 @@ class PlanSelection extends Component {
205 price={plans.pro.yearly.price} 205 price={plans.pro.yearly.price}
206 currency={currency} 206 currency={currency}
207 ctaLabel={intl.formatMessage(hadSubscription ? messages.shortActionPro : messages.actionTrial)} 207 ctaLabel={intl.formatMessage(hadSubscription ? messages.shortActionPro : messages.actionTrial)}
208 upgrade={() => upgradeAccount(plans.personal.yearly.id)} 208 upgrade={() => upgradeAccount(plans.pro.yearly.id)}
209 className={classes.featuredPlan} 209 className={classes.featuredPlan}
210 perUser 210 perUser
211 bestValue 211 bestValue
diff --git a/src/features/planSelection/containers/PlanSelectionScreen.js b/src/features/planSelection/containers/PlanSelectionScreen.js
index dff9051d8..6e8cdbf47 100644
--- a/src/features/planSelection/containers/PlanSelectionScreen.js
+++ b/src/features/planSelection/containers/PlanSelectionScreen.js
@@ -43,13 +43,10 @@ class PlanSelectionScreen extends Component {
43 } 43 }
44 44
45 upgradeAccount(planId) { 45 upgradeAccount(planId) {
46 const { upgradeAccount, hideOverlay } = this.props.actions.planSelection; 46 const { upgradeAccount } = this.props.actions.payment;
47 47
48 upgradeAccount({ 48 upgradeAccount({
49 planId, 49 planId,
50 onCloseWindow: () => {
51 hideOverlay();
52 },
53 }); 50 });
54 } 51 }
55 52
@@ -63,7 +60,7 @@ class PlanSelectionScreen extends Component {
63 const { user, features } = this.props.stores; 60 const { user, features } = this.props.stores;
64 const { plans, currency } = features.features.pricingConfig; 61 const { plans, currency } = features.features.pricingConfig;
65 const { activateTrial } = this.props.actions.user; 62 const { activateTrial } = this.props.actions.user;
66 const { upgradeAccount, downgradeAccount, hideOverlay } = this.props.actions.planSelection; 63 const { downgradeAccount, hideOverlay } = this.props.actions.planSelection;
67 64
68 return ( 65 return (
69 <ErrorBoundary> 66 <ErrorBoundary>
@@ -102,7 +99,7 @@ class PlanSelectionScreen extends Component {
102 downgradeAccount(); 99 downgradeAccount();
103 hideOverlay(); 100 hideOverlay();
104 } else { 101 } else {
105 upgradeAccount(plans.personal.yearly.id); 102 this.upgradeAccount(plans.personal.yearly.id);
106 103
107 gaEvent(GA_CATEGORY_PLAN_SELECTION, 'SelectPlan', 'Revoke'); 104 gaEvent(GA_CATEGORY_PLAN_SELECTION, 'SelectPlan', 'Revoke');
108 } 105 }
@@ -123,8 +120,10 @@ PlanSelectionScreen.wrappedComponent.propTypes = {
123 user: PropTypes.instanceOf(UserStore).isRequired, 120 user: PropTypes.instanceOf(UserStore).isRequired,
124 }).isRequired, 121 }).isRequired,
125 actions: PropTypes.shape({ 122 actions: PropTypes.shape({
126 planSelection: PropTypes.shape({ 123 payment: PropTypes.shape({
127 upgradeAccount: PropTypes.func.isRequired, 124 upgradeAccount: PropTypes.func.isRequired,
125 }),
126 planSelection: PropTypes.shape({
128 downgradeAccount: PropTypes.func.isRequired, 127 downgradeAccount: PropTypes.func.isRequired,
129 hideOverlay: PropTypes.func.isRequired, 128 hideOverlay: PropTypes.func.isRequired,
130 }), 129 }),
diff --git a/src/features/planSelection/store.js b/src/features/planSelection/store.js
index e229c37e5..0d4672722 100644
--- a/src/features/planSelection/store.js
+++ b/src/features/planSelection/store.js
@@ -42,7 +42,6 @@ export default class PlanSelectionStore extends FeatureStore {
42 // ACTIONS 42 // ACTIONS
43 43
44 this._registerActions(createActionBindings([ 44 this._registerActions(createActionBindings([
45 [planSelectionActions.upgradeAccount, this._upgradeAccount],
46 [planSelectionActions.downgradeAccount, this._downgradeAccount], 45 [planSelectionActions.downgradeAccount, this._downgradeAccount],
47 [planSelectionActions.hideOverlay, this._hideOverlay], 46 [planSelectionActions.hideOverlay, this._hideOverlay],
48 ])); 47 ]));
@@ -64,47 +63,12 @@ export default class PlanSelectionStore extends FeatureStore {
64 @action stop() { 63 @action stop() {
65 super.stop(); 64 super.stop();
66 debug('PlanSelectionStore::stop'); 65 debug('PlanSelectionStore::stop');
67 this.reset();
68 this.isFeatureActive = false; 66 this.isFeatureActive = false;
69 } 67 }
70 68
71 // ========== PRIVATE METHODS ========= // 69 // ========== PRIVATE METHODS ========= //
72 70
73 // Actions 71 // Actions
74
75 @action _upgradeAccount = ({ planId, onCloseWindow = () => null }) => {
76 let hostedPageURL = this.stores.features.features.subscribeURL;
77
78 const parsedUrl = new URL(hostedPageURL);
79 const params = new URLSearchParams(parsedUrl.search.slice(1));
80
81 params.set('plan', planId);
82
83 hostedPageURL = this.stores.user.getAuthURL(`${parsedUrl.origin}${parsedUrl.pathname}?${params.toString()}`);
84
85 const win = new BrowserWindow({
86 parent: remote.getCurrentWindow(),
87 modal: true,
88 title: '🔒 Upgrade Your Franz Account',
89 width: 800,
90 height: window.innerHeight - 100,
91 maxWidth: 800,
92 minWidth: 600,
93 webPreferences: {
94 nodeIntegration: true,
95 webviewTag: true,
96 },
97 });
98 win.loadURL(`file://${__dirname}/../../index.html#/payment/${encodeURIComponent(hostedPageURL)}`);
99
100 win.on('closed', () => {
101 this.stores.user.getUserInfoRequest.invalidate({ immediately: true });
102 this.stores.features.featuresRequest.invalidate({ immediately: true });
103
104 onCloseWindow();
105 });
106 };
107
108 @action _downgradeAccount = () => { 72 @action _downgradeAccount = () => {
109 downgradeUserRequest.execute(); 73 downgradeUserRequest.execute();
110 } 74 }
@@ -112,4 +76,8 @@ export default class PlanSelectionStore extends FeatureStore {
112 @action _hideOverlay = () => { 76 @action _hideOverlay = () => {
113 this.hideOverlay = true; 77 this.hideOverlay = true;
114 } 78 }
79
80 @action _showOverlay = () => {
81 this.hideOverlay = false;
82 }
115} 83}