некорректное отображение данных в корзине
This commit is contained in:
parent
1a72d6d368
commit
1e1dd76b7b
@ -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,
|
||||||
order.sessions.filter { session ->
|
price = sessionFromCartRemote.session.price,
|
||||||
session.id == it.id &&
|
availableCount = sessionFromCartRemote.session.maxCount - service.getOrders()
|
||||||
session.dateTime == it.session.dateTime &&
|
.flatMap
|
||||||
session.cinemaId == it.session.cinemaId
|
{ order ->
|
||||||
}
|
order.sessions.filter { session ->
|
||||||
}.sumOf { session -> session.count }, cinema.toCinema()
|
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) {
|
override suspend fun insertUser(user: User) {
|
||||||
|
@ -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
|
||||||
@ -12,17 +10,4 @@ data class UserSessionWithSessionRemote(
|
|||||||
val sessionId: Int = 0,
|
val sessionId: Int = 0,
|
||||||
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
|
|
||||||
)
|
)
|
@ -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,
|
||||||
|
31004
server/data.json
31004
server/data.json
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user