11import cx from 'classnames' ;
22import PropTypes from 'prop-types' ;
3- import React , { useCallback } from 'react' ;
3+ import React from 'react' ;
44import { FormattedMessage , useIntl } from 'react-intl' ;
5- import connectToStores from 'fluxible-addons-react/connectToStores' ;
65import { addAnalyticsEvent } from '../../../util/analyticsUtils' ;
7- import { configShape , legShape } from '../../../util/shapes' ;
6+ import { legShape } from '../../../util/shapes' ;
87import { epochToTime , durationToString } from '../../../util/timeUtils' ;
98import { getFaresFromLegs , shouldShowFareInfo } from '../../../util/fareUtils' ;
109import localizedUrl from '../../../util/urlUtils' ;
10+ import { useConfigContext } from '../../../configurations/ConfigContext' ;
1111
12- function NaviBottom (
13- { setNavigation, arrival, time, legs, currentLanguage } ,
14- { config } ,
15- ) {
16- const handleClose = useCallback ( ( ) => {
12+ export default function NaviBottom ( { setNavigation, arrival, time, legs } ) {
13+ const intl = useIntl ( ) ;
14+ const config = useConfigContext ( ) ;
15+ const currentLanguage = config . language ;
16+
17+ const handleClose = ( ) => {
1718 addAnalyticsEvent ( {
1819 category : 'Itinerary' ,
1920 event : 'navigator' ,
2021 action : 'cancel_navigation' ,
2122 } ) ;
2223 setNavigation ( false ) ;
23- } , [ setNavigation ] ) ;
24- const handleTicketButtonClick = useCallback ( e => e . stopPropagation ( ) , [ ] ) ;
25- const intl = useIntl ( ) ;
24+ } ;
25+
26+ const handleTicketButtonClick = e => {
27+ e . stopPropagation ( ) ;
28+ } ;
2629
2730 const isTicketSaleActive =
2831 config . navigatorTicketLink &&
@@ -70,19 +73,16 @@ function NaviBottom(
7073 { FirstElement }
7174 { SecondElement }
7275 { isTicketSaleActive && (
73- /* TODO HSL hack, make link below configurable */ < button
74- type = "button"
76+ /* TODO HSL hack, make link below configurable */
77+ < a
7578 className = "navi-ticket-button"
79+ href = { localizedUrl ( config . navigatorTicketLink , currentLanguage ) }
80+ onClick = { handleTicketButtonClick }
81+ target = "_blank"
82+ rel = "noopener noreferrer"
7683 >
77- < a
78- onClick = { handleTicketButtonClick }
79- href = { localizedUrl ( config . navigatorTicketLink , currentLanguage ) }
80- target = "_blank"
81- rel = "noopener noreferrer"
82- >
83- < FormattedMessage id = "navigation-ticket" />
84- </ a >
85- </ button >
84+ < FormattedMessage id = "navigation-ticket" />
85+ </ a >
8686 ) }
8787 </ div >
8888 ) ;
@@ -93,19 +93,4 @@ NaviBottom.propTypes = {
9393 arrival : PropTypes . number . isRequired ,
9494 time : PropTypes . number . isRequired ,
9595 legs : PropTypes . arrayOf ( legShape ) . isRequired ,
96- currentLanguage : PropTypes . string . isRequired ,
9796} ;
98-
99- NaviBottom . contextTypes = {
100- config : configShape . isRequired ,
101- } ;
102-
103- const connectedComponent = connectToStores (
104- NaviBottom ,
105- [ 'PreferencesStore' ] ,
106- context => ( {
107- currentLanguage : context . getStore ( 'PreferencesStore' ) . getLanguage ( ) ,
108- } ) ,
109- ) ;
110-
111- export { connectedComponent as default , NaviBottom as Component } ;
0 commit comments