Skip to content

Commit

Permalink
Merge pull request #5193 from HSLdevcom/call-agency-fixes
Browse files Browse the repository at this point in the history
Call agency fixes
  • Loading branch information
partisaani authored Dec 10, 2024
2 parents fe4e065 + a78338a commit 6c65caa
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 27 deletions.
2 changes: 1 addition & 1 deletion app/component/RouteNumberContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const RouteNumberContainer = (
<RouteNumber
alertSeverityLevel={alertSeverityLevel}
className={className}
isCallAgency={isCallAgency || route.type === 715}
isCallAgency={isCallAgency}
color={route.color ? `#${route.color}` : null}
mode={mode !== undefined ? mode : route.mode}
text={getLegText(route, config, interliningWithRoute)}
Expand Down
20 changes: 11 additions & 9 deletions app/component/itinerary/CallAgencyLeg.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,17 @@ const CallAgencyLeg = ({ leg, ...props }) => {
defaultMessage="Only on demand: {routeName}, which needs to be booked in advance."
/>
<div className="itinerary-warning-agency-container" />
<div className="call-button">
<a href={`tel:${leg.route.agency.phone}`}>
<FormattedMessage
id="call"
defaultMessage="Call"
values={{ number: leg.route.agency.phone }}
/>
</a>
</div>
{leg.route.agency.phone && (
<div className="call-button">
<a href={`tel:${leg.route.agency.phone}`}>
<FormattedMessage
id="call"
defaultMessage="Call"
values={{ number: leg.route.agency.phone }}
/>
</a>
</div>
)}
</span>
</div>
</TransitLeg>
Expand Down
4 changes: 2 additions & 2 deletions app/component/itinerary/Itinerary.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
getLegMode,
compressLegs,
getLegBadgeProps,
isCallAgencyPickupType,
isCallAgencyLeg,
getInterliningLegs,
getTotalDistance,
legTime,
Expand Down Expand Up @@ -86,7 +86,7 @@ export function RouteLeg(
},
{ config },
) {
const isCallAgency = isCallAgencyPickupType(leg);
const isCallAgency = isCallAgencyLeg(leg);
let routeNumber;
const mode = getRouteMode(leg.route, config);

Expand Down
4 changes: 2 additions & 2 deletions app/component/itinerary/ItineraryDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
getTotalWalkingDistance,
getTotalWalkingDuration,
getZones,
isCallAgencyPickupType,
isCallAgencyLeg,
legContainsBikePark,
legContainsRentalBike,
} from '../../util/legUtils';
Expand Down Expand Up @@ -215,7 +215,7 @@ class ItineraryDetails extends React.Component {
});

const info = config.callAgencyInfo?.[currentLanguage];
if (info && itinerary.legs.some(leg => isCallAgencyPickupType(leg))) {
if (info && itinerary.legs.some(leg => isCallAgencyLeg(leg))) {
disclaimers.push(
<FareDisclaimer
key={disclaimers.length}
Expand Down
4 changes: 2 additions & 2 deletions app/component/itinerary/Legs.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import ViaLeg from './ViaLeg';
import CallAgencyLeg from './CallAgencyLeg';
import {
compressLegs,
isCallAgencyPickupType,
isCallAgencyLeg,
isLegOnFoot,
legTime,
} from '../../util/legUtils';
Expand Down Expand Up @@ -164,7 +164,7 @@ export default class Legs extends React.Component {
);
}
}
if (leg.mode !== 'WALK' && isCallAgencyPickupType(leg)) {
if (leg.mode !== 'WALK' && isCallAgencyLeg(leg)) {
legs.push(<CallAgencyLeg {...transitLegProps} />);
} else if (leg.intermediatePlace) {
legs.push(<ViaLeg {...legProps} arrival={startTime} />);
Expand Down
12 changes: 6 additions & 6 deletions app/component/map/ItineraryLine.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { getMiddleOf } from '../../util/geo-utils';
import {
getInterliningLegs,
getLegText,
isCallAgencyPickupType,
isCallAgencyLeg,
} from '../../util/legUtils';
import { getRouteMode } from '../../util/modeUtils';
import { configShape, legShape } from '../../util/shapes';
Expand Down Expand Up @@ -86,7 +86,7 @@ class ItineraryLine extends React.Component {
mode = 'CITYBIKE';
}

const modePlusClass = isCallAgencyPickupType(leg)
const modePlusClass = isCallAgencyLeg(leg)
? 'call'
: mode.toLowerCase() + (this.props.passive ? ' passive' : '');
const geometry = polyUtil.decode(leg.legGeometry.points);
Expand Down Expand Up @@ -117,7 +117,7 @@ class ItineraryLine extends React.Component {
color={leg.route && leg.route.color ? `#${leg.route.color}` : null}
key={`${this.props.hash}_${i}_${mode}`}
geometry={geometry}
mode={isCallAgencyPickupType(leg) ? 'call' : mode.toLowerCase()}
mode={isCallAgencyLeg(leg) ? 'call' : mode.toLowerCase()}
passive={this.props.passive}
/>,
);
Expand Down Expand Up @@ -188,7 +188,7 @@ class ItineraryLine extends React.Component {
end,
nextLeg,
index: i,
mode: isCallAgencyPickupType(leg) ? 'call' : mode.toLowerCase(),
mode: isCallAgencyLeg(leg) ? 'call' : mode.toLowerCase(),
legName: name,
zIndexOffset: 300,
interliningWithRoute,
Expand All @@ -205,7 +205,7 @@ class ItineraryLine extends React.Component {
platformCode: leg.from.stop.platformCode,
transfer: true,
}}
mode={isCallAgencyPickupType(leg) ? 'call' : mode.toLowerCase()}
mode={isCallAgencyLeg(leg) ? 'call' : mode.toLowerCase()}
renderText={leg.transitLeg && this.props.showTransferLabels}
/>,
);
Expand All @@ -220,7 +220,7 @@ class ItineraryLine extends React.Component {
platformCode: leg.to.stop.platformCode,
transfer: true,
}}
mode={isCallAgencyPickupType(leg) ? 'call' : mode.toLowerCase()}
mode={isCallAgencyLeg(leg) ? 'call' : mode.toLowerCase()}
renderText={leg.transitLeg && this.props.showTransferLabels}
/>,
);
Expand Down
7 changes: 2 additions & 5 deletions app/util/legUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@ function filterLegStops(leg, filter) {
return false;
}

export function isCallAgencyDeparture(departure) {
return departure.pickupType === 'CALL_AGENCY';
}

function sameBicycleNetwork(leg1, leg2) {
if (leg1.from.vehicleRentalStation && leg2.from.vehicleRentalStation) {
return (
Expand Down Expand Up @@ -126,8 +122,9 @@ export function getLegMode(legOrMode) {
* stop.gtfsId
* pickupType
*/
export function isCallAgencyPickupType(leg) {
export function isCallAgencyLeg(leg) {
return (
leg.route?.type === 715 ||
filterLegStops(leg, stoptime => stoptime.pickupType === 'CALL_AGENCY')
.length > 0
);
Expand Down

0 comments on commit 6c65caa

Please sign in to comment.