diff options
Diffstat (limited to 'src/containers/settings/AccountScreen.js')
-rw-r--r-- | src/containers/settings/AccountScreen.js | 88 |
1 files changed, 0 insertions, 88 deletions
diff --git a/src/containers/settings/AccountScreen.js b/src/containers/settings/AccountScreen.js deleted file mode 100644 index aae230577..000000000 --- a/src/containers/settings/AccountScreen.js +++ /dev/null | |||
@@ -1,88 +0,0 @@ | |||
1 | import { Component } from 'react'; | ||
2 | import PropTypes from 'prop-types'; | ||
3 | import { inject, observer } from 'mobx-react'; | ||
4 | |||
5 | import UserStore from '../../stores/UserStore'; | ||
6 | import AppStore from '../../stores/AppStore'; | ||
7 | import FeaturesStore from '../../stores/FeaturesStore'; | ||
8 | import SettingsStore from '../../stores/SettingsStore'; | ||
9 | |||
10 | import AccountDashboard from '../../components/settings/account/AccountDashboard'; | ||
11 | import ErrorBoundary from '../../components/util/ErrorBoundary'; | ||
12 | import { LIVE_FRANZ_API } from '../../config'; | ||
13 | import { WEBSITE } from '../../environment-remote'; | ||
14 | |||
15 | class AccountScreen extends Component { | ||
16 | onCloseWindow() { | ||
17 | const { user, features } = this.props.stores; | ||
18 | user.getUserInfoRequest.invalidate({ immediately: true }); | ||
19 | features.featuresRequest.invalidate({ immediately: true }); | ||
20 | } | ||
21 | |||
22 | reloadData() { | ||
23 | const { user } = this.props.stores; | ||
24 | |||
25 | user.getUserInfoRequest.reload(); | ||
26 | } | ||
27 | |||
28 | handleWebsiteLink(route) { | ||
29 | const { actions, stores } = this.props; | ||
30 | |||
31 | const api = stores.settings.all.app.server; | ||
32 | |||
33 | const url = | ||
34 | api === LIVE_FRANZ_API | ||
35 | ? stores.user.getAuthURL( | ||
36 | `${WEBSITE}${route}?utm_source=app&utm_medium=account_dashboard`, | ||
37 | ) | ||
38 | : `${api}${route}`; | ||
39 | |||
40 | actions.app.openExternalUrl({ url }); | ||
41 | } | ||
42 | |||
43 | render() { | ||
44 | const { user, settings } = this.props.stores; | ||
45 | const { user: userActions } = this.props.actions; | ||
46 | |||
47 | const isLoadingUserInfo = user.getUserInfoRequest.isExecuting; | ||
48 | |||
49 | return ( | ||
50 | <ErrorBoundary> | ||
51 | <AccountDashboard | ||
52 | server={settings.all.app.server} | ||
53 | user={user.data} | ||
54 | isLoading={isLoadingUserInfo} | ||
55 | userInfoRequestFailed={ | ||
56 | user.getUserInfoRequest.wasExecuted && | ||
57 | user.getUserInfoRequest.isError | ||
58 | } | ||
59 | retryUserInfoRequest={() => this.reloadData()} | ||
60 | onCloseSubscriptionWindow={() => this.onCloseWindow()} | ||
61 | deleteAccount={userActions.delete} | ||
62 | isLoadingDeleteAccount={user.deleteAccountRequest.isExecuting} | ||
63 | isDeleteAccountSuccessful={ | ||
64 | user.deleteAccountRequest.wasExecuted && | ||
65 | !user.deleteAccountRequest.isError | ||
66 | } | ||
67 | openEditAccount={() => this.handleWebsiteLink('/user/profile')} | ||
68 | openInvoices={() => this.handleWebsiteLink('/user/invoices')} | ||
69 | /> | ||
70 | </ErrorBoundary> | ||
71 | ); | ||
72 | } | ||
73 | } | ||
74 | |||
75 | AccountScreen.propTypes = { | ||
76 | stores: PropTypes.shape({ | ||
77 | user: PropTypes.instanceOf(UserStore).isRequired, | ||
78 | features: PropTypes.instanceOf(FeaturesStore).isRequired, | ||
79 | settings: PropTypes.instanceOf(SettingsStore).isRequired, | ||
80 | app: PropTypes.instanceOf(AppStore).isRequired, | ||
81 | }).isRequired, | ||
82 | actions: PropTypes.shape({ | ||
83 | app: PropTypes.instanceOf(AppStore).isRequired, | ||
84 | user: PropTypes.instanceOf(UserStore).isRequired, | ||
85 | }).isRequired, | ||
86 | }; | ||
87 | |||
88 | export default inject('stores', 'actions')(observer(AccountScreen)); | ||