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

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 sessions = cart.map { sessionFromCartRemote ->
val cinema = service.getCinema(it.session.cinemaId) SessionFromCart(
it.toSessionFromCart( uid = sessionFromCartRemote.sessionId,
it.session.maxCount - service.getOrders().flatMap { order -> dateTime = sessionFromCartRemote.session.dateTime,
price = sessionFromCartRemote.session.price,
availableCount = sessionFromCartRemote.session.maxCount - service.getOrders()
.flatMap
{ order ->
order.sessions.filter { session -> order.sessions.filter { session ->
session.id == it.id && session.id == sessionFromCartRemote.sessionId &&
session.dateTime == it.session.dateTime && session.cinemaId == sessionFromCartRemote.session.cinemaId &&
session.cinemaId == it.session.cinemaId session.dateTime == sessionFromCartRemote.session.dateTime
} }
}.sumOf { session -> session.count }, cinema.toCinema() }.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) { override suspend fun insertUser(user: User) {

View File

@ -1,8 +1,6 @@
package com.example.myapplication.api.user package com.example.myapplication.api.user
import com.example.myapplication.api.session.SessionRemote 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 import kotlinx.serialization.Serializable
@Serializable @Serializable
@ -13,16 +11,3 @@ data class UserSessionWithSessionRemote(
val count: Int = 0, val count: Int = 0,
val session: SessionRemote, 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.Icons
import androidx.compose.material.icons.filled.Add import androidx.compose.material.icons.filled.Add
import androidx.compose.material3.Button import androidx.compose.material3.Button
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme import androidx.compose.material3.MaterialTheme
@ -78,7 +77,6 @@ fun Cart(
) )
} }
@OptIn(ExperimentalMaterial3Api::class)
@Composable @Composable
private fun Cart( private fun Cart(
cartUiState: CartUiState, cartUiState: CartUiState,

File diff suppressed because it is too large Load Diff