11import  React ,  {  useEffect ,  useMemo ,  useState  }  from  'react' ; 
2- import  {  connect  }  from  'react-redux' ; 
2+ import  {  connect ,   useSelector  }  from  'react-redux' ; 
33
44import  {  getConfig  }  from  '@edx/frontend-platform' ; 
55import  {  sendPageEvent ,  sendTrackEvent  }  from  '@edx/frontend-platform/analytics' ; 
@@ -33,7 +33,7 @@ import { thirdPartyAuthContextSelector } from '../common-components/data/selecto
3333import  EnterpriseSSO  from  '../common-components/EnterpriseSSO' ; 
3434import  ThirdPartyAuth  from  '../common-components/ThirdPartyAuth' ; 
3535import  { 
36-   DEFAULT_STATE ,   PENDING_STATE ,  RESET_PAGE , 
36+   PENDING_STATE ,  RESET_PAGE , 
3737}  from  '../data/constants' ; 
3838import  { 
3939  getActivationStatus , 
@@ -46,11 +46,6 @@ import ResetPasswordSuccess from '../reset-password/ResetPasswordSuccess';
4646
4747const  LoginPage  =  ( props )  =>  { 
4848  const  { 
49-     backedUpFormData, 
50-     loginErrorCode, 
51-     loginErrorContext, 
52-     loginResult, 
53-     shouldBackupState, 
5449    thirdPartyAuthContext : { 
5550      providers, 
5651      currentProvider, 
@@ -59,15 +54,32 @@ const LoginPage = (props) => {
5954      platformName, 
6055      errorMessage : thirdPartyErrorMessage , 
6156    } , 
62-     thirdPartyAuthApiStatus, 
6357    institutionLogin, 
64-     showResetPasswordSuccessBanner, 
65-     submitState, 
6658    // Actions 
6759    backupFormState, 
6860    handleInstitutionLogin, 
6961    getTPADataFromBackend, 
7062  }  =  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+   } ) ) ; 
7183  const  {  formatMessage }  =  useIntl ( ) ; 
7284  const  activationMsgType  =  getActivationStatus ( ) ; 
7385  const  queryParams  =  useMemo ( ( )  =>  getAllPossibleQueryParams ( ) ,  [ ] ) ; 
@@ -281,27 +293,15 @@ const LoginPage = (props) => {
281293  ) ; 
282294} ; 
283295
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+ } ) ; 
298299
299300LoginPage . propTypes  =  { 
300301  backedUpFormData : PropTypes . shape ( { 
301302    formFields : PropTypes . shape ( { } ) , 
302303    errors : PropTypes . shape ( { } ) , 
303304  } ) , 
304-   loginErrorCode : PropTypes . string , 
305305  loginErrorContext : PropTypes . shape ( { 
306306    email : PropTypes . string , 
307307    redirectUrl : PropTypes . string , 
@@ -311,10 +311,6 @@ LoginPage.propTypes = {
311311    redirectUrl : PropTypes . string , 
312312    success : PropTypes . bool , 
313313  } ) , 
314-   shouldBackupState : PropTypes . bool , 
315-   showResetPasswordSuccessBanner : PropTypes . bool , 
316-   submitState : PropTypes . string , 
317-   thirdPartyAuthApiStatus : PropTypes . string , 
318314  institutionLogin : PropTypes . bool . isRequired , 
319315  thirdPartyAuthContext : PropTypes . shape ( { 
320316    currentProvider : PropTypes . string , 
@@ -341,13 +337,8 @@ LoginPage.defaultProps = {
341337      emailOrUsername : '' ,  password : '' , 
342338    } , 
343339  } , 
344-   loginErrorCode : null , 
345340  loginErrorContext : { } , 
346341  loginResult : { } , 
347-   shouldBackupState : false , 
348-   showResetPasswordSuccessBanner : false , 
349-   submitState : DEFAULT_STATE , 
350-   thirdPartyAuthApiStatus : PENDING_STATE , 
351342  thirdPartyAuthContext : { 
352343    currentProvider : null , 
353344    errorMessage : null , 
0 commit comments