diff options
author | Vijay A <vraravam@users.noreply.github.com> | 2022-05-08 21:00:17 -0500 |
---|---|---|
committer | Vijay Aravamudhan <vraravam@users.noreply.github.com> | 2022-05-08 22:19:29 -0400 |
commit | db25991927e9b74eda2f3a9df5d01908abc04208 (patch) | |
tree | 28b82e6e50512ceecdae4e6d2ddec50f0c7835b5 /src/containers/auth/SetupAssistantScreen.js | |
parent | New Crowdin updates (#119) [skip ci] (diff) | |
download | ferdium-app-db25991927e9b74eda2f3a9df5d01908abc04208.tar.gz ferdium-app-db25991927e9b74eda2f3a9df5d01908abc04208.tar.zst ferdium-app-db25991927e9b74eda2f3a9df5d01908abc04208.zip |
Converted some javascript files to typescript
Diffstat (limited to 'src/containers/auth/SetupAssistantScreen.js')
-rw-r--r-- | src/containers/auth/SetupAssistantScreen.js | 123 |
1 files changed, 0 insertions, 123 deletions
diff --git a/src/containers/auth/SetupAssistantScreen.js b/src/containers/auth/SetupAssistantScreen.js deleted file mode 100644 index 42c3d6019..000000000 --- a/src/containers/auth/SetupAssistantScreen.js +++ /dev/null | |||
@@ -1,123 +0,0 @@ | |||
1 | /* eslint-disable no-await-in-loop */ | ||
2 | import { Component } from 'react'; | ||
3 | import PropTypes from 'prop-types'; | ||
4 | import { inject, observer } from 'mobx-react'; | ||
5 | |||
6 | import { RouterStore } from 'mobx-react-router'; | ||
7 | import { sleep } from '../../helpers/async-helpers'; | ||
8 | import SetupAssistant from '../../components/auth/SetupAssistant'; | ||
9 | import ServicesStore from '../../stores/ServicesStore'; | ||
10 | import RecipesStore from '../../stores/RecipesStore'; | ||
11 | import UserStore from '../../stores/UserStore'; | ||
12 | |||
13 | class SetupAssistantScreen extends Component { | ||
14 | constructor(props) { | ||
15 | super(props); | ||
16 | this.state = { | ||
17 | isSettingUpServices: false, | ||
18 | }; | ||
19 | } | ||
20 | |||
21 | // 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 | ||
22 | services = { | ||
23 | whatsapp: { | ||
24 | name: 'WhatsApp', | ||
25 | hasTeamId: false, | ||
26 | }, | ||
27 | messenger: { | ||
28 | name: 'Messenger', | ||
29 | hasTeamId: false, | ||
30 | }, | ||
31 | gmail: { | ||
32 | name: 'Gmail', | ||
33 | hasTeamId: false, | ||
34 | }, | ||
35 | skype: { | ||
36 | name: 'Skype', | ||
37 | hasTeamId: false, | ||
38 | }, | ||
39 | telegram: { | ||
40 | name: 'Telegram', | ||
41 | hasTeamId: false, | ||
42 | }, | ||
43 | instagram: { | ||
44 | name: 'Instagram', | ||
45 | hasTeamId: false, | ||
46 | }, | ||
47 | slack: { | ||
48 | name: 'Slack', | ||
49 | hasTeamId: true, | ||
50 | }, | ||
51 | hangouts: { | ||
52 | name: 'Hangouts', | ||
53 | hasTeamId: false, | ||
54 | }, | ||
55 | linkedin: { | ||
56 | name: 'LinkedIn', | ||
57 | hasTeamId: false, | ||
58 | }, | ||
59 | }; | ||
60 | |||
61 | async setupServices(serviceConfig) { | ||
62 | const { stores: { services, router } } = this.props; | ||
63 | |||
64 | this.setState({ | ||
65 | isSettingUpServices: true, | ||
66 | }); | ||
67 | |||
68 | // The store requests are not build for parallel requests so we need to finish one request after another | ||
69 | for (const config of serviceConfig) { | ||
70 | const serviceData = { | ||
71 | name: this.services[config.id].name, | ||
72 | }; | ||
73 | |||
74 | if (config.team) { | ||
75 | serviceData.team = config.team; | ||
76 | } | ||
77 | |||
78 | await services._createService({ | ||
79 | recipeId: config.id, | ||
80 | serviceData, | ||
81 | redirect: false, | ||
82 | skipCleanup: true, | ||
83 | }); | ||
84 | |||
85 | await sleep(100); | ||
86 | } | ||
87 | |||
88 | this.setState({ | ||
89 | isSettingUpServices: false, | ||
90 | }); | ||
91 | |||
92 | await sleep(100); | ||
93 | |||
94 | router.push("/"); | ||
95 | } | ||
96 | |||
97 | render() { | ||
98 | return ( | ||
99 | <SetupAssistant | ||
100 | onSubmit={config => this.setupServices(config)} | ||
101 | services={this.services} | ||
102 | embed={false} | ||
103 | isSettingUpServices={this.state.isSettingUpServices} | ||
104 | /> | ||
105 | ); | ||
106 | } | ||
107 | } | ||
108 | |||
109 | SetupAssistantScreen.propTypes = { | ||
110 | stores: PropTypes.shape({ | ||
111 | services: PropTypes.instanceOf(ServicesStore), | ||
112 | router: PropTypes.instanceOf(RouterStore).isRequired, | ||
113 | recipes: PropTypes.instanceOf(RecipesStore), | ||
114 | user: PropTypes.instanceOf(UserStore), | ||
115 | }).isRequired, | ||
116 | actions: PropTypes.shape({ | ||
117 | user: PropTypes.instanceOf(UserStore).isRequired, | ||
118 | service: PropTypes.instanceOf(ServicesStore).isRequired, | ||
119 | recipe: PropTypes.instanceOf(RecipesStore).isRequired, | ||
120 | }).isRequired, | ||
121 | }; | ||
122 | |||
123 | export default inject('stores', 'actions')(observer(SetupAssistantScreen)); | ||