aboutsummaryrefslogtreecommitdiffstats
path: root/src/containers/settings/AccountScreen.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/containers/settings/AccountScreen.js')
-rw-r--r--src/containers/settings/AccountScreen.js56
1 files changed, 9 insertions, 47 deletions
diff --git a/src/containers/settings/AccountScreen.js b/src/containers/settings/AccountScreen.js
index d681d5226..b3f967353 100644
--- a/src/containers/settings/AccountScreen.js
+++ b/src/containers/settings/AccountScreen.js
@@ -1,4 +1,3 @@
1import { remote } from 'electron';
2import React, { Component } from 'react'; 1import React, { Component } from 'react';
3import PropTypes from 'prop-types'; 2import PropTypes from 'prop-types';
4import { inject, observer } from 'mobx-react'; 3import { inject, observer } from 'mobx-react';
@@ -6,92 +5,55 @@ import { inject, observer } from 'mobx-react';
6import PaymentStore from '../../stores/PaymentStore'; 5import PaymentStore from '../../stores/PaymentStore';
7import UserStore from '../../stores/UserStore'; 6import UserStore from '../../stores/UserStore';
8import AppStore from '../../stores/AppStore'; 7import AppStore from '../../stores/AppStore';
9import { gaPage } from '../../lib/analytics';
10 8
11import AccountDashboard from '../../components/settings/account/AccountDashboard'; 9import AccountDashboard from '../../components/settings/account/AccountDashboard';
12import ErrorBoundary from '../../components/util/ErrorBoundary'; 10import ErrorBoundary from '../../components/util/ErrorBoundary';
13 11import { WEBSITE } from '../../environment';
14const { BrowserWindow } = remote;
15 12
16export default @inject('stores', 'actions') @observer class AccountScreen extends Component { 13export default @inject('stores', 'actions') @observer class AccountScreen extends Component {
17 componentWillMount() {
18 const {
19 user,
20 } = this.props.stores;
21
22 user.getUserInfoRequest.invalidate({ immediately: true });
23 }
24
25 componentDidMount() {
26 gaPage('Settings/Account Dashboard');
27 }
28
29 onCloseWindow() { 14 onCloseWindow() {
30 const { user, payment } = this.props.stores; 15 const { user } = this.props.stores;
31 user.getUserInfoRequest.invalidate({ immediately: true }); 16 user.getUserInfoRequest.invalidate({ immediately: true });
32 payment.ordersDataRequest.invalidate({ immediately: true });
33 } 17 }
34 18
35 reloadData() { 19 reloadData() {
36 const { user, payment } = this.props.stores; 20 const { user, payment } = this.props.stores;
37 21
38 user.getUserInfoRequest.reload(); 22 user.getUserInfoRequest.reload();
39 payment.ordersDataRequest.reload();
40 payment.plansRequest.reload(); 23 payment.plansRequest.reload();
41 } 24 }
42 25
43 async handlePaymentDashboard() { 26 handleWebsiteLink(route) {
44 const { actions, stores } = this.props; 27 const { actions, stores } = this.props;
45 28
46 actions.payment.createDashboardUrl(); 29 const url = `${WEBSITE}${route}?authToken=${stores.user.authToken}&utm_source=app&utm_medium=account_dashboard`;
47 30 console.log(url);
48 const dashboard = await stores.payment.createDashboardUrlRequest;
49
50 if (dashboard.url) {
51 const paymentWindow = new BrowserWindow({
52 title: '🔒 Franz Subscription Dashboard',
53 parent: remote.getCurrentWindow(),
54 modal: false,
55 width: 900,
56 minWidth: 600,
57 webPreferences: {
58 nodeIntegration: false,
59 },
60 });
61 paymentWindow.loadURL(dashboard.url);
62 31
63 paymentWindow.on('closed', () => { 32 actions.app.openExternalUrl({ url });
64 this.onCloseWindow();
65 });
66 }
67 } 33 }
68 34
69 render() { 35 render() {
70 const { user, payment } = this.props.stores; 36 const { user, payment } = this.props.stores;
71 const { openExternalUrl } = this.props.actions.app;
72 const { user: userActions } = this.props.actions; 37 const { user: userActions } = this.props.actions;
73 38
74 const isLoadingUserInfo = user.getUserInfoRequest.isExecuting; 39 const isLoadingUserInfo = user.getUserInfoRequest.isExecuting;
75 const isLoadingOrdersInfo = payment.ordersDataRequest.isExecuting;
76 const isLoadingPlans = payment.plansRequest.isExecuting; 40 const isLoadingPlans = payment.plansRequest.isExecuting;
77 41
78 return ( 42 return (
79 <ErrorBoundary> 43 <ErrorBoundary>
80 <AccountDashboard 44 <AccountDashboard
81 user={user.data} 45 user={user.data}
82 orders={payment.orders}
83 isLoading={isLoadingUserInfo} 46 isLoading={isLoadingUserInfo}
84 isLoadingOrdersInfo={isLoadingOrdersInfo}
85 isLoadingPlans={isLoadingPlans} 47 isLoadingPlans={isLoadingPlans}
86 userInfoRequestFailed={user.getUserInfoRequest.wasExecuted && user.getUserInfoRequest.isError} 48 userInfoRequestFailed={user.getUserInfoRequest.wasExecuted && user.getUserInfoRequest.isError}
87 retryUserInfoRequest={() => this.reloadData()} 49 retryUserInfoRequest={() => this.reloadData()}
88 isCreatingPaymentDashboardUrl={payment.createDashboardUrlRequest.isExecuting}
89 openDashboard={price => this.handlePaymentDashboard(price)}
90 openExternalUrl={url => openExternalUrl({ url })}
91 onCloseSubscriptionWindow={() => this.onCloseWindow()} 50 onCloseSubscriptionWindow={() => this.onCloseWindow()}
92 deleteAccount={userActions.delete} 51 deleteAccount={userActions.delete}
93 isLoadingDeleteAccount={user.deleteAccountRequest.isExecuting} 52 isLoadingDeleteAccount={user.deleteAccountRequest.isExecuting}
94 isDeleteAccountSuccessful={user.deleteAccountRequest.wasExecuted && !user.deleteAccountRequest.isError} 53 isDeleteAccountSuccessful={user.deleteAccountRequest.wasExecuted && !user.deleteAccountRequest.isError}
54 openEditAccount={() => this.handleWebsiteLink('/user/profile')}
55 openBilling={() => this.handleWebsiteLink('/user/billing')}
56 openInvoices={() => this.handleWebsiteLink('/user/invoices')}
95 /> 57 />
96 </ErrorBoundary> 58 </ErrorBoundary>
97 ); 59 );