diff options
author | 2022-11-01 06:42:12 +0530 | |
---|---|---|
committer | 2022-11-01 01:12:12 +0000 | |
commit | 85d1aac4cd70e79d5ab64684dea09e92b17ed2c2 (patch) | |
tree | a006a2eb5c58b9351219d8a85d57a04c5c73787a /src/containers/auth | |
parent | refactor: convert global app to typescript (#723) (diff) | |
download | ferdium-app-85d1aac4cd70e79d5ab64684dea09e92b17ed2c2.tar.gz ferdium-app-85d1aac4cd70e79d5ab64684dea09e92b17ed2c2.tar.zst ferdium-app-85d1aac4cd70e79d5ab64684dea09e92b17ed2c2.zip |
Transform ChangeServer components tree to typescript (#725)
Diffstat (limited to 'src/containers/auth')
-rw-r--r-- | src/containers/auth/ChangeServerScreen.tsx | 24 | ||||
-rw-r--r-- | src/containers/auth/LoginScreen.tsx | 14 |
2 files changed, 22 insertions, 16 deletions
diff --git a/src/containers/auth/ChangeServerScreen.tsx b/src/containers/auth/ChangeServerScreen.tsx index 29320a001..db48479cc 100644 --- a/src/containers/auth/ChangeServerScreen.tsx +++ b/src/containers/auth/ChangeServerScreen.tsx | |||
@@ -2,8 +2,17 @@ import { Component, ReactElement } from 'react'; | |||
2 | import { inject, observer } from 'mobx-react'; | 2 | import { inject, observer } from 'mobx-react'; |
3 | import { StoresProps } from '../../@types/ferdium-components.types'; | 3 | import { StoresProps } from '../../@types/ferdium-components.types'; |
4 | import ChangeServer from '../../components/auth/ChangeServer'; | 4 | import ChangeServer from '../../components/auth/ChangeServer'; |
5 | import { Actions } from '../../actions/lib/actions'; | ||
6 | import { RealStores } from '../../stores'; | ||
5 | 7 | ||
6 | class ChangeServerScreen extends Component<StoresProps> { | 8 | interface IProps { |
9 | stores?: RealStores; | ||
10 | actions?: Actions; | ||
11 | } | ||
12 | |||
13 | @inject('stores', 'actions') | ||
14 | @observer | ||
15 | class ChangeServerScreen extends Component<IProps> { | ||
7 | constructor(props: StoresProps) { | 16 | constructor(props: StoresProps) { |
8 | super(props); | 17 | super(props); |
9 | 18 | ||
@@ -13,21 +22,18 @@ class ChangeServerScreen extends Component<StoresProps> { | |||
13 | onSubmit(values: any): void { | 22 | onSubmit(values: any): void { |
14 | const { server } = values; | 23 | const { server } = values; |
15 | 24 | ||
16 | this.props.actions.settings.update({ | 25 | this.props.actions!.settings.update({ |
17 | type: 'app', | 26 | type: 'app', |
18 | data: { | 27 | data: { server }, |
19 | server, | ||
20 | }, | ||
21 | }); | 28 | }); |
22 | this.props.stores.router.push('/auth'); | 29 | this.props.stores!.router.push('/auth'); |
23 | } | 30 | } |
24 | 31 | ||
25 | render(): ReactElement { | 32 | render(): ReactElement { |
26 | const { stores } = this.props; | 33 | const { server } = this.props.stores!.settings.all.app; |
27 | const { server } = stores.settings.all.app; | ||
28 | 34 | ||
29 | return <ChangeServer onSubmit={this.onSubmit} server={server} />; | 35 | return <ChangeServer onSubmit={this.onSubmit} server={server} />; |
30 | } | 36 | } |
31 | } | 37 | } |
32 | 38 | ||
33 | export default inject('stores', 'actions')(observer(ChangeServerScreen)); | 39 | export default ChangeServerScreen; |
diff --git a/src/containers/auth/LoginScreen.tsx b/src/containers/auth/LoginScreen.tsx index c4782d287..100736d19 100644 --- a/src/containers/auth/LoginScreen.tsx +++ b/src/containers/auth/LoginScreen.tsx | |||
@@ -6,7 +6,7 @@ import { | |||
6 | } from '../../@types/ferdium-components.types'; | 6 | } from '../../@types/ferdium-components.types'; |
7 | import Login from '../../components/auth/Login'; | 7 | import Login from '../../components/auth/Login'; |
8 | 8 | ||
9 | interface IProps extends Partial<StoresProps> { | 9 | interface IProps extends StoresProps { |
10 | error: GlobalError; | 10 | error: GlobalError; |
11 | } | 11 | } |
12 | 12 | ||
@@ -17,14 +17,14 @@ class LoginScreen extends Component<IProps> { | |||
17 | const { actions, stores, error } = this.props; | 17 | const { actions, stores, error } = this.props; |
18 | return ( | 18 | return ( |
19 | <Login | 19 | <Login |
20 | onSubmit={actions!.user.login} | 20 | onSubmit={actions.user.login} |
21 | isSubmitting={stores!.user.loginRequest.isExecuting} | 21 | isSubmitting={stores.user.loginRequest.isExecuting} |
22 | isTokenExpired={stores!.user.isTokenExpired} | 22 | isTokenExpired={stores.user.isTokenExpired} |
23 | isServerLogout={ | 23 | isServerLogout={ |
24 | stores!.user.logoutReason === stores!.user.logoutReasonTypes.SERVER | 24 | stores.user.logoutReason === stores.user.logoutReasonTypes.SERVER |
25 | } | 25 | } |
26 | signupRoute={stores!.user.signupRoute} | 26 | signupRoute={stores.user.signupRoute} |
27 | passwordRoute={stores!.user.passwordRoute} | 27 | passwordRoute={stores.user.passwordRoute} |
28 | error={error} | 28 | error={error} |
29 | /> | 29 | /> |
30 | ); | 30 | ); |