diff --git a/frontend/app_student/.run/main_prod.run.xml b/frontend/app_student/.run/main_prod.run.xml deleted file mode 100644 index 7a31433..0000000 --- a/frontend/app_student/.run/main_prod.run.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file diff --git a/frontend/app_student/lib/week_schedule/cubit/week_schedule_cubit.dart b/frontend/app_student/lib/week_schedule/cubit/week_schedule_cubit.dart index 8584283..0401094 100644 --- a/frontend/app_student/lib/week_schedule/cubit/week_schedule_cubit.dart +++ b/frontend/app_student/lib/week_schedule/cubit/week_schedule_cubit.dart @@ -50,19 +50,27 @@ class WeekScheduleCubit extends Cubit { } } - DateTime findClosestDate(List allEvents) { - // Sort the schedules by date - allEvents.sort((a, b) => a.date.compareTo(b.date)); + DateTime findClosestDate(List daySchedules) { + DateTime currentDate = DateTime.now(); - // Find the schedule with the date closest to today - for (var schedule in allEvents) { - if (schedule.date.isAfter(DateTime.now()) || - schedule.date.isAtSameMomentAs(DateTime.now())) { - return schedule.date; + for (var day in daySchedules) { + if (day.date == currentDate) { + currentDate = day.date; + return currentDate; + } else { + try { + var nextDayWithEvent = daySchedules.firstWhere( + (daySchedule) => daySchedule.date.isAfter(currentDate)); + currentDate = nextDayWithEvent.date; + return currentDate; + } catch (e) { + // No next day with an event found, continue to the next day + continue; + } } } - return DateTime.now(); + return currentDate; } int findTodayIndex(List allEvents) {