11import React , { useEffect , useState } from 'react' ;
2- import { connect } from 'react-redux' ;
2+ import { useDispatch , useSelector } from 'react-redux' ;
33
44import { getConfig } from '@edx/frontend-platform' ;
55import { sendPageEvent , sendTrackEvent } from '@edx/frontend-platform/analytics' ;
@@ -16,9 +16,6 @@ import { Navigate, useNavigate } from 'react-router-dom';
1616
1717import BaseContainer from '../base-container' ;
1818import { clearThirdPartyAuthContextErrorMessage } from '../common-components/data/actions' ;
19- import {
20- tpaProvidersSelector ,
21- } from '../common-components/data/selectors' ;
2219import messages from '../common-components/messages' ;
2320import { LOGIN_PAGE , REGISTER_PAGE } from '../data/constants' ;
2421import {
@@ -30,18 +27,19 @@ import { RegistrationPage } from '../register';
3027import { backupRegistrationForm } from '../register/data/actions' ;
3128
3229const Logistration = ( props ) => {
33- const { selectedPage, tpaProviders } = props ;
30+ const { selectedPage } = props ;
3431 const tpaHint = getTpaHint ( ) ;
35- const {
36- providers, secondaryProviders,
37- } = tpaProviders ;
3832 const { formatMessage } = useIntl ( ) ;
3933 const [ institutionLogin , setInstitutionLogin ] = useState ( false ) ;
4034 const [ key , setKey ] = useState ( '' ) ;
4135 const navigate = useNavigate ( ) ;
4236 const disablePublicAccountCreation = getConfig ( ) . ALLOW_PUBLIC_ACCOUNT_CREATION === false ;
4337 const hideRegistrationLink = getConfig ( ) . SHOW_REGISTRATION_LINKS === false ;
4438
39+ const dispatch = useDispatch ( ) ;
40+ const providers = useSelector ( state => state . commonComponents . thirdPartyAuthContext . providers ) ;
41+ const secondaryProviders = useSelector ( state => state . commonComponents . thirdPartyAuthContext . secondaryProviders ) ;
42+
4543 useEffect ( ( ) => {
4644 const authService = getAuthService ( ) ;
4745 if ( authService ) {
@@ -71,11 +69,11 @@ const Logistration = (props) => {
7169 return ;
7270 }
7371 sendTrackEvent ( `edx.bi.${ tabKey . replace ( '/' , '' ) } _form.toggled` , { category : 'user-engagement' } ) ;
74- props . clearThirdPartyAuthContextErrorMessage ( ) ;
72+ dispatch ( clearThirdPartyAuthContextErrorMessage ( ) ) ;
7573 if ( tabKey === LOGIN_PAGE ) {
76- props . backupRegistrationForm ( ) ;
74+ dispatch ( backupRegistrationForm ( ) ) ;
7775 } else if ( tabKey === REGISTER_PAGE ) {
78- props . backupLoginForm ( ) ;
76+ dispatch ( backupLoginForm ( ) ) ;
7977 }
8078 setKey ( tabKey ) ;
8179 } ;
@@ -156,35 +154,10 @@ const Logistration = (props) => {
156154
157155Logistration . propTypes = {
158156 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- } ,
173157} ;
174158
175159Logistration . defaultProps = {
176160 selectedPage : REGISTER_PAGE ,
177161} ;
178162
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