fix: 🐛 Felaktig sortering av lektioner (#595)

* fix: 🐛 incorrect sorting of lessons in timetable

 Closes: #591

* fix: 🐛 end time when overlapping lessons

* style: 💄 lint
This commit is contained in:
Kajetan Kazimierczak 2021-12-10 21:07:29 +01:00 committed by GitHub
parent 69e21ac68f
commit ed3a27bba1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View File

@ -32,7 +32,7 @@ export const DaySummary = ({
const lessons = weekLessons
.filter((lesson) => lesson.dayOfWeek === currentDate.isoWeekday())
.sort((a, b) => a.dateStart.localeCompare(b.dateStart))
.sort((a, b) => a.timeStart.localeCompare(b.timeStart))
if (lessons.length <= 0) {
return null
@ -62,7 +62,9 @@ export const DaySummary = ({
{translate('schedule.end')}
</Text>
<Text category="h5">
{lessons[lessons.length - 1].timeEnd.slice(0, 5)}
{lessons
.sort((a, b) => a.timeEnd.localeCompare(b.timeEnd))
[lessons.length - 1].timeEnd.slice(0, 5)}
</Text>
</View>
</View>

View File

@ -169,7 +169,7 @@ export const Week = ({ child }: WeekProps) => {
lunch={menu[index] || {}}
lessons={lessons
.filter((lesson) => days[lesson.dayOfWeek - 1] === weekDay)
.sort((a, b) => a.dateStart.localeCompare(b.dateStart))}
.sort((a, b) => a.timeStart.localeCompare(b.timeStart))}
/>
))}
</ViewPager>