Skip to content

Commit

Permalink
Merge pull request #5084 from HSLdevcom/lahti-ticketlink
Browse files Browse the repository at this point in the history
Ticket link testing for Lahti
  • Loading branch information
vesameskanen authored Oct 9, 2024
2 parents a0ce97f + 83ea6cd commit 5c2125f
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 14 deletions.
5 changes: 4 additions & 1 deletion app/component/itinerary/MobileTicketPurchaseInformation.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ export default function MobileTicketPurchaseInformation(
{faresInfo()}
<div className="app-link">
<ExternalLink
href={config.ticketPurchaseLink(fare)}
href={config.ticketPurchaseLink(
fare,
config.ticketLinkOperatorCode,
)}
onClick={() =>
addAnalyticsEvent({ event: 'journey_planner_open_app' })
}
Expand Down
1 change: 1 addition & 0 deletions app/configurations/config.hsl.js
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ export default {
return `https://open.app.hsl.fi/zoneTicketWizard/TICKET_TYPE_SINGLE_TICKET/${fare.ticketName}/adult/-`;
},
ticketLink: 'https://open.app.hsl.fi/tickets',
ticketLinkOperatorCode: 'hsl',
// mapping fareId from OTP fare identifiers to human readable form
// in the new HSL zone model, just strip off the prefix 'HSL:'
fareMapping: function mapHslFareId(fareId) {
Expand Down
14 changes: 1 addition & 13 deletions app/configurations/config.jyvaskyla.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,19 +172,7 @@ export default configMerger(walttiConfig, {
includeBikeSuggestions: false,
transferPenalty: 1600,
},

ticketPurchaseLink: function purchaseTicketLink(fare) {
const fareId = fare.fareProducts[0].product.id;
const ticket = fareId?.substring
? fareId.substring(fareId.indexOf(':') + 1)
: '';
let zones = '';
// Waltti wants zone ids, so map A to 01, B to 02 etc
for (let i = 0; i < ticket.length; i++) {
zones += `0${ticket.charCodeAt(i) - 64}`; // eslint-disable
}
return `https://waltti.fi/walttiapp/busTicket/?operator=50209&ticketType=single&customerGroup=adult&zones=${zones}`;
},
ticketLinkOperatorCode: 50209,

fareMapping: function mapFareId(fareId) {
const id = fareId?.substring?.(fareId.indexOf(':') + 1);
Expand Down
42 changes: 42 additions & 0 deletions app/configurations/config.lahti.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,4 +172,46 @@ export default configMerger(walttiConfig, {
},
},
},

showTicketInformation: true,
useTicketIcons: true,
ticketLink: 'https://www.lsl.fi/liput-ja-hinnat/',
showTicketPrice: true,

showTicketLinkOnlyWhenTesting: true,
settingsForFeatureTesting: {
walkSpeed: 0.69,
bikeSpeed: 8.33,
includeBikeSuggestions: false,
transferPenalty: 1600,
},
ticketLinkOperatorCode: 50223,

fareMapping: function mapFareId(fareId) {
const id = fareId?.substring?.(fareId.indexOf(':') + 1);
switch (id) {
case 'A':
return 'Käteismaksu autossa, Vyöhyke A';
case 'AB':
return 'Käteismaksu autossa, Vyöhykkeet AB';
case 'ABC':
return 'Käteismaksu autossa, Vyöhykkeet ABC';
case 'ABCD':
return 'Käteismaksu autossa, Vyöhykkeet ABCD';
case 'B':
return 'Käteismaksu autossa, Vyöhyke B';
case 'BC':
return 'Käteismaksu autossa, Vyöhykkeet BC';
case 'BCD':
return 'Käteismaksu autossa, Vyöhykkeet BCD';
case 'C':
return 'Käteismaksu autossa, Vyöhyke C';
case 'CD':
return 'Käteismaksu autossa, Vyöhykkeet CD';
case 'D':
return 'Käteismaksu autossa, Vyöhyke D';
default:
return '';
}
},
});
13 changes: 13 additions & 0 deletions app/configurations/config.waltti.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,4 +264,17 @@ export default {
value: 600,
},
],

ticketPurchaseLink: function purchaseTicketLink(fare, operatorCode) {
const fareId = fare.fareProducts[0].product.id;
const ticket = fareId?.substring
? fareId.substring(fareId.indexOf(':') + 1)
: '';
let zones = '';
// Waltti wants zone ids, so map A to 01, B to 02 etc
for (let i = 0; i < ticket.length; i++) {
zones += `0${ticket.charCodeAt(i) - 64}`; // eslint-disable
}
return `https://waltti.fi/walttiapp/busTicket/?operator=${operatorCode}&ticketType=single&customerGroup=adult&zones=${zones}`;
},
};
1 change: 1 addition & 0 deletions app/util/fareUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ export const shouldShowFarePurchaseInfo = (config, breakpoint, fares) => {
!unknownFares &&
fares?.length === 1 &&
config.ticketPurchaseLink &&
config.ticketLinkOperatorCode &&
breakpoint !== 'large'
);
};

0 comments on commit 5c2125f

Please sign in to comment.