diff options
author | 2017-10-13 12:29:40 +0200 | |
---|---|---|
committer | 2017-10-13 12:29:40 +0200 | |
commit | 58cda9cc7fb79ca9df6746de7f9662bc08dc156a (patch) | |
tree | 1211600c2a5d3b5f81c435c6896618111a611720 /src/containers/auth | |
download | ferdium-app-58cda9cc7fb79ca9df6746de7f9662bc08dc156a.tar.gz ferdium-app-58cda9cc7fb79ca9df6746de7f9662bc08dc156a.tar.zst ferdium-app-58cda9cc7fb79ca9df6746de7f9662bc08dc156a.zip |
initial commit
Diffstat (limited to 'src/containers/auth')
-rw-r--r-- | src/containers/auth/AuthLayoutContainer.js | 47 | ||||
-rw-r--r-- | src/containers/auth/ImportScreen.js | 41 | ||||
-rw-r--r-- | src/containers/auth/InviteScreen.js | 29 | ||||
-rw-r--r-- | src/containers/auth/LoginScreen.js | 45 | ||||
-rw-r--r-- | src/containers/auth/PasswordScreen.js | 38 | ||||
-rw-r--r-- | src/containers/auth/PricingScreen.js | 53 | ||||
-rw-r--r-- | src/containers/auth/SignupScreen.js | 43 | ||||
-rw-r--r-- | src/containers/auth/WelcomeScreen.js | 34 |
8 files changed, 330 insertions, 0 deletions
diff --git a/src/containers/auth/AuthLayoutContainer.js b/src/containers/auth/AuthLayoutContainer.js new file mode 100644 index 000000000..004054fdd --- /dev/null +++ b/src/containers/auth/AuthLayoutContainer.js | |||
@@ -0,0 +1,47 @@ | |||
1 | import React, { Component } from 'react'; | ||
2 | import PropTypes from 'prop-types'; | ||
3 | import { inject, observer } from 'mobx-react'; | ||
4 | |||
5 | import AuthLayout from '../../components/auth/AuthLayout'; | ||
6 | import AppStore from '../../stores/AppStore'; | ||
7 | import GlobalErrorStore from '../../stores/GlobalErrorStore'; | ||
8 | |||
9 | import { oneOrManyChildElements } from '../../prop-types'; | ||
10 | |||
11 | @inject('stores', 'actions') @observer | ||
12 | export default class AuthLayoutContainer extends Component { | ||
13 | static propTypes = { | ||
14 | children: oneOrManyChildElements.isRequired, | ||
15 | location: PropTypes.shape({ | ||
16 | pathname: PropTypes.string.isRequired, | ||
17 | }).isRequired, | ||
18 | }; | ||
19 | |||
20 | render() { | ||
21 | const { stores, actions, children, location } = this.props; | ||
22 | return ( | ||
23 | <AuthLayout | ||
24 | error={stores.globalError.response} | ||
25 | pathname={location.pathname} | ||
26 | isOnline={stores.app.isOnline} | ||
27 | isAPIHealthy={!stores.app.healthCheckRequest.isError} | ||
28 | retryHealthCheck={actions.app.healthCheck} | ||
29 | isHealthCheckLoading={stores.app.healthCheckRequest.isExecuting} | ||
30 | > | ||
31 | {children} | ||
32 | </AuthLayout> | ||
33 | ); | ||
34 | } | ||
35 | } | ||
36 | |||
37 | AuthLayoutContainer.wrappedComponent.propTypes = { | ||
38 | stores: PropTypes.shape({ | ||
39 | app: PropTypes.instanceOf(AppStore).isRequired, | ||
40 | globalError: PropTypes.instanceOf(GlobalErrorStore).isRequired, | ||
41 | }).isRequired, | ||
42 | actions: PropTypes.shape({ | ||
43 | app: PropTypes.shape({ | ||
44 | healthCheck: PropTypes.func.isRequired, | ||
45 | }).isRequired, | ||
46 | }).isRequired, | ||
47 | }; | ||
diff --git a/src/containers/auth/ImportScreen.js b/src/containers/auth/ImportScreen.js new file mode 100644 index 000000000..ddd56ffb6 --- /dev/null +++ b/src/containers/auth/ImportScreen.js | |||
@@ -0,0 +1,41 @@ | |||
1 | import React, { Component } from 'react'; | ||
2 | import PropTypes from 'prop-types'; | ||
3 | import { inject, observer } from 'mobx-react'; | ||
4 | import Import from '../../components/auth/Import'; | ||
5 | import UserStore from '../../stores/UserStore'; | ||
6 | import { gaPage } from '../../lib/analytics'; | ||
7 | |||
8 | @inject('stores', 'actions') @observer | ||
9 | export default class ImportScreen extends Component { | ||
10 | componentDidMount() { | ||
11 | gaPage('Auth/Import'); | ||
12 | } | ||
13 | |||
14 | render() { | ||
15 | const { actions, stores } = this.props; | ||
16 | |||
17 | if (stores.user.isImportLegacyServicesCompleted) { | ||
18 | stores.router.push(stores.user.inviteRoute); | ||
19 | } | ||
20 | |||
21 | return ( | ||
22 | <Import | ||
23 | services={stores.user.legacyServices} | ||
24 | onSubmit={actions.user.importLegacyServices} | ||
25 | isSubmitting={stores.user.isImportLegacyServicesExecuting} | ||
26 | inviteRoute={stores.user.inviteRoute} | ||
27 | /> | ||
28 | ); | ||
29 | } | ||
30 | } | ||
31 | |||
32 | ImportScreen.wrappedComponent.propTypes = { | ||
33 | actions: PropTypes.shape({ | ||
34 | user: PropTypes.shape({ | ||
35 | importLegacyServices: PropTypes.func.isRequired, | ||
36 | }).isRequired, | ||
37 | }).isRequired, | ||
38 | stores: PropTypes.shape({ | ||
39 | user: PropTypes.instanceOf(UserStore).isRequired, | ||
40 | }).isRequired, | ||
41 | }; | ||
diff --git a/src/containers/auth/InviteScreen.js b/src/containers/auth/InviteScreen.js new file mode 100644 index 000000000..51971f436 --- /dev/null +++ b/src/containers/auth/InviteScreen.js | |||
@@ -0,0 +1,29 @@ | |||
1 | import React, { Component } from 'react'; | ||
2 | import PropTypes from 'prop-types'; | ||
3 | import { inject, observer } from 'mobx-react'; | ||
4 | import Invite from '../../components/auth/Invite'; | ||
5 | import { gaPage } from '../../lib/analytics'; | ||
6 | |||
7 | @inject('stores', 'actions') @observer | ||
8 | export default class InviteScreen extends Component { | ||
9 | componentDidMount() { | ||
10 | gaPage('Auth/Invite'); | ||
11 | } | ||
12 | |||
13 | render() { | ||
14 | const { actions } = this.props; | ||
15 | return ( | ||
16 | <Invite | ||
17 | onSubmit={actions.user.invite} | ||
18 | /> | ||
19 | ); | ||
20 | } | ||
21 | } | ||
22 | |||
23 | InviteScreen.wrappedComponent.propTypes = { | ||
24 | actions: PropTypes.shape({ | ||
25 | user: PropTypes.shape({ | ||
26 | invite: PropTypes.func.isRequired, | ||
27 | }).isRequired, | ||
28 | }).isRequired, | ||
29 | }; | ||
diff --git a/src/containers/auth/LoginScreen.js b/src/containers/auth/LoginScreen.js new file mode 100644 index 000000000..9e22c5141 --- /dev/null +++ b/src/containers/auth/LoginScreen.js | |||
@@ -0,0 +1,45 @@ | |||
1 | import React, { Component } from 'react'; | ||
2 | import PropTypes from 'prop-types'; | ||
3 | import { inject, observer } from 'mobx-react'; | ||
4 | import Login from '../../components/auth/Login'; | ||
5 | import UserStore from '../../stores/UserStore'; | ||
6 | import { gaPage } from '../../lib/analytics'; | ||
7 | |||
8 | import { globalError as globalErrorPropType } from '../../prop-types'; | ||
9 | |||
10 | @inject('stores', 'actions') @observer | ||
11 | export default class LoginScreen extends Component { | ||
12 | static propTypes = { | ||
13 | error: globalErrorPropType.isRequired, | ||
14 | }; | ||
15 | |||
16 | componentDidMount() { | ||
17 | gaPage('Auth/Login'); | ||
18 | } | ||
19 | |||
20 | render() { | ||
21 | const { actions, stores, error } = this.props; | ||
22 | return ( | ||
23 | <Login | ||
24 | onSubmit={actions.user.login} | ||
25 | isSubmitting={stores.user.loginRequest.isExecuting} | ||
26 | isTokenExpired={stores.user.isTokenExpired} | ||
27 | isServerLogout={stores.user.logoutReason === stores.user.logoutReasonTypes.SERVER} | ||
28 | signupRoute={stores.user.signupRoute} | ||
29 | passwordRoute={stores.user.passwordRoute} | ||
30 | error={error} | ||
31 | /> | ||
32 | ); | ||
33 | } | ||
34 | } | ||
35 | |||
36 | LoginScreen.wrappedComponent.propTypes = { | ||
37 | actions: PropTypes.shape({ | ||
38 | user: PropTypes.shape({ | ||
39 | login: PropTypes.func.isRequired, | ||
40 | }).isRequired, | ||
41 | }).isRequired, | ||
42 | stores: PropTypes.shape({ | ||
43 | user: PropTypes.instanceOf(UserStore).isRequired, | ||
44 | }).isRequired, | ||
45 | }; | ||
diff --git a/src/containers/auth/PasswordScreen.js b/src/containers/auth/PasswordScreen.js new file mode 100644 index 000000000..d88cb08e6 --- /dev/null +++ b/src/containers/auth/PasswordScreen.js | |||
@@ -0,0 +1,38 @@ | |||
1 | import React, { Component } from 'react'; | ||
2 | import PropTypes from 'prop-types'; | ||
3 | import { inject, observer } from 'mobx-react'; | ||
4 | import Password from '../../components/auth/Password'; | ||
5 | import UserStore from '../../stores/UserStore'; | ||
6 | import { gaPage } from '../../lib/analytics'; | ||
7 | |||
8 | @inject('stores', 'actions') @observer | ||
9 | export default class PasswordScreen extends Component { | ||
10 | componentDidMount() { | ||
11 | gaPage('Auth/Password Retrieve'); | ||
12 | } | ||
13 | |||
14 | render() { | ||
15 | const { actions, stores } = this.props; | ||
16 | |||
17 | return ( | ||
18 | <Password | ||
19 | onSubmit={actions.user.retrievePassword} | ||
20 | isSubmitting={stores.user.passwordRequest.isExecuting} | ||
21 | signupRoute={stores.user.signupRoute} | ||
22 | loginRoute={stores.user.loginRoute} | ||
23 | status={stores.user.actionStatus} | ||
24 | /> | ||
25 | ); | ||
26 | } | ||
27 | } | ||
28 | |||
29 | PasswordScreen.wrappedComponent.propTypes = { | ||
30 | actions: PropTypes.shape({ | ||
31 | user: PropTypes.shape({ | ||
32 | retrievePassword: PropTypes.func.isRequired, | ||
33 | }).isRequired, | ||
34 | }).isRequired, | ||
35 | stores: PropTypes.shape({ | ||
36 | user: PropTypes.instanceOf(UserStore).isRequired, | ||
37 | }).isRequired, | ||
38 | }; | ||
diff --git a/src/containers/auth/PricingScreen.js b/src/containers/auth/PricingScreen.js new file mode 100644 index 000000000..7e1586535 --- /dev/null +++ b/src/containers/auth/PricingScreen.js | |||
@@ -0,0 +1,53 @@ | |||
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 | import PaymentStore from '../../stores/PaymentStore'; | ||
9 | import { gaPage } from '../../lib/analytics'; | ||
10 | |||
11 | import { globalError as globalErrorPropType } from '../../prop-types'; | ||
12 | |||
13 | @inject('stores', 'actions') @observer | ||
14 | export default class PricingScreen extends Component { | ||
15 | static propTypes = { | ||
16 | error: globalErrorPropType.isRequired, | ||
17 | }; | ||
18 | |||
19 | componentDidMount() { | ||
20 | gaPage('Auth/Pricing'); | ||
21 | } | ||
22 | |||
23 | render() { | ||
24 | const { actions, stores, error } = this.props; | ||
25 | |||
26 | const nextStepRoute = stores.user.legacyServices.length ? stores.user.importRoute : stores.user.inviteRoute; | ||
27 | |||
28 | return ( | ||
29 | <Pricing | ||
30 | donor={stores.user.data.donor || {}} | ||
31 | onSubmit={actions.user.signup} | ||
32 | onCloseSubscriptionWindow={() => this.props.stores.router.push(nextStepRoute)} | ||
33 | isLoading={stores.payment.plansRequest.isExecuting} | ||
34 | isLoadingUser={stores.user.getUserInfoRequest.isExecuting} | ||
35 | error={error} | ||
36 | skipAction={() => this.props.stores.router.push(nextStepRoute)} | ||
37 | /> | ||
38 | ); | ||
39 | } | ||
40 | } | ||
41 | |||
42 | PricingScreen.wrappedComponent.propTypes = { | ||
43 | actions: PropTypes.shape({ | ||
44 | user: PropTypes.shape({ | ||
45 | signup: PropTypes.func.isRequired, | ||
46 | }).isRequired, | ||
47 | }).isRequired, | ||
48 | stores: PropTypes.shape({ | ||
49 | user: PropTypes.instanceOf(UserStore).isRequired, | ||
50 | payment: PropTypes.instanceOf(PaymentStore).isRequired, | ||
51 | router: PropTypes.instanceOf(RouterStore).isRequired, | ||
52 | }).isRequired, | ||
53 | }; | ||
diff --git a/src/containers/auth/SignupScreen.js b/src/containers/auth/SignupScreen.js new file mode 100644 index 000000000..3b86ab138 --- /dev/null +++ b/src/containers/auth/SignupScreen.js | |||
@@ -0,0 +1,43 @@ | |||
1 | import React, { Component } from 'react'; | ||
2 | import PropTypes from 'prop-types'; | ||
3 | import { inject, observer } from 'mobx-react'; | ||
4 | |||
5 | import Signup from '../../components/auth/Signup'; | ||
6 | import UserStore from '../../stores/UserStore'; | ||
7 | import { gaPage } from '../../lib/analytics'; | ||
8 | |||
9 | import { globalError as globalErrorPropType } from '../../prop-types'; | ||
10 | |||
11 | @inject('stores', 'actions') @observer | ||
12 | export default class SignupScreen extends Component { | ||
13 | static propTypes = { | ||
14 | error: globalErrorPropType.isRequired, | ||
15 | }; | ||
16 | |||
17 | componentDidMount() { | ||
18 | gaPage('Auth/Signup'); | ||
19 | } | ||
20 | |||
21 | render() { | ||
22 | const { actions, stores, error } = this.props; | ||
23 | return ( | ||
24 | <Signup | ||
25 | onSubmit={actions.user.signup} | ||
26 | isSubmitting={stores.user.signupRequest.isExecuting} | ||
27 | loginRoute={stores.user.loginRoute} | ||
28 | error={error} | ||
29 | /> | ||
30 | ); | ||
31 | } | ||
32 | } | ||
33 | |||
34 | SignupScreen.wrappedComponent.propTypes = { | ||
35 | actions: PropTypes.shape({ | ||
36 | user: PropTypes.shape({ | ||
37 | signup: PropTypes.func.isRequired, | ||
38 | }).isRequired, | ||
39 | }).isRequired, | ||
40 | stores: PropTypes.shape({ | ||
41 | user: PropTypes.instanceOf(UserStore).isRequired, | ||
42 | }).isRequired, | ||
43 | }; | ||
diff --git a/src/containers/auth/WelcomeScreen.js b/src/containers/auth/WelcomeScreen.js new file mode 100644 index 000000000..e413264a6 --- /dev/null +++ b/src/containers/auth/WelcomeScreen.js | |||
@@ -0,0 +1,34 @@ | |||
1 | import React, { Component } from 'react'; | ||
2 | import PropTypes from 'prop-types'; | ||
3 | import { inject, observer } from 'mobx-react'; | ||
4 | |||
5 | import Welcome from '../../components/auth/Welcome'; | ||
6 | import UserStore from '../../stores/UserStore'; | ||
7 | import RecipePreviewsStore from '../../stores/RecipePreviewsStore'; | ||
8 | import { gaPage } from '../../lib/analytics'; | ||
9 | |||
10 | @inject('stores', 'actions') @observer | ||
11 | export default class LoginScreen extends Component { | ||
12 | componentDidMount() { | ||
13 | gaPage('Auth/Welcome'); | ||
14 | } | ||
15 | |||
16 | render() { | ||
17 | const { user, recipePreviews } = this.props.stores; | ||
18 | |||
19 | return ( | ||
20 | <Welcome | ||
21 | loginRoute={user.loginRoute} | ||
22 | signupRoute={user.signupRoute} | ||
23 | recipes={recipePreviews.featured} | ||
24 | /> | ||
25 | ); | ||
26 | } | ||
27 | } | ||
28 | |||
29 | LoginScreen.wrappedComponent.propTypes = { | ||
30 | stores: PropTypes.shape({ | ||
31 | user: PropTypes.instanceOf(UserStore).isRequired, | ||
32 | recipePreviews: PropTypes.instanceOf(RecipePreviewsStore).isRequired, | ||
33 | }).isRequired, | ||
34 | }; | ||