diff options
author | 2021-02-08 10:34:45 +0100 | |
---|---|---|
committer | 2021-02-08 10:34:45 +0100 | |
commit | 035002ceedf78d5ec73eabc0df7f06139939b967 (patch) | |
tree | 1c0d1e9531bae05fb65d70b9ea25baf404b74fe1 /src/containers/auth | |
parent | docs: add k0staa as a contributor (#1193) (diff) | |
download | ferdium-app-035002ceedf78d5ec73eabc0df7f06139939b967.tar.gz ferdium-app-035002ceedf78d5ec73eabc0df7f06139939b967.tar.zst ferdium-app-035002ceedf78d5ec73eabc0df7f06139939b967.zip |
Synchronize with Franz 5.6.0 (#1033)
Co-authored-by: FranzBot <i18n@meetfranz.com>
Co-authored-by: vantezzen <hello@vantezzen.io>
Co-authored-by: Makazzz <makazzzpro@live.ca>
Co-authored-by: Stefan Malzner <stefan@adlk.io>
Co-authored-by: Amine Mouafik <amine@mouafik.fr>
Diffstat (limited to 'src/containers/auth')
-rw-r--r-- | src/containers/auth/SetupAssistantScreen.js | 133 |
1 files changed, 133 insertions, 0 deletions
diff --git a/src/containers/auth/SetupAssistantScreen.js b/src/containers/auth/SetupAssistantScreen.js new file mode 100644 index 000000000..960ed7e33 --- /dev/null +++ b/src/containers/auth/SetupAssistantScreen.js | |||
@@ -0,0 +1,133 @@ | |||
1 | /* eslint-disable no-await-in-loop */ | ||
2 | import React, { Component } from 'react'; | ||
3 | import PropTypes from 'prop-types'; | ||
4 | import { inject, observer } from 'mobx-react'; | ||
5 | |||
6 | import { sleep } from '../../helpers/async-helpers'; | ||
7 | import SetupAssistant from '../../components/auth/SetupAssistant'; | ||
8 | import ServicesStore from '../../stores/ServicesStore'; | ||
9 | import RecipesStore from '../../stores/RecipesStore'; | ||
10 | import { TODOS_RECIPE_ID } from '../../features/todos'; | ||
11 | import UserStore from '../../stores/UserStore'; | ||
12 | |||
13 | export default @inject('stores', 'actions') @observer class SetupAssistantScreen extends Component { | ||
14 | services = { | ||
15 | whatsapp: { | ||
16 | name: 'WhatsApp', | ||
17 | hasTeamId: false, | ||
18 | }, | ||
19 | messenger: { | ||
20 | name: 'Messenger', | ||
21 | hasTeamId: false, | ||
22 | }, | ||
23 | gmail: { | ||
24 | name: 'Gmail', | ||
25 | hasTeamId: false, | ||
26 | }, | ||
27 | skype: { | ||
28 | name: 'Skype', | ||
29 | hasTeamId: false, | ||
30 | }, | ||
31 | telegram: { | ||
32 | name: 'Telegram', | ||
33 | hasTeamId: false, | ||
34 | }, | ||
35 | instagram: { | ||
36 | name: 'Instagram', | ||
37 | hasTeamId: false, | ||
38 | }, | ||
39 | slack: { | ||
40 | name: 'Slack', | ||
41 | hasTeamId: true, | ||
42 | }, | ||
43 | hangouts: { | ||
44 | name: 'Hangouts', | ||
45 | hasTeamId: false, | ||
46 | }, | ||
47 | linkedin: { | ||
48 | name: 'LinkedIn', | ||
49 | hasTeamId: false, | ||
50 | }, | ||
51 | } | ||
52 | |||
53 | state = { | ||
54 | isSettingUpServices: false, | ||
55 | } | ||
56 | |||
57 | async setupServices(serviceConfig) { | ||
58 | const { stores: { services, router, user } } = this.props; | ||
59 | console.log(serviceConfig); | ||
60 | |||
61 | this.setState({ | ||
62 | isSettingUpServices: true, | ||
63 | }); | ||
64 | |||
65 | // The store requests are not build for paralell requests so we need to finish one request after another | ||
66 | for (const config of serviceConfig) { | ||
67 | const serviceData = { | ||
68 | name: this.services[config.id].name, | ||
69 | }; | ||
70 | |||
71 | if (config.team) { | ||
72 | serviceData.team = config.team; | ||
73 | } | ||
74 | |||
75 | await services._createService({ | ||
76 | recipeId: config.id, | ||
77 | serviceData, | ||
78 | redirect: false, | ||
79 | skipCleanup: true, | ||
80 | }); | ||
81 | |||
82 | await sleep(100); | ||
83 | } | ||
84 | |||
85 | // Add Franz ToDos | ||
86 | await services._createService({ | ||
87 | recipeId: TODOS_RECIPE_ID, | ||
88 | serviceData: { | ||
89 | name: 'Franz ToDos', | ||
90 | }, | ||
91 | redirect: false, | ||
92 | skipCleanup: true, | ||
93 | }); | ||
94 | |||
95 | this.setState({ | ||
96 | isSettingUpServices: false, | ||
97 | }); | ||
98 | |||
99 | await sleep(100); | ||
100 | |||
101 | router.push(user.pricingRoute); | ||
102 | } | ||
103 | |||
104 | render() { | ||
105 | return ( | ||
106 | <SetupAssistant | ||
107 | onSubmit={config => this.setupServices(config)} | ||
108 | services={this.services} | ||
109 | embed={false} | ||
110 | isSettingUpServices={this.state.isSettingUpServices} | ||
111 | /> | ||
112 | ); | ||
113 | } | ||
114 | } | ||
115 | |||
116 | SetupAssistantScreen.wrappedComponent.propTypes = { | ||
117 | stores: PropTypes.shape({ | ||
118 | services: PropTypes.instanceOf(ServicesStore), | ||
119 | recipes: PropTypes.instanceOf(RecipesStore), | ||
120 | user: PropTypes.instanceOf(UserStore), | ||
121 | }).isRequired, | ||
122 | actions: PropTypes.shape({ | ||
123 | user: PropTypes.shape({ | ||
124 | invite: PropTypes.func.isRequired, | ||
125 | }).isRequired, | ||
126 | service: PropTypes.shape({ | ||
127 | createService: PropTypes.func.isRequired, | ||
128 | }).isRequired, | ||
129 | recipe: PropTypes.shape({ | ||
130 | install: PropTypes.func.isRequired, | ||
131 | }).isRequired, | ||
132 | }).isRequired, | ||
133 | }; | ||