некорректное отображение данных в корзине

This commit is contained in:
dasha 2023-12-19 21:51:03 +04:00
parent 1a72d6d368
commit 1e1dd76b7b
4 changed files with 25 additions and 31024 deletions

View File

@ -37,18 +37,26 @@ class RestUserRepository(
)
)
}
return cart.map {
val cinema = service.getCinema(it.session.cinemaId)
it.toSessionFromCart(
it.session.maxCount - service.getOrders().flatMap { order ->
order.sessions.filter { session ->
session.id == it.id &&
session.dateTime == it.session.dateTime &&
session.cinemaId == it.session.cinemaId
}
}.sumOf { session -> session.count }, cinema.toCinema()
val sessions = cart.map { sessionFromCartRemote ->
SessionFromCart(
uid = sessionFromCartRemote.sessionId,
dateTime = sessionFromCartRemote.session.dateTime,
price = sessionFromCartRemote.session.price,
availableCount = sessionFromCartRemote.session.maxCount - service.getOrders()
.flatMap
{ order ->
order.sessions.filter { session ->
session.id == sessionFromCartRemote.sessionId &&
session.cinemaId == sessionFromCartRemote.session.cinemaId &&
session.dateTime == sessionFromCartRemote.session.dateTime
}
}.sumOf { session -> session.count },
count = sessionFromCartRemote.count,
cinemaId = sessionFromCartRemote.session.cinemaId,
cinema = service.getCinema(sessionFromCartRemote.session.cinemaId).toCinema()
)
}
return sessions
}
override suspend fun insertUser(user: User) {

View File

@ -1,8 +1,6 @@
package com.example.myapplication.api.user
import com.example.myapplication.api.session.SessionRemote
import com.example.myapplication.database.entities.model.Cinema
import com.example.myapplication.database.entities.model.SessionFromCart
import kotlinx.serialization.Serializable
@Serializable
@ -12,17 +10,4 @@ data class UserSessionWithSessionRemote(
val sessionId: Int = 0,
val count: Int = 0,
val session: SessionRemote,
)
fun UserSessionWithSessionRemote.toSessionFromCart(
availableCount: Int = 0,
cinema: Cinema
): SessionFromCart = SessionFromCart(
sessionId,
session.dateTime,
session.price,
availableCount,
count,
session.cinemaId,
cinema
)

View File

@ -17,7 +17,6 @@ import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Add
import androidx.compose.material3.Button
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
@ -78,7 +77,6 @@ fun Cart(
)
}
@OptIn(ExperimentalMaterial3Api::class)
@Composable
private fun Cart(
cartUiState: CartUiState,

File diff suppressed because it is too large Load Diff