защита от приколистов

This commit is contained in:
dasha 2023-12-20 19:28:17 +04:00
parent 39f2cf609c
commit 4b84248c66
2 changed files with 3 additions and 3 deletions

View File

@ -193,7 +193,7 @@ private fun SessionListItem(
Text(
text = "${session.cinema.name}, ${session.cinema.year}\n" +
"Цена: ${session.price}\n" +
if (session.availableCount == 0) "Недоступно" else "${session.count}/${session.availableCount}",
if (session.availableCount <= 0) "Недоступно" else "${session.count}/${session.availableCount}",
color = MaterialTheme.colorScheme.onSecondary
)
}
@ -219,7 +219,7 @@ private fun SessionListItem(
Spacer(modifier = Modifier.weight(1F))
if (session.availableCount != 0) {
if (session.availableCount > 0) {
IconButton(
enabled = session.count != 1,
onClick = { onChangeCount(session, session.count - 1) }

View File

@ -51,7 +51,7 @@ class CartViewModel(
actionSuccess = {
val orderId = orderRepository.insertOrder(Order(0, userId, LocalDateTime.now()))
cart.forEach { session ->
if (session.availableCount != 0) {
if (session.availableCount > 0) {
orderSessionRepository.insertOrderSession(
OrderSessionCrossRef(
orderId.toInt(),