Sortuj kursy kierowcy według dnia

This commit is contained in:
admin
2026-07-10 21:31:17 +02:00
parent e49e7c358e
commit f9c3a2e305
4 changed files with 31 additions and 2 deletions
@@ -245,6 +245,8 @@ data class DriverRouteDto(
val id: String,
val routeDate: String? = null,
val unloadingDate: String? = null,
val ordering: Int? = null,
val dayOrderings: Map<String, Int>? = emptyMap(),
val startsAt: String,
val originName: String,
val destinationName: String,
@@ -66,6 +66,9 @@ fun routeIsActiveToday(
fun routeUnloadingDate(route: DriverRouteDto): String? = route.unloadingDate ?: route.routeDate
fun routeDayOrdering(route: DriverRouteDto, date: String): Int =
route.dayOrderings?.get(date) ?: route.ordering ?: Int.MAX_VALUE
fun routeScheduleDateLabel(date: String?): String =
date
?.let { runCatching { LocalDate.parse(it).format(shortDateFormatter) }.getOrNull() }
@@ -96,7 +96,10 @@ data class DriverUiState(
val displayRoutes: List<DriverRouteDto>
get() = projectDriverRoutes(routes, projectionActions)
.sortedBy { route -> if (route.status == "ZAKOŃCZONA") 1 else 0 }
.sortedWith(
compareBy<DriverRouteDto> { route -> if (route.status == "ZAKOŃCZONA") 1 else 0 }
.thenBy { route -> routeDayOrdering(route, selectedDate) },
)
val selectedRouteProjection: ProjectedDriverRoute?
get() = selectedRoute?.let { projectDriverRoute(it, projectionActions) }