Skip to content

Commit

Permalink
Merge pull request #390 from HSLdevcom/timetables-hotfix
Browse files Browse the repository at this point in the history
Timetable columns hotfix
  • Loading branch information
ahjyrkia authored Nov 6, 2023
2 parents 02de6ad + d76cf5d commit 020f6cf
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 11 deletions.
2 changes: 0 additions & 2 deletions src/components/timetable/timetable.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,6 @@ class Timetable extends Component {
}

Timetable.defaultProps = {
weekdays: null,
saturdays: null,
sundays: null,
isSummerTimetable: false,
Expand All @@ -225,7 +224,6 @@ Timetable.defaultProps = {
};

Timetable.propTypes = {
weekdays: PropTypes.arrayOf(PropTypes.shape(TableRows.propTypes.departures)),
saturdays: PropTypes.arrayOf(PropTypes.shape(TableRows.propTypes.departures)),
sundays: PropTypes.arrayOf(PropTypes.shape(TableRows.propTypes.departures)),
notes: PropTypes.arrayOf(PropTypes.string.isRequired).isRequired,
Expand Down
39 changes: 30 additions & 9 deletions src/components/timetable/timetableContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -368,15 +368,36 @@ 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,
Expand Down

0 comments on commit 020f6cf

Please sign in to comment.