Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ddfform 802 sort openning hours #1247

Merged
merged 2 commits into from
Jun 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions src/apps/opening-hours/OpeningHoursHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,19 @@ export const groupOpeningHoursByWeekday = (
const daysWithOpeningHours: GroupedOpeningHours = allDays.map((day) => {
return {
dateTime: day,
date: day,
openingHourEntries: openingHours.filter((individualOpeningHour) =>
dayjs(individualOpeningHour.date).isSame(day, "day")
)
openingHourEntries: openingHours
.filter((individualOpeningHour) =>
dayjs(individualOpeningHour.date).isSame(day, "day")
)
.sort((a, b) => {
// The array is primarily sorted by the start_time property of each object.
const startTimeComparison = a.start_time.localeCompare(b.start_time);
if (startTimeComparison !== 0) {
return startTimeComparison;
}
// If two objects have the same start_time, they are then sorted by the end_time property.
return a.end_time.localeCompare(b.end_time);
})
};
});

Expand Down
Loading