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 ( ) , [ ] ) ;
@@ -282,17 +294,8 @@ const LoginPage = (props) => {
282
294
} ;
283
295
284
296
const mapStateToProps = state => {
285
- const loginPageState = state . login ;
286
297
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
298
thirdPartyAuthContext : thirdPartyAuthContextSelector ( state ) ,
295
- thirdPartyAuthApiStatus : state . commonComponents . thirdPartyAuthApiStatus ,
296
299
} ;
297
300
} ;
298
301
@@ -301,7 +304,6 @@ LoginPage.propTypes = {
301
304
formFields : PropTypes . shape ( { } ) ,
302
305
errors : PropTypes . shape ( { } ) ,
303
306
} ) ,
304
- loginErrorCode : PropTypes . string ,
305
307
loginErrorContext : PropTypes . shape ( {
306
308
email : PropTypes . string ,
307
309
redirectUrl : PropTypes . string ,
@@ -311,10 +313,6 @@ LoginPage.propTypes = {
311
313
redirectUrl : PropTypes . string ,
312
314
success : PropTypes . bool ,
313
315
} ) ,
314
- shouldBackupState : PropTypes . bool ,
315
- showResetPasswordSuccessBanner : PropTypes . bool ,
316
- submitState : PropTypes . string ,
317
- thirdPartyAuthApiStatus : PropTypes . string ,
318
316
institutionLogin : PropTypes . bool . isRequired ,
319
317
thirdPartyAuthContext : PropTypes . shape ( {
320
318
currentProvider : PropTypes . string ,
@@ -341,13 +339,8 @@ LoginPage.defaultProps = {
341
339
emailOrUsername : '' , password : '' ,
342
340
} ,
343
341
} ,
344
- loginErrorCode : null ,
345
342
loginErrorContext : { } ,
346
343
loginResult : { } ,
347
- shouldBackupState : false ,
348
- showResetPasswordSuccessBanner : false ,
349
- submitState : DEFAULT_STATE ,
350
- thirdPartyAuthApiStatus : PENDING_STATE ,
351
344
thirdPartyAuthContext : {
352
345
currentProvider : null ,
353
346
errorMessage : null ,
0 commit comments