diff --git a/app/src/main/java/com/example/myapplication/composeui/Cart.kt b/app/src/main/java/com/example/myapplication/composeui/Cart.kt index 8f8f2a7..c21d62c 100644 --- a/app/src/main/java/com/example/myapplication/composeui/Cart.kt +++ b/app/src/main/java/com/example/myapplication/composeui/Cart.kt @@ -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) } diff --git a/app/src/main/java/com/example/myapplication/composeui/CartViewModel.kt b/app/src/main/java/com/example/myapplication/composeui/CartViewModel.kt index 5a06de8..fd83093 100644 --- a/app/src/main/java/com/example/myapplication/composeui/CartViewModel.kt +++ b/app/src/main/java/com/example/myapplication/composeui/CartViewModel.kt @@ -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(),