diff options
author | 2022-11-16 23:30:39 +0530 | |
---|---|---|
committer | 2022-11-16 18:00:39 +0000 | |
commit | eb7b2481f631cec5953265eef4ebc3f2fa7e496a (patch) | |
tree | 419d4413f90ece77c0a2204b40948f1a158793d5 /src/containers/auth | |
parent | 6.2.1-nightly.44 [skip ci] (diff) | |
download | ferdium-app-eb7b2481f631cec5953265eef4ebc3f2fa7e496a.tar.gz ferdium-app-eb7b2481f631cec5953265eef4ebc3f2fa7e496a.tar.zst ferdium-app-eb7b2481f631cec5953265eef4ebc3f2fa7e496a.zip |
Transform JSX components to TSX (#755)
* color picker types
* Import
* SetupAssistant
* Services & appear
* ServiceWebView
* SettingsLayout
* ImportantScreen
* WorkspaceDrawer
* SetupAssistant
* chore: update vscode settings
* chore: removed stale Import screen component & its tree
Diffstat (limited to 'src/containers/auth')
-rw-r--r-- | src/containers/auth/ImportScreen.tsx | 25 | ||||
-rw-r--r-- | src/containers/auth/SetupAssistantScreen.tsx | 133 |
2 files changed, 69 insertions, 89 deletions
diff --git a/src/containers/auth/ImportScreen.tsx b/src/containers/auth/ImportScreen.tsx deleted file mode 100644 index 91e985ad5..000000000 --- a/src/containers/auth/ImportScreen.tsx +++ /dev/null | |||
@@ -1,25 +0,0 @@ | |||
1 | import { Component, ReactElement } from 'react'; | ||
2 | import { inject, observer } from 'mobx-react'; | ||
3 | import { StoresProps } from '../../@types/ferdium-components.types'; | ||
4 | import Import from '../../components/auth/Import'; | ||
5 | |||
6 | class ImportScreen extends Component<StoresProps> { | ||
7 | render(): ReactElement { | ||
8 | const { actions, stores } = this.props; | ||
9 | |||
10 | if (stores.user.isImportLegacyServicesCompleted) { | ||
11 | stores.router.push(stores.user.inviteRoute); | ||
12 | } | ||
13 | |||
14 | return ( | ||
15 | <Import | ||
16 | services={stores.user.legacyServices} | ||
17 | onSubmit={actions.user.importLegacyServices} | ||
18 | isSubmitting={stores.user.isImportLegacyServicesExecuting} | ||
19 | inviteRoute={stores.user.inviteRoute} | ||
20 | /> | ||
21 | ); | ||
22 | } | ||
23 | } | ||
24 | |||
25 | export default inject('stores', 'actions')(observer(ImportScreen)); | ||
diff --git a/src/containers/auth/SetupAssistantScreen.tsx b/src/containers/auth/SetupAssistantScreen.tsx index 661d688aa..0d4c3feec 100644 --- a/src/containers/auth/SetupAssistantScreen.tsx +++ b/src/containers/auth/SetupAssistantScreen.tsx | |||
@@ -1,88 +1,93 @@ | |||
1 | /* eslint-disable no-await-in-loop */ | ||
2 | import { Component, ReactElement } from 'react'; | 1 | import { Component, ReactElement } from 'react'; |
3 | import { inject, observer } from 'mobx-react'; | 2 | import { inject, observer } from 'mobx-react'; |
4 | |||
5 | import { StoresProps } from '../../@types/ferdium-components.types'; | 3 | import { StoresProps } from '../../@types/ferdium-components.types'; |
6 | import sleep from '../../helpers/async-helpers'; | 4 | import sleep from '../../helpers/async-helpers'; |
7 | import SetupAssistant from '../../components/auth/SetupAssistant'; | 5 | import SetupAssistant from '../../components/auth/SetupAssistant'; |
6 | import { ILegacyServices } from '../../@types/legacy-types'; | ||
7 | |||
8 | interface IProps extends StoresProps {} | ||
9 | |||
10 | interface IState { | ||
11 | isSettingUpServices: boolean; | ||
12 | } | ||
13 | |||
14 | @inject('stores', 'actions') | ||
15 | @observer | ||
16 | class SetupAssistantScreen extends Component<IProps, IState> { | ||
17 | services: ILegacyServices; | ||
18 | |||
19 | constructor(props: IProps) { | ||
20 | super(props); | ||
8 | 21 | ||
9 | class SetupAssistantScreen extends Component<StoresProps> { | 22 | this.state = { |
10 | state = { | 23 | isSettingUpServices: false, |
11 | isSettingUpServices: false, | 24 | }; |
12 | }; | ||
13 | 25 | ||
14 | // 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 | 26 | // 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 = { | 27 | this.services = { |
16 | whatsapp: { | 28 | whatsapp: { |
17 | name: 'WhatsApp', | 29 | name: 'WhatsApp', |
18 | hasTeamId: false, | 30 | hasTeamId: false, |
19 | }, | 31 | }, |
20 | messenger: { | 32 | messenger: { |
21 | name: 'Messenger', | 33 | name: 'Messenger', |
22 | hasTeamId: false, | 34 | hasTeamId: false, |
23 | }, | 35 | }, |
24 | gmail: { | 36 | gmail: { |
25 | name: 'Gmail', | 37 | name: 'Gmail', |
26 | hasTeamId: false, | 38 | hasTeamId: false, |
27 | }, | 39 | }, |
28 | skype: { | 40 | skype: { |
29 | name: 'Skype', | 41 | name: 'Skype', |
30 | hasTeamId: false, | 42 | hasTeamId: false, |
31 | }, | 43 | }, |
32 | telegram: { | 44 | telegram: { |
33 | name: 'Telegram', | 45 | name: 'Telegram', |
34 | hasTeamId: false, | 46 | hasTeamId: false, |
35 | }, | 47 | }, |
36 | instagram: { | 48 | instagram: { |
37 | name: 'Instagram', | 49 | name: 'Instagram', |
38 | hasTeamId: false, | 50 | hasTeamId: false, |
39 | }, | 51 | }, |
40 | slack: { | 52 | slack: { |
41 | name: 'Slack', | 53 | name: 'Slack', |
42 | hasTeamId: true, | 54 | hasTeamId: true, |
43 | }, | 55 | }, |
44 | hangouts: { | 56 | hangouts: { |
45 | name: 'Hangouts', | 57 | name: 'Hangouts', |
46 | hasTeamId: false, | 58 | hasTeamId: false, |
47 | }, | 59 | }, |
48 | linkedin: { | 60 | linkedin: { |
49 | name: 'LinkedIn', | 61 | name: 'LinkedIn', |
50 | hasTeamId: false, | 62 | hasTeamId: false, |
51 | }, | 63 | }, |
52 | }; | 64 | }; |
65 | } | ||
53 | 66 | ||
54 | async setupServices(serviceConfig: any): Promise<void> { | 67 | async setupServices(serviceConfig: any): Promise<void> { |
55 | const { | 68 | const { services, router } = this.props.stores; |
56 | stores: { services, router }, | ||
57 | } = this.props; | ||
58 | 69 | ||
59 | this.setState({ | 70 | this.setState({ isSettingUpServices: true }); |
60 | isSettingUpServices: true, | ||
61 | }); | ||
62 | 71 | ||
63 | // The store requests are not build for parallel requests so we need to finish one request after another | 72 | // The store requests are not build for parallel requests so we need to finish one request after another |
64 | for (const config of serviceConfig) { | 73 | for (const config of serviceConfig) { |
65 | const serviceData = { | 74 | // eslint-disable-next-line no-await-in-loop |
66 | name: this.services[config.id].name, | ||
67 | team: config.team, | ||
68 | }; | ||
69 | |||
70 | await services._createService({ | 75 | await services._createService({ |
71 | recipeId: config.id, | 76 | recipeId: config.id, |
72 | serviceData, | 77 | serviceData: { |
78 | name: this.services[config.id].name, | ||
79 | team: config.team, | ||
80 | }, | ||
73 | redirect: false, | 81 | redirect: false, |
74 | skipCleanup: true, | 82 | skipCleanup: true, |
75 | }); | 83 | }); |
76 | 84 | ||
85 | // eslint-disable-next-line no-await-in-loop | ||
77 | await sleep(100); | 86 | await sleep(100); |
78 | } | 87 | } |
79 | 88 | ||
80 | this.setState({ | 89 | this.setState({ isSettingUpServices: false }); |
81 | isSettingUpServices: false, | ||
82 | }); | ||
83 | |||
84 | await sleep(100); | 90 | await sleep(100); |
85 | |||
86 | router.push('/'); | 91 | router.push('/'); |
87 | } | 92 | } |
88 | 93 | ||
@@ -91,11 +96,11 @@ class SetupAssistantScreen extends Component<StoresProps> { | |||
91 | <SetupAssistant | 96 | <SetupAssistant |
92 | onSubmit={config => this.setupServices(config)} | 97 | onSubmit={config => this.setupServices(config)} |
93 | services={this.services} | 98 | services={this.services} |
94 | embed={false} | 99 | // embed={false} // TODO - [TS DEBT][PROP NOT USED IN COMPONENT] check legacy services type |
95 | isSettingUpServices={this.state.isSettingUpServices} | 100 | isSettingUpServices={this.state.isSettingUpServices} |
96 | /> | 101 | /> |
97 | ); | 102 | ); |
98 | } | 103 | } |
99 | } | 104 | } |
100 | 105 | ||
101 | export default inject('stores', 'actions')(observer(SetupAssistantScreen)); | 106 | export default SetupAssistantScreen; |