Skip to content

Commit

Permalink
Merge pull request #389 from HSLdevcom/timetables-column-fix
Browse files Browse the repository at this point in the history
StopPoster timetables column fix
  • Loading branch information
ahjyrkia authored Nov 2, 2023
2 parents ab41ab2 + 49a4b5f commit fd17a6b
Showing 1 changed file with 30 additions and 10 deletions.
40 changes: 30 additions & 10 deletions src/components/timetable/timetableContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -368,18 +368,38 @@ const propsMapper = mapProps(props => {
saturdays,
sundays,
} = groupDeparturesByDay(departures);
const combinedDays = combineConsecutiveDays({
mondays,
tuesdays,
wednesdays,
thursdays,
fridays,
saturdays,
sundays,
});
const segmentMap = {
weekdays: 'mondays-fridays',
saturdays: 'saturdays',
sundays: 'sundays',
};

const combinedDays = (() => {
if (props.segments.length > 0) {
const result = {};
const groupedDepartures = groupDepartures(departures);
const pickedDepartures = pick(groupedDepartures, props.segments);

for (const segment of props.segments) {
if (segmentMap[segment]) {
result[segmentMap[segment]] = pickedDepartures[segment];
}
}

return result;
}
return combineConsecutiveDays({
mondays,
tuesdays,
wednesdays,
thursdays,
fridays,
saturdays,
sundays,
});
})();

return {
weekdays,
saturdays,
sundays,
combinedDays,
Expand Down

0 comments on commit fd17a6b

Please sign in to comment.