1
1
import React , { useEffect , useMemo , useState } from 'react' ;
2
- import { connect } from 'react-redux' ;
2
+ import { connect , useSelector } from 'react-redux' ;
3
3
4
4
import { getConfig } from '@edx/frontend-platform' ;
5
5
import { sendPageEvent , sendTrackEvent } from '@edx/frontend-platform/analytics' ;
@@ -33,7 +33,7 @@ import { thirdPartyAuthContextSelector } from '../common-components/data/selecto
33
33
import EnterpriseSSO from '../common-components/EnterpriseSSO' ;
34
34
import ThirdPartyAuth from '../common-components/ThirdPartyAuth' ;
35
35
import {
36
- DEFAULT_STATE , PENDING_STATE , RESET_PAGE ,
36
+ PENDING_STATE , RESET_PAGE ,
37
37
} from '../data/constants' ;
38
38
import {
39
39
getActivationStatus ,
@@ -46,11 +46,6 @@ import ResetPasswordSuccess from '../reset-password/ResetPasswordSuccess';
46
46
47
47
const LoginPage = ( props ) => {
48
48
const {
49
- backedUpFormData,
50
- loginErrorCode,
51
- loginErrorContext,
52
- loginResult,
53
- shouldBackupState,
54
49
thirdPartyAuthContext : {
55
50
providers,
56
51
currentProvider,
@@ -59,15 +54,32 @@ const LoginPage = (props) => {
59
54
platformName,
60
55
errorMessage : thirdPartyErrorMessage ,
61
56
} ,
62
- thirdPartyAuthApiStatus,
63
57
institutionLogin,
64
- showResetPasswordSuccessBanner,
65
- submitState,
66
58
// Actions
67
59
backupFormState,
68
60
handleInstitutionLogin,
69
61
getTPADataFromBackend,
70
62
} = props ;
63
+ const {
64
+ backedUpFormData,
65
+ loginErrorCode,
66
+ loginErrorContext,
67
+ loginResult,
68
+ shouldBackupState,
69
+ showResetPasswordSuccessBanner,
70
+ submitState,
71
+ thirdPartyAuthApiStatus,
72
+ } = useSelector ( ( state ) => ( {
73
+ backedUpFormData : state . login . loginFormData ,
74
+ loginErrorCode : state . login . loginErrorCode ,
75
+ loginErrorContext : state . login . loginErrorContext ,
76
+ loginResult : state . login . loginResult ,
77
+ shouldBackupState : state . login . shouldBackupState ,
78
+ showResetPasswordSuccessBanner : state . login . showResetPasswordSuccessBanner ,
79
+ submitState : state . login . submitState ,
80
+ thirdPartyAuthContext : thirdPartyAuthContextSelector ( state ) ,
81
+ thirdPartyAuthApiStatus : state . commonComponents . thirdPartyAuthApiStatus ,
82
+ } ) ) ;
71
83
const { formatMessage } = useIntl ( ) ;
72
84
const activationMsgType = getActivationStatus ( ) ;
73
85
const queryParams = useMemo ( ( ) => getAllPossibleQueryParams ( ) , [ ] ) ;
@@ -281,27 +293,15 @@ const LoginPage = (props) => {
281
293
) ;
282
294
} ;
283
295
284
- const mapStateToProps = state => {
285
- const loginPageState = state . login ;
286
- return {
287
- backedUpFormData : loginPageState . loginFormData ,
288
- loginErrorCode : loginPageState . loginErrorCode ,
289
- loginErrorContext : loginPageState . loginErrorContext ,
290
- loginResult : loginPageState . loginResult ,
291
- shouldBackupState : loginPageState . shouldBackupState ,
292
- showResetPasswordSuccessBanner : loginPageState . showResetPasswordSuccessBanner ,
293
- submitState : loginPageState . submitState ,
294
- thirdPartyAuthContext : thirdPartyAuthContextSelector ( state ) ,
295
- thirdPartyAuthApiStatus : state . commonComponents . thirdPartyAuthApiStatus ,
296
- } ;
297
- } ;
296
+ const mapStateToProps = state => ( {
297
+ thirdPartyAuthContext : thirdPartyAuthContextSelector ( state ) ,
298
+ } ) ;
298
299
299
300
LoginPage . propTypes = {
300
301
backedUpFormData : PropTypes . shape ( {
301
302
formFields : PropTypes . shape ( { } ) ,
302
303
errors : PropTypes . shape ( { } ) ,
303
304
} ) ,
304
- loginErrorCode : PropTypes . string ,
305
305
loginErrorContext : PropTypes . shape ( {
306
306
email : PropTypes . string ,
307
307
redirectUrl : PropTypes . string ,
@@ -311,10 +311,6 @@ LoginPage.propTypes = {
311
311
redirectUrl : PropTypes . string ,
312
312
success : PropTypes . bool ,
313
313
} ) ,
314
- shouldBackupState : PropTypes . bool ,
315
- showResetPasswordSuccessBanner : PropTypes . bool ,
316
- submitState : PropTypes . string ,
317
- thirdPartyAuthApiStatus : PropTypes . string ,
318
314
institutionLogin : PropTypes . bool . isRequired ,
319
315
thirdPartyAuthContext : PropTypes . shape ( {
320
316
currentProvider : PropTypes . string ,
@@ -341,13 +337,8 @@ LoginPage.defaultProps = {
341
337
emailOrUsername : '' , password : '' ,
342
338
} ,
343
339
} ,
344
- loginErrorCode : null ,
345
340
loginErrorContext : { } ,
346
341
loginResult : { } ,
347
- shouldBackupState : false ,
348
- showResetPasswordSuccessBanner : false ,
349
- submitState : DEFAULT_STATE ,
350
- thirdPartyAuthApiStatus : PENDING_STATE ,
351
342
thirdPartyAuthContext : {
352
343
currentProvider : null ,
353
344
errorMessage : null ,
0 commit comments