diff options
Diffstat (limited to 'src/containers/auth')
-rw-r--r-- | src/containers/auth/PricingScreen.js | 83 | ||||
-rw-r--r-- | src/containers/auth/SetupAssistantScreen.js | 9 | ||||
-rw-r--r-- | src/containers/auth/SignupScreen.js | 11 |
3 files changed, 4 insertions, 99 deletions
diff --git a/src/containers/auth/PricingScreen.js b/src/containers/auth/PricingScreen.js deleted file mode 100644 index 97bf1f6be..000000000 --- a/src/containers/auth/PricingScreen.js +++ /dev/null | |||
@@ -1,83 +0,0 @@ | |||
1 | import React, { Component } from 'react'; | ||
2 | import PropTypes from 'prop-types'; | ||
3 | import { inject, observer } from 'mobx-react'; | ||
4 | import { RouterStore } from 'mobx-react-router'; | ||
5 | |||
6 | import Pricing from '../../components/auth/Pricing'; | ||
7 | import UserStore from '../../stores/UserStore'; | ||
8 | |||
9 | import { globalError as globalErrorPropType } from '../../prop-types'; | ||
10 | import FeaturesStore from '../../stores/FeaturesStore'; | ||
11 | |||
12 | export default @inject('stores', 'actions') @observer class PricingScreen extends Component { | ||
13 | static propTypes = { | ||
14 | error: globalErrorPropType.isRequired, | ||
15 | }; | ||
16 | |||
17 | async submit() { | ||
18 | const { | ||
19 | actions, | ||
20 | stores, | ||
21 | } = this.props; | ||
22 | |||
23 | const { activateTrialRequest } = stores.user; | ||
24 | const { defaultTrialPlan, canSkipTrial } = stores.features.anonymousFeatures; | ||
25 | |||
26 | if (!canSkipTrial) { | ||
27 | stores.router.push('/'); | ||
28 | stores.user.hasCompletedSignup = true; | ||
29 | } else { | ||
30 | actions.user.activateTrial({ planId: defaultTrialPlan }); | ||
31 | await activateTrialRequest._promise; | ||
32 | |||
33 | if (!activateTrialRequest.isError) { | ||
34 | stores.router.push('/'); | ||
35 | stores.user.hasCompletedSignup = true; | ||
36 | } | ||
37 | } | ||
38 | } | ||
39 | |||
40 | render() { | ||
41 | const { | ||
42 | error, | ||
43 | stores, | ||
44 | } = this.props; | ||
45 | |||
46 | const { getUserInfoRequest, activateTrialRequest, data } = stores.user; | ||
47 | const { featuresRequest, features } = stores.features; | ||
48 | |||
49 | const { pricingConfig } = features; | ||
50 | |||
51 | let currency = '$'; | ||
52 | let price = 5.99; | ||
53 | if (pricingConfig) { | ||
54 | ({ currency } = pricingConfig); | ||
55 | ({ price } = pricingConfig.plans.pro.yearly); | ||
56 | } | ||
57 | |||
58 | return ( | ||
59 | <Pricing | ||
60 | onSubmit={this.submit.bind(this)} | ||
61 | isLoadingRequiredData={(getUserInfoRequest.isExecuting || !getUserInfoRequest.wasExecuted) || (featuresRequest.isExecuting || !featuresRequest.wasExecuted)} | ||
62 | isActivatingTrial={activateTrialRequest.isExecuting} | ||
63 | trialActivationError={activateTrialRequest.isError} | ||
64 | canSkipTrial={features.canSkipTrial} | ||
65 | error={error} | ||
66 | currency={currency} | ||
67 | price={price} | ||
68 | name={data.firstname} | ||
69 | /> | ||
70 | ); | ||
71 | } | ||
72 | } | ||
73 | |||
74 | PricingScreen.wrappedComponent.propTypes = { | ||
75 | actions: PropTypes.shape({ | ||
76 | user: PropTypes.instanceOf(UserStore).isRequired, | ||
77 | }).isRequired, | ||
78 | stores: PropTypes.shape({ | ||
79 | user: PropTypes.instanceOf(UserStore).isRequired, | ||
80 | router: PropTypes.instanceOf(RouterStore).isRequired, | ||
81 | features: PropTypes.instanceOf(FeaturesStore).isRequired, | ||
82 | }).isRequired, | ||
83 | }; | ||
diff --git a/src/containers/auth/SetupAssistantScreen.js b/src/containers/auth/SetupAssistantScreen.js index 2a8f2c010..eaf3fda8a 100644 --- a/src/containers/auth/SetupAssistantScreen.js +++ b/src/containers/auth/SetupAssistantScreen.js | |||
@@ -12,6 +12,7 @@ import RecipesStore from '../../stores/RecipesStore'; | |||
12 | import UserStore from '../../stores/UserStore'; | 12 | import UserStore from '../../stores/UserStore'; |
13 | 13 | ||
14 | export default @inject('stores', 'actions') @observer class SetupAssistantScreen extends Component { | 14 | export default @inject('stores', 'actions') @observer class SetupAssistantScreen extends Component { |
15 | // TODO: Why are these hardcoded here? Do they need to conform to specific services in the packaged recipes? If so, its more important to fix this | ||
15 | services = { | 16 | services = { |
16 | whatsapp: { | 17 | whatsapp: { |
17 | name: 'WhatsApp', | 18 | name: 'WhatsApp', |
@@ -56,14 +57,14 @@ export default @inject('stores', 'actions') @observer class SetupAssistantScreen | |||
56 | } | 57 | } |
57 | 58 | ||
58 | async setupServices(serviceConfig) { | 59 | async setupServices(serviceConfig) { |
59 | const { stores: { services, router, user } } = this.props; | 60 | const { stores: { services } } = this.props; |
60 | console.log(serviceConfig); | 61 | console.log(serviceConfig); |
61 | 62 | ||
62 | this.setState({ | 63 | this.setState({ |
63 | isSettingUpServices: true, | 64 | isSettingUpServices: true, |
64 | }); | 65 | }); |
65 | 66 | ||
66 | // The store requests are not build for paralell requests so we need to finish one request after another | 67 | // The store requests are not build for parallel requests so we need to finish one request after another |
67 | for (const config of serviceConfig) { | 68 | for (const config of serviceConfig) { |
68 | const serviceData = { | 69 | const serviceData = { |
69 | name: this.services[config.id].name, | 70 | name: this.services[config.id].name, |
@@ -96,10 +97,6 @@ export default @inject('stores', 'actions') @observer class SetupAssistantScreen | |||
96 | this.setState({ | 97 | this.setState({ |
97 | isSettingUpServices: false, | 98 | isSettingUpServices: false, |
98 | }); | 99 | }); |
99 | |||
100 | await sleep(100); | ||
101 | |||
102 | router.push(user.pricingRoute); | ||
103 | } | 100 | } |
104 | 101 | ||
105 | render() { | 102 | render() { |
diff --git a/src/containers/auth/SignupScreen.js b/src/containers/auth/SignupScreen.js index 42ee09f33..eeab63a0c 100644 --- a/src/containers/auth/SignupScreen.js +++ b/src/containers/auth/SignupScreen.js | |||
@@ -14,16 +14,7 @@ export default @inject('stores', 'actions') @observer class SignupScreen extends | |||
14 | }; | 14 | }; |
15 | 15 | ||
16 | onSignup(values) { | 16 | onSignup(values) { |
17 | const { actions, stores } = this.props; | 17 | const { actions } = this.props; |
18 | |||
19 | const { canSkipTrial, defaultTrialPlan, pricingConfig } = stores.features.anonymousFeatures; | ||
20 | |||
21 | if (!canSkipTrial) { | ||
22 | Object.assign(values, { | ||
23 | plan: defaultTrialPlan, | ||
24 | currency: pricingConfig.currencyID, | ||
25 | }); | ||
26 | } | ||
27 | 18 | ||
28 | actions.user.signup(values); | 19 | actions.user.signup(values); |
29 | } | 20 | } |