1
1
import React , { useEffect , useState } from 'react' ;
2
- import { connect } from 'react-redux' ;
2
+ import { useDispatch , useSelector } from 'react-redux' ;
3
3
4
4
import { getConfig } from '@edx/frontend-platform' ;
5
5
import { sendPageEvent , sendTrackEvent } from '@edx/frontend-platform/analytics' ;
@@ -16,9 +16,6 @@ import { Navigate, useNavigate } from 'react-router-dom';
16
16
17
17
import BaseContainer from '../base-container' ;
18
18
import { clearThirdPartyAuthContextErrorMessage } from '../common-components/data/actions' ;
19
- import {
20
- tpaProvidersSelector ,
21
- } from '../common-components/data/selectors' ;
22
19
import messages from '../common-components/messages' ;
23
20
import { LOGIN_PAGE , REGISTER_PAGE } from '../data/constants' ;
24
21
import {
@@ -30,18 +27,19 @@ import { RegistrationPage } from '../register';
30
27
import { backupRegistrationForm } from '../register/data/actions' ;
31
28
32
29
const Logistration = ( props ) => {
33
- const { selectedPage, tpaProviders } = props ;
30
+ const { selectedPage } = props ;
34
31
const tpaHint = getTpaHint ( ) ;
35
- const {
36
- providers, secondaryProviders,
37
- } = tpaProviders ;
38
32
const { formatMessage } = useIntl ( ) ;
39
33
const [ institutionLogin , setInstitutionLogin ] = useState ( false ) ;
40
34
const [ key , setKey ] = useState ( '' ) ;
41
35
const navigate = useNavigate ( ) ;
42
36
const disablePublicAccountCreation = getConfig ( ) . ALLOW_PUBLIC_ACCOUNT_CREATION === false ;
43
37
const hideRegistrationLink = getConfig ( ) . SHOW_REGISTRATION_LINKS === false ;
44
38
39
+ const dispatch = useDispatch ( ) ;
40
+ const providers = useSelector ( state => state . commonComponents . thirdPartyAuthContext . providers ) ;
41
+ const secondaryProviders = useSelector ( state => state . commonComponents . thirdPartyAuthContext . secondaryProviders ) ;
42
+
45
43
useEffect ( ( ) => {
46
44
const authService = getAuthService ( ) ;
47
45
if ( authService ) {
@@ -71,11 +69,11 @@ const Logistration = (props) => {
71
69
return ;
72
70
}
73
71
sendTrackEvent ( `edx.bi.${ tabKey . replace ( '/' , '' ) } _form.toggled` , { category : 'user-engagement' } ) ;
74
- props . clearThirdPartyAuthContextErrorMessage ( ) ;
72
+ dispatch ( clearThirdPartyAuthContextErrorMessage ( ) ) ;
75
73
if ( tabKey === LOGIN_PAGE ) {
76
- props . backupRegistrationForm ( ) ;
74
+ dispatch ( backupRegistrationForm ( ) ) ;
77
75
} else if ( tabKey === REGISTER_PAGE ) {
78
- props . backupLoginForm ( ) ;
76
+ dispatch ( backupLoginForm ( ) ) ;
79
77
}
80
78
setKey ( tabKey ) ;
81
79
} ;
@@ -156,35 +154,10 @@ const Logistration = (props) => {
156
154
157
155
Logistration . propTypes = {
158
156
selectedPage : PropTypes . string ,
159
- backupLoginForm : PropTypes . func . isRequired ,
160
- backupRegistrationForm : PropTypes . func . isRequired ,
161
- clearThirdPartyAuthContextErrorMessage : PropTypes . func . isRequired ,
162
- tpaProviders : PropTypes . shape ( {
163
- providers : PropTypes . arrayOf ( PropTypes . shape ( { } ) ) ,
164
- secondaryProviders : PropTypes . arrayOf ( PropTypes . shape ( { } ) ) ,
165
- } ) ,
166
- } ;
167
-
168
- Logistration . defaultProps = {
169
- tpaProviders : {
170
- providers : [ ] ,
171
- secondaryProviders : [ ] ,
172
- } ,
173
157
} ;
174
158
175
159
Logistration . defaultProps = {
176
160
selectedPage : REGISTER_PAGE ,
177
161
} ;
178
162
179
- const mapStateToProps = state => ( {
180
- tpaProviders : tpaProvidersSelector ( state ) ,
181
- } ) ;
182
-
183
- export default connect (
184
- mapStateToProps ,
185
- {
186
- backupLoginForm,
187
- backupRegistrationForm,
188
- clearThirdPartyAuthContextErrorMessage,
189
- } ,
190
- ) ( Logistration ) ;
163
+ export default Logistration ;
0 commit comments