|
1 | | -// @flow |
2 | | - |
3 | | -// #region imports |
4 | 1 | import React, { PureComponent } from 'react'; |
5 | 2 | import axios from 'axios'; |
6 | | -import { |
7 | | - type Match, |
8 | | - type Location, |
9 | | - type RouterHistory, |
10 | | -} from 'react-router-dom'; |
| 3 | +import { RouteComponentProps } from 'react-router'; |
11 | 4 | import Button from 'reactstrap/lib/Button'; |
12 | 5 | import Row from 'reactstrap/lib/Row'; |
13 | 6 | import Col from 'reactstrap/lib/Col'; |
14 | 7 | import { appConfig } from '../../config/appConfig'; |
15 | 8 | import { getLocationOrigin } from '../../services/API/fetchTools'; |
16 | 9 | import userInfoMock from '../../mock/userInfo.json'; |
17 | | -import { type AuthContextProps } from '../../contexts/auth/consumerHOC'; |
18 | | -// #endregion |
| 10 | +import { AuthContextProps } from '../../contexts/auth/consumerHOC'; |
19 | 11 |
|
20 | | -// #region flow types |
21 | | -type Props = { |
22 | | - // react-router 4: |
23 | | - match: Match, |
24 | | - location: Location, |
25 | | - history: RouterHistory, |
26 | | - |
27 | | - ...any, |
28 | | -} & AuthContextProps; |
| 12 | +// #region types |
| 13 | +type Props = {} & RouteComponentProps & AuthContextProps; |
29 | 14 |
|
30 | 15 | type State = { |
31 | | - email: string, |
32 | | - password: string, |
33 | | - isLogging: boolean, |
34 | | - |
35 | | - ...any, |
| 16 | + email: string; |
| 17 | + password: string; |
| 18 | + isLogging: boolean; |
36 | 19 | }; |
37 | 20 | // #endregion |
38 | 21 |
|
@@ -141,19 +124,19 @@ class Login extends PureComponent<Props, State> { |
141 | 124 | disconnectUser(); |
142 | 125 | }; |
143 | 126 |
|
144 | | - handlesOnEmailChange = (event: SyntheticEvent<>) => { |
| 127 | + handlesOnEmailChange = (event: React.ChangeEvent<HTMLInputElement>) => { |
145 | 128 | event.preventDefault(); |
146 | 129 | // should add some validator before setState in real use cases |
147 | 130 | this.setState({ email: event.target.value.trim() }); |
148 | 131 | }; |
149 | 132 |
|
150 | | - handlesOnPasswordChange = (event: SyntheticEvent<>) => { |
| 133 | + handlesOnPasswordChange = (event: React.ChangeEvent<HTMLInputElement>) => { |
151 | 134 | event.preventDefault(); |
152 | 135 | // should add some validator before setState in real use cases |
153 | 136 | this.setState({ password: event.target.value.trim() }); |
154 | 137 | }; |
155 | 138 |
|
156 | | - handlesOnLogin = async (event: SyntheticEvent<>) => { |
| 139 | + handlesOnLogin = async (event: React.MouseEvent<HTMLButtonElement>) => { |
157 | 140 | if (event) { |
158 | 141 | event.preventDefault(); |
159 | 142 | } |
@@ -226,7 +209,7 @@ class Login extends PureComponent<Props, State> { |
226 | 209 | } |
227 | 210 | }; |
228 | 211 |
|
229 | | - goHome = (event: any) => { |
| 212 | + goHome = (event: React.MouseEvent<HTMLButtonElement>) => { |
230 | 213 | if (event) { |
231 | 214 | event.preventDefault(); |
232 | 215 | } |
|
0 commit comments