Skip to content

Commit c49db80

Browse files
committed
Modernize CallAgencyLeg.
1 parent 95219d2 commit c49db80

1 file changed

Lines changed: 7 additions & 23 deletions

File tree

app/component/itinerary/CallAgencyLeg.js

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,24 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
33
import { useIntl } from 'react-intl';
4-
import connectToStores from 'fluxible-addons-react/connectToStores';
5-
import { legShape, configShape } from '../../util/shapes';
4+
import { legShape } from '../../util/shapes';
65
import TransitLeg from './TransitLeg';
76
import CallAgencyDisclaimer from './CallAgencyDisclaimer';
87
import RouteNumberContainer from '../RouteNumber';
98
import withBreakpoint from '../../util/withBreakpoint';
109
import { isLocalCallAgency } from '../../util/legUtils';
10+
import { useConfigContext } from '../../configurations/ConfigContext';
1111

12-
const CallAgencyLeg = (
13-
{ leg, currentLanguage, breakpoint, ...props },
14-
{ config },
15-
) => {
12+
const CallAgencyLeg = ({ leg, breakpoint, ...props }) => {
1613
const intl = useIntl();
14+
const config = useConfigContext();
1715
const modeClassName = 'call';
1816
const { route } = leg;
1917
const mobile = breakpoint === 'small' || breakpoint === 'medium';
2018
const notification =
2119
config.showRouteDescNotification &&
2220
route.desc?.length &&
23-
config.flex.infoLanguage === currentLanguage // No translations available in the data at the moment
21+
config.flex.infoLanguage === config.language // No translations available in the data at the moment
2422
? { content: route.desc, link: route.url }
2523
: {
2624
content: intl.formatMessage({ id: 'call-agency-disclaimer' }),
@@ -67,7 +65,6 @@ CallAgencyLeg.propTypes = {
6765
leg: legShape.isRequired,
6866
index: PropTypes.number.isRequired,
6967
showRouteDescNotification: PropTypes.bool,
70-
currentLanguage: PropTypes.string.isRequired,
7168
breakpoint: PropTypes.string,
7269
};
7370

@@ -76,18 +73,5 @@ CallAgencyLeg.defaultProps = {
7673
breakpoint: undefined,
7774
};
7875

79-
CallAgencyLeg.contextTypes = {
80-
config: configShape.isRequired,
81-
};
82-
83-
const CallAgencyLegWithBreakpoint = withBreakpoint(CallAgencyLeg);
84-
85-
const connectedComponent = connectToStores(
86-
CallAgencyLegWithBreakpoint,
87-
['PreferencesStore'],
88-
context => ({
89-
currentLanguage: context.getStore('PreferencesStore').getLanguage(),
90-
}),
91-
);
92-
93-
export { CallAgencyLeg as Component, connectedComponent as default };
76+
export { CallAgencyLeg as Component };
77+
export default withBreakpoint(CallAgencyLeg);

0 commit comments

Comments
 (0)