From 4b84248c66a9b5898bfb13468b5e2f7351ef2c8b Mon Sep 17 00:00:00 2001 From: dasha Date: Wed, 20 Dec 2023 19:28:17 +0400 Subject: [PATCH] =?UTF-8?q?=D0=B7=D0=B0=D1=89=D0=B8=D1=82=D0=B0=20=D0=BE?= =?UTF-8?q?=D1=82=20=D0=BF=D1=80=D0=B8=D0=BA=D0=BE=D0=BB=D0=B8=D1=81=D1=82?= =?UTF-8?q?=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/com/example/myapplication/composeui/Cart.kt | 4 ++-- .../java/com/example/myapplication/composeui/CartViewModel.kt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) 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(),