Skip to content

Commit

Permalink
Merge pull request #4939 from HSLdevcom/DT-6225
Browse files Browse the repository at this point in the history
DT-6225: Use transferPenalty to avoid transfers
  • Loading branch information
vesameskanen authored Jan 30, 2024
2 parents db4cde8 + 2ff73de commit 9d293dd
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion app/component/CustomizeSearchNew.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class CustomizeSearch extends React.Component {
<TransferOptionsSection
defaultSettings={this.defaultSettings}
currentSettings={currentSettings}
walkBoardCostHigh={config.walkBoardCostHigh}
transferPenaltyHigh={config.transferPenaltyHigh}
/>
</div>
</div>
Expand Down
13 changes: 7 additions & 6 deletions app/component/customizesearch/TransferOptionsSection.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import { saveRoutingSettings } from '../../action/SearchSettingsActions';
import { addAnalyticsEvent } from '../../util/analyticsUtils';

const TransferOptionsSection = (
{ defaultSettings, walkBoardCostHigh, currentSettings },
{ defaultSettings, transferPenaltyHigh, currentSettings },
{ executeAction },
) => {
const avoidTransfers =
currentSettings.walkBoardCost !== defaultSettings.walkBoardCost;
currentSettings.transferPenalty !== defaultSettings.transferPenalty;
return (
<div className="mode-option-container toggle-container avoid-transfers-container">
<label htmlFor="settings-toggle-transfers" className="settings-header">
Expand All @@ -23,9 +23,9 @@ const TransferOptionsSection = (
toggled={avoidTransfers}
onToggle={() => {
executeAction(saveRoutingSettings, {
walkBoardCost: avoidTransfers
? defaultSettings.walkBoardCost
: walkBoardCostHigh,
transferPenalty: avoidTransfers
? defaultSettings.transferPenalty
: transferPenaltyHigh,
});
addAnalyticsEvent({
category: 'ItinerarySettings',
Expand All @@ -43,9 +43,10 @@ const TransferOptionsSection = (
TransferOptionsSection.propTypes = {
defaultSettings: PropTypes.shape({
walkBoardCost: PropTypes.number.isRequired,
transferPenalty: PropTypes.number.isRequired,
}).isRequired,
currentSettings: PropTypes.object.isRequired,
walkBoardCostHigh: PropTypes.number.isRequired,
transferPenaltyHigh: PropTypes.number.isRequired,
};

TransferOptionsSection.contextTypes = {
Expand Down
3 changes: 2 additions & 1 deletion app/configurations/config.default.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ export default {
walkBoardCost: 120,
walkReluctance: 1.8,
walkSpeed: 1.2,
transferPenalty: 0,
includeBikeSuggestions: true,
includeParkAndRideSuggestions: false,
includeCarSuggestions: false,
Expand All @@ -216,7 +217,7 @@ export default {
bikeSpeed: [2.77, 4.15, 5.55, 6.94, 8.33],
},

walkBoardCostHigh: 1600,
transferPenaltyHigh: 1600,

suggestWalkMaxDistance: 10000,
suggestBikeMaxDistance: 30000,
Expand Down
4 changes: 4 additions & 0 deletions app/store/localStorage.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ export function setCustomizedSettings(data) {
data.walkBoardCost,
oldSettings.walkBoardCost,
),
transferPenalty: getNumberValueOrDefault(
data.transferPenalty,
oldSettings.transferPenalty,
),
walkReluctance: getNumberValueOrDefault(
data.walkReluctance,
oldSettings.walkReluctance,
Expand Down

0 comments on commit 9d293dd

Please sign in to comment.