aboutsummaryrefslogtreecommitdiffstats
path: root/src/containers/auth
diff options
context:
space:
mode:
authorLibravatar Stefan Malzner <stefan@adlk.io>2019-10-17 14:12:36 +0200
committerLibravatar Stefan Malzner <stefan@adlk.io>2019-10-17 14:12:36 +0200
commitb6276bd0cb88ce681bc35a6fc7b1ae0cf6ac56ea (patch)
tree7070d5c2fd4a3d98d63d0c85171d85dba77102c5 /src/containers/auth
parentpolishing (diff)
downloadferdium-app-b6276bd0cb88ce681bc35a6fc7b1ae0cf6ac56ea.tar.gz
ferdium-app-b6276bd0cb88ce681bc35a6fc7b1ae0cf6ac56ea.tar.zst
ferdium-app-b6276bd0cb88ce681bc35a6fc7b1ae0cf6ac56ea.zip
optimize trial signup flow
Diffstat (limited to 'src/containers/auth')
-rw-r--r--src/containers/auth/PricingScreen.js17
-rw-r--r--src/containers/auth/SignupScreen.js22
2 files changed, 31 insertions, 8 deletions
diff --git a/src/containers/auth/PricingScreen.js b/src/containers/auth/PricingScreen.js
index ff378bd8b..55811ed23 100644
--- a/src/containers/auth/PricingScreen.js
+++ b/src/containers/auth/PricingScreen.js
@@ -20,14 +20,19 @@ export default @inject('stores', 'actions') @observer class PricingScreen extend
20 } = this.props; 20 } = this.props;
21 21
22 const { activateTrialRequest } = stores.user; 22 const { activateTrialRequest } = stores.user;
23 const { defaultTrialPlan } = stores.features.features; 23 const { defaultTrialPlan, canSkipTrial } = stores.features.anonymousFeatures;
24 24
25 actions.user.activateTrial({ planId: defaultTrialPlan }); 25 if (!canSkipTrial) {
26 await activateTrialRequest._promise;
27
28 if (!activateTrialRequest.isError) {
29 stores.router.push('/'); 26 stores.router.push('/');
30 stores.user.hasCompletedSignup = true; 27 stores.user.hasCompletedSignup = true;
28 } else {
29 actions.user.activateTrial({ planId: defaultTrialPlan });
30 await activateTrialRequest._promise;
31
32 if (!activateTrialRequest.isError) {
33 stores.router.push('/');
34 stores.user.hasCompletedSignup = true;
35 }
31 } 36 }
32 } 37 }
33 38
@@ -43,7 +48,7 @@ export default @inject('stores', 'actions') @observer class PricingScreen extend
43 const { pricingConfig } = features; 48 const { pricingConfig } = features;
44 49
45 let currency = '$'; 50 let currency = '$';
46 let price = '5.99'; 51 let price = 5.99;
47 if (pricingConfig) { 52 if (pricingConfig) {
48 ({ currency } = pricingConfig); 53 ({ currency } = pricingConfig);
49 ({ price } = pricingConfig.plans.pro.yearly); 54 ({ price } = pricingConfig.plans.pro.yearly);
diff --git a/src/containers/auth/SignupScreen.js b/src/containers/auth/SignupScreen.js
index efc7ea4c1..f93498be2 100644
--- a/src/containers/auth/SignupScreen.js
+++ b/src/containers/auth/SignupScreen.js
@@ -4,6 +4,7 @@ import { inject, observer } from 'mobx-react';
4 4
5import Signup from '../../components/auth/Signup'; 5import Signup from '../../components/auth/Signup';
6import UserStore from '../../stores/UserStore'; 6import UserStore from '../../stores/UserStore';
7import FeaturesStore from '../../stores/FeaturesStore';
7 8
8import { globalError as globalErrorPropType } from '../../prop-types'; 9import { globalError as globalErrorPropType } from '../../prop-types';
9 10
@@ -12,11 +13,27 @@ export default @inject('stores', 'actions') @observer class SignupScreen extends
12 error: globalErrorPropType.isRequired, 13 error: globalErrorPropType.isRequired,
13 }; 14 };
14 15
16 onSignup(values) {
17 const { actions, stores } = 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
28 actions.user.signup(values);
29 }
30
15 render() { 31 render() {
16 const { actions, stores, error } = this.props; 32 const { stores, error } = this.props;
33
17 return ( 34 return (
18 <Signup 35 <Signup
19 onSubmit={actions.user.signup} 36 onSubmit={values => this.onSignup(values)}
20 isSubmitting={stores.user.signupRequest.isExecuting} 37 isSubmitting={stores.user.signupRequest.isExecuting}
21 loginRoute={stores.user.loginRoute} 38 loginRoute={stores.user.loginRoute}
22 error={error} 39 error={error}
@@ -33,5 +50,6 @@ SignupScreen.wrappedComponent.propTypes = {
33 }).isRequired, 50 }).isRequired,
34 stores: PropTypes.shape({ 51 stores: PropTypes.shape({
35 user: PropTypes.instanceOf(UserStore).isRequired, 52 user: PropTypes.instanceOf(UserStore).isRequired,
53 features: PropTypes.instanceOf(FeaturesStore).isRequired,
36 }).isRequired, 54 }).isRequired,
37}; 55};