1- import React from 'react' ;
1+ import React , { useContext } from 'react' ;
22import PropTypes from 'prop-types' ;
3- import { injectIntl , intlShape } from '@edx/frontend-platform/i18n' ;
3+ import { useIntl } from '@edx/frontend-platform/i18n' ;
44import { sendTrackEvent } from '@edx/frontend-platform/analytics' ;
55import { ensureConfig } from '@edx/frontend-platform' ;
66import { AppContext } from '@edx/frontend-platform/react' ;
@@ -17,66 +17,57 @@ const EVENT_NAMES = {
1717 FOOTER_LINK : 'edx.bi.footer.link' ,
1818} ;
1919
20- class SiteFooter extends React . Component {
21- constructor ( props ) {
22- super ( props ) ;
23- this . externalLinkClickHandler = this . externalLinkClickHandler . bind ( this ) ;
24- }
20+ const SiteFooter = ( {
21+ supportedLanguages,
22+ onLanguageSelected,
23+ logo,
24+ } ) => {
25+ const intl = useIntl ( ) ;
26+ const { config } = useContext ( AppContext ) ;
2527
26- externalLinkClickHandler ( event ) {
28+ const showLanguageSelector = supportedLanguages . length > 0 && onLanguageSelected ;
29+
30+ const externalLinkClickHandler = ( event ) => {
2731 const label = event . currentTarget . getAttribute ( 'href' ) ;
2832 const eventName = EVENT_NAMES . FOOTER_LINK ;
2933 const properties = {
3034 category : 'outbound_link' ,
3135 label,
3236 } ;
3337 sendTrackEvent ( eventName , properties ) ;
34- }
35-
36- render ( ) {
37- const {
38- supportedLanguages,
39- onLanguageSelected,
40- logo,
41- intl,
42- } = this . props ;
43- const showLanguageSelector = supportedLanguages . length > 0 && onLanguageSelected ;
44- const { config } = this . context ;
38+ } ;
4539
46- return (
47- < footer
48- role = "contentinfo"
49- className = "footer d-flex border-top py-3 px-4"
50- >
51- < div className = "container-fluid d-flex" >
52- < a
53- className = "d-block"
54- href = { config . LMS_BASE_URL }
55- aria-label = { intl . formatMessage ( messages [ 'footer.logo.ariaLabel' ] ) }
56- >
57- < img
58- style = { { maxHeight : 45 } }
59- src = { logo || config . LOGO_TRADEMARK_URL }
60- alt = { intl . formatMessage ( messages [ 'footer.logo.altText' ] ) }
61- />
62- </ a >
63- < div className = "flex-grow-1" />
64- { showLanguageSelector && (
65- < LanguageSelector
66- options = { supportedLanguages }
67- onSubmit = { onLanguageSelected }
68- />
69- ) }
70- </ div >
71- </ footer >
72- ) ;
73- }
74- }
75-
76- SiteFooter . contextType = AppContext ;
40+ return (
41+ < footer
42+ role = "contentinfo"
43+ className = "footer d-flex border-top py-3 px-4"
44+ >
45+ < div className = "container-fluid d-flex" >
46+ < a
47+ className = "d-block"
48+ href = { config . LMS_BASE_URL }
49+ aria-label = { intl . formatMessage ( messages [ 'footer.logo.ariaLabel' ] ) }
50+ onClick = { externalLinkClickHandler }
51+ >
52+ < img
53+ style = { { maxHeight : 45 } }
54+ src = { logo || config . LOGO_TRADEMARK_URL }
55+ alt = { intl . formatMessage ( messages [ 'footer.logo.altText' ] ) }
56+ />
57+ </ a >
58+ < div className = "flex-grow-1" />
59+ { showLanguageSelector && (
60+ < LanguageSelector
61+ options = { supportedLanguages }
62+ onSubmit = { onLanguageSelected }
63+ />
64+ ) }
65+ </ div >
66+ </ footer >
67+ ) ;
68+ } ;
7769
7870SiteFooter . propTypes = {
79- intl : intlShape . isRequired ,
8071 logo : PropTypes . string ,
8172 onLanguageSelected : PropTypes . func ,
8273 supportedLanguages : PropTypes . arrayOf ( PropTypes . shape ( {
@@ -91,5 +82,5 @@ SiteFooter.defaultProps = {
9182 supportedLanguages : [ ] ,
9283} ;
9384
94- export default injectIntl ( SiteFooter ) ;
85+ export default SiteFooter ;
9586export { EVENT_NAMES } ;
0 commit comments