diff options
Diffstat (limited to 'src/features/planSelection/containers/PlanSelectionScreen.js')
-rw-r--r-- | src/features/planSelection/containers/PlanSelectionScreen.js | 120 |
1 files changed, 0 insertions, 120 deletions
diff --git a/src/features/planSelection/containers/PlanSelectionScreen.js b/src/features/planSelection/containers/PlanSelectionScreen.js deleted file mode 100644 index 594829c01..000000000 --- a/src/features/planSelection/containers/PlanSelectionScreen.js +++ /dev/null | |||
@@ -1,120 +0,0 @@ | |||
1 | import React, { Component } from 'react'; | ||
2 | import { observer, inject } from 'mobx-react'; | ||
3 | import PropTypes from 'prop-types'; | ||
4 | import { dialog, app } from '@electron/remote'; | ||
5 | import { defineMessages, intlShape } from 'react-intl'; | ||
6 | |||
7 | import FeaturesStore from '../../../stores/FeaturesStore'; | ||
8 | import UserStore from '../../../stores/UserStore'; | ||
9 | import PlanSelection from '../components/PlanSelection'; | ||
10 | import ErrorBoundary from '../../../components/util/ErrorBoundary'; | ||
11 | import { planSelectionStore } from '..'; | ||
12 | import PaymentStore from '../../../stores/PaymentStore'; | ||
13 | |||
14 | const messages = defineMessages({ | ||
15 | dialogTitle: { | ||
16 | id: 'feature.planSelection.fullscreen.dialog.title', | ||
17 | defaultMessage: '!!!Downgrade your Franz Plan', | ||
18 | }, | ||
19 | dialogMessage: { | ||
20 | id: 'feature.planSelection.fullscreen.dialog.message', | ||
21 | defaultMessage: '!!!You\'re about to downgrade to our Free account. Are you sure? Click here instead to get more services and functionality for just {currency}{price} a month.', | ||
22 | }, | ||
23 | dialogCTADowngrade: { | ||
24 | id: 'feature.planSelection.fullscreen.dialog.cta.downgrade', | ||
25 | defaultMessage: '!!!Downgrade to Free', | ||
26 | }, | ||
27 | dialogCTAUpgrade: { | ||
28 | id: 'feature.planSelection.fullscreen.dialog.cta.upgrade', | ||
29 | defaultMessage: '!!!Choose Personal', | ||
30 | }, | ||
31 | }); | ||
32 | |||
33 | @inject('stores', 'actions') @observer | ||
34 | class PlanSelectionScreen extends Component { | ||
35 | static contextTypes = { | ||
36 | intl: intlShape, | ||
37 | }; | ||
38 | |||
39 | upgradeAccount(planId) { | ||
40 | const { upgradeAccount } = this.props.actions.payment; | ||
41 | |||
42 | upgradeAccount({ | ||
43 | planId, | ||
44 | }); | ||
45 | } | ||
46 | |||
47 | render() { | ||
48 | if (!planSelectionStore || !planSelectionStore.isFeatureActive || !planSelectionStore.showPlanSelectionOverlay) { | ||
49 | return null; | ||
50 | } | ||
51 | |||
52 | const { intl } = this.context; | ||
53 | |||
54 | const { user, features } = this.props.stores; | ||
55 | const { isPersonalPlanAvailable, pricingConfig } = features.features; | ||
56 | const { plans, currency } = pricingConfig; | ||
57 | const { activateTrial } = this.props.actions.user; | ||
58 | const { downgradeAccount, hideOverlay } = this.props.actions.planSelection; | ||
59 | |||
60 | return ( | ||
61 | <ErrorBoundary> | ||
62 | <PlanSelection | ||
63 | firstname={user.data.firstname} | ||
64 | plans={plans} | ||
65 | currency={currency} | ||
66 | upgradeAccount={(planId) => { | ||
67 | if (user.data.hadSubscription) { | ||
68 | this.upgradeAccount(planId); | ||
69 | } else { | ||
70 | activateTrial({ | ||
71 | planId, | ||
72 | }); | ||
73 | } | ||
74 | }} | ||
75 | stayOnFree={() => { | ||
76 | const selection = dialog.showMessageBoxSync(app.mainWindow, { | ||
77 | type: 'question', | ||
78 | message: intl.formatMessage(messages.dialogTitle), | ||
79 | detail: intl.formatMessage(messages.dialogMessage, { | ||
80 | currency, | ||
81 | price: plans.personal.yearly.price, | ||
82 | }), | ||
83 | buttons: [ | ||
84 | intl.formatMessage(messages.dialogCTADowngrade), | ||
85 | intl.formatMessage(messages.dialogCTAUpgrade), | ||
86 | ], | ||
87 | }); | ||
88 | |||
89 | if (selection === 0) { | ||
90 | downgradeAccount(); | ||
91 | hideOverlay(); | ||
92 | } else { | ||
93 | this.upgradeAccount(plans.personal.yearly.id); | ||
94 | } | ||
95 | }} | ||
96 | subscriptionExpired={user.team && user.team.state === 'expired' && !user.team.userHasDowngraded} | ||
97 | hadSubscription={user.data.hadSubscription} | ||
98 | isPersonalPlanAvailable={isPersonalPlanAvailable} | ||
99 | /> | ||
100 | </ErrorBoundary> | ||
101 | ); | ||
102 | } | ||
103 | } | ||
104 | |||
105 | export default PlanSelectionScreen; | ||
106 | |||
107 | PlanSelectionScreen.wrappedComponent.propTypes = { | ||
108 | stores: PropTypes.shape({ | ||
109 | features: PropTypes.instanceOf(FeaturesStore).isRequired, | ||
110 | user: PropTypes.instanceOf(UserStore).isRequired, | ||
111 | }).isRequired, | ||
112 | actions: PropTypes.shape({ | ||
113 | payment: PropTypes.instanceOf(PaymentStore), | ||
114 | planSelection: PropTypes.shape({ | ||
115 | downgradeAccount: PropTypes.func.isRequired, | ||
116 | hideOverlay: PropTypes.func.isRequired, | ||
117 | }), | ||
118 | user: PropTypes.instanceOf(UserStore).isRequired, | ||
119 | }).isRequired, | ||
120 | }; | ||