Skip to content

Commit

Permalink
Merge pull request #5291 from HSLdevcom/DT-6738
Browse files Browse the repository at this point in the history
DT-6738 Pori: hide ticket link for specific routes
  • Loading branch information
vesameskanen authored Mar 6, 2025
2 parents 4e90d4b + 007a3c9 commit f69f7f8
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 3 deletions.
9 changes: 7 additions & 2 deletions app/component/itinerary/ItineraryDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ class ItineraryDetails extends React.Component {
isMobile={isMobile}
hideBottomDivider={
isMobile &&
shouldShowFarePurchaseInfo(config, breakpoint, fares)
shouldShowFarePurchaseInfo(config, breakpoint, fares, itinerary)
}
/>,
showRentalBikeDurationWarning && (
Expand All @@ -305,7 +305,12 @@ class ItineraryDetails extends React.Component {
/>
),
shouldShowFareInfo(config) &&
(shouldShowFarePurchaseInfo(config, breakpoint, fares) ? (
(shouldShowFarePurchaseInfo(
config,
breakpoint,
fares,
itinerary,
) ? (
<MobileTicketPurchaseInformation
key="mobileticketpurchaseinformation"
fares={fares}
Expand Down
11 changes: 11 additions & 0 deletions app/configurations/config.pori.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,4 +170,15 @@ export default configMerger(walttiConfig, {
showTicketPrice: true,
showTicketLinkOnlyWhenTesting: true,
ticketLinkOperatorCode: 50231,
externalFareRoutes: [
'301',
'302',
'303',
'320',
'321',
'1001',
'1011',
'1021',
'1041',
],
});
18 changes: 17 additions & 1 deletion app/util/fareUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,12 @@ export const shouldShowFareInfo = config =>
Array.isArray(config.feedIds) &&
config.feedIds.some(feedId => config.availableTickets[feedId]);

export const shouldShowFarePurchaseInfo = (config, breakpoint, fares) => {
export const shouldShowFarePurchaseInfo = (
config,
breakpoint,
fares,
itinerary,
) => {
const unknownFares = fares?.some(fare => fare.isUnknown);
// Windows phones or Huawei should only show ticket information.
const { userAgent } = navigator;
Expand All @@ -110,6 +115,17 @@ export const shouldShowFarePurchaseInfo = (config, breakpoint, fares) => {
if (huaweiPattern.test(userAgent) || windowsPattern.test(userAgent)) {
return false;
}

if (
config.externalFareRoutes &&
itinerary?.legs?.some(
leg =>
leg.route && config.externalFareRoutes.includes(leg.route.shortName),
)
) {
return false;
}

return (
!unknownFares &&
fares?.length === 1 &&
Expand Down

0 comments on commit f69f7f8

Please sign in to comment.