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 | 35 | ||||
-rw-r--r-- | src/containers/auth/SignupScreen.js | 13 | ||||
-rw-r--r-- | src/containers/auth/WelcomeScreen.js | 2 |
4 files changed, 24 insertions, 109 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..d7036969a 100644 --- a/src/containers/auth/SetupAssistantScreen.js +++ b/src/containers/auth/SetupAssistantScreen.js | |||
@@ -4,14 +4,28 @@ import PropTypes from 'prop-types'; | |||
4 | import { inject, observer } from 'mobx-react'; | 4 | import { inject, observer } from 'mobx-react'; |
5 | 5 | ||
6 | import { RouterStore } from 'mobx-react-router'; | 6 | import { RouterStore } from 'mobx-react-router'; |
7 | import { DEFAULT_TODO_RECIPE_ID, DEFAULT_TODO_SERVICE_NAME } from '../../config'; | 7 | import { |
8 | DEFAULT_TODO_RECIPE_ID, | ||
9 | DEFAULT_TODO_SERVICE_NAME, | ||
10 | } from '../../config'; | ||
8 | import { sleep } from '../../helpers/async-helpers'; | 11 | import { sleep } from '../../helpers/async-helpers'; |
9 | import SetupAssistant from '../../components/auth/SetupAssistant'; | 12 | import SetupAssistant from '../../components/auth/SetupAssistant'; |
10 | import ServicesStore from '../../stores/ServicesStore'; | 13 | import ServicesStore from '../../stores/ServicesStore'; |
11 | import RecipesStore from '../../stores/RecipesStore'; | 14 | import RecipesStore from '../../stores/RecipesStore'; |
12 | import UserStore from '../../stores/UserStore'; | 15 | import UserStore from '../../stores/UserStore'; |
13 | 16 | ||
14 | export default @inject('stores', 'actions') @observer class SetupAssistantScreen extends Component { | 17 | export default |
18 | @inject('stores', 'actions') | ||
19 | @observer | ||
20 | class SetupAssistantScreen extends Component { | ||
21 | constructor(props) { | ||
22 | super(props); | ||
23 | this.state = { | ||
24 | isSettingUpServices: false, | ||
25 | }; | ||
26 | } | ||
27 | |||
28 | // 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 = { | 29 | services = { |
16 | whatsapp: { | 30 | whatsapp: { |
17 | name: 'WhatsApp', | 31 | name: 'WhatsApp', |
@@ -49,21 +63,18 @@ export default @inject('stores', 'actions') @observer class SetupAssistantScreen | |||
49 | name: 'LinkedIn', | 63 | name: 'LinkedIn', |
50 | hasTeamId: false, | 64 | hasTeamId: false, |
51 | }, | 65 | }, |
52 | } | 66 | }; |
53 | |||
54 | state = { | ||
55 | isSettingUpServices: false, | ||
56 | } | ||
57 | 67 | ||
58 | async setupServices(serviceConfig) { | 68 | async setupServices(serviceConfig) { |
59 | const { stores: { services, router, user } } = this.props; | 69 | const { |
60 | console.log(serviceConfig); | 70 | stores: { services }, |
71 | } = this.props; | ||
61 | 72 | ||
62 | this.setState({ | 73 | this.setState({ |
63 | isSettingUpServices: true, | 74 | isSettingUpServices: true, |
64 | }); | 75 | }); |
65 | 76 | ||
66 | // The store requests are not build for paralell requests so we need to finish one request after another | 77 | // The store requests are not build for parallel requests so we need to finish one request after another |
67 | for (const config of serviceConfig) { | 78 | for (const config of serviceConfig) { |
68 | const serviceData = { | 79 | const serviceData = { |
69 | name: this.services[config.id].name, | 80 | name: this.services[config.id].name, |
@@ -96,10 +107,6 @@ export default @inject('stores', 'actions') @observer class SetupAssistantScreen | |||
96 | this.setState({ | 107 | this.setState({ |
97 | isSettingUpServices: false, | 108 | isSettingUpServices: false, |
98 | }); | 109 | }); |
99 | |||
100 | await sleep(100); | ||
101 | |||
102 | router.push(user.pricingRoute); | ||
103 | } | 110 | } |
104 | 111 | ||
105 | render() { | 112 | render() { |
diff --git a/src/containers/auth/SignupScreen.js b/src/containers/auth/SignupScreen.js index 42ee09f33..38c5dfb43 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 | } |
@@ -33,7 +24,7 @@ export default @inject('stores', 'actions') @observer class SignupScreen extends | |||
33 | 24 | ||
34 | return ( | 25 | return ( |
35 | <Signup | 26 | <Signup |
36 | onSubmit={values => this.onSignup(values)} | 27 | onSubmit={(values) => this.onSignup(values)} |
37 | isSubmitting={stores.user.signupRequest.isExecuting} | 28 | isSubmitting={stores.user.signupRequest.isExecuting} |
38 | loginRoute={stores.user.loginRoute} | 29 | loginRoute={stores.user.loginRoute} |
39 | changeServerRoute={stores.user.changeServerRoute} | 30 | changeServerRoute={stores.user.changeServerRoute} |
diff --git a/src/containers/auth/WelcomeScreen.js b/src/containers/auth/WelcomeScreen.js index 6f2d0eee6..bfcc880d0 100644 --- a/src/containers/auth/WelcomeScreen.js +++ b/src/containers/auth/WelcomeScreen.js | |||
@@ -15,7 +15,7 @@ export default @inject('stores', 'actions') @observer class LoginScreen extends | |||
15 | loginRoute={user.loginRoute} | 15 | loginRoute={user.loginRoute} |
16 | signupRoute={user.signupRoute} | 16 | signupRoute={user.signupRoute} |
17 | changeServerRoute={user.changeServerRoute} | 17 | changeServerRoute={user.changeServerRoute} |
18 | recipes={recipePreviews.featured} | 18 | recipes={recipePreviews.all} |
19 | /> | 19 | /> |
20 | ); | 20 | ); |
21 | } | 21 | } |