1
- import React from 'react' ;
1
+ import React , { useContext } from 'react' ;
2
2
import PropTypes from 'prop-types' ;
3
- import { injectIntl , intlShape } from '@edx/frontend-platform/i18n' ;
3
+ import { useIntl } from '@edx/frontend-platform/i18n' ;
4
4
import { sendTrackEvent } from '@edx/frontend-platform/analytics' ;
5
5
import { ensureConfig } from '@edx/frontend-platform' ;
6
6
import { AppContext } from '@edx/frontend-platform/react' ;
@@ -17,66 +17,57 @@ const EVENT_NAMES = {
17
17
FOOTER_LINK : 'edx.bi.footer.link' ,
18
18
} ;
19
19
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 ) ;
25
27
26
- externalLinkClickHandler ( event ) {
28
+ const showLanguageSelector = supportedLanguages . length > 0 && onLanguageSelected ;
29
+
30
+ const externalLinkClickHandler = ( event ) => {
27
31
const label = event . currentTarget . getAttribute ( 'href' ) ;
28
32
const eventName = EVENT_NAMES . FOOTER_LINK ;
29
33
const properties = {
30
34
category : 'outbound_link' ,
31
35
label,
32
36
} ;
33
37
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
+ } ;
45
39
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
+ } ;
77
69
78
70
SiteFooter . propTypes = {
79
- intl : intlShape . isRequired ,
80
71
logo : PropTypes . string ,
81
72
onLanguageSelected : PropTypes . func ,
82
73
supportedLanguages : PropTypes . arrayOf ( PropTypes . shape ( {
@@ -91,5 +82,5 @@ SiteFooter.defaultProps = {
91
82
supportedLanguages : [ ] ,
92
83
} ;
93
84
94
- export default injectIntl ( SiteFooter ) ;
85
+ export default SiteFooter ;
95
86
export { EVENT_NAMES } ;
0 commit comments