From f76e0ff450a67f24980fd00cc00ef68b51296326 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D0=B0=D1=88=D0=B8=D0=BD=20=D0=9C=D0=B0=D0=BA=D1=81?= =?UTF-8?q?=D0=B8=D0=BC?= Date: Sat, 23 Dec 2023 02:04:02 +0400 Subject: [PATCH] =?UTF-8?q?=D0=92=D1=80=D0=BE=D0=B4=D0=B5=20=D1=80=D0=BE?= =?UTF-8?q?=D0=B1=D0=B8=D1=82,=20=D0=B4=D0=B0=D0=BB=D1=8C=D1=88=D0=B5=20?= =?UTF-8?q?=D0=B4=D0=BE=D0=BF=D0=B8=D0=BB=D0=B8=D0=B2=D0=B0=D0=B5=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle.kts | 2 - .../database/entities/composeui/ItemList.kt | 4 +- .../entities/composeui/ItemListViewModel.kt | 4 +- local.properties | 8 --- server/data.json | 62 ++++++++++++++++++- 5 files changed, 65 insertions(+), 15 deletions(-) delete mode 100644 local.properties diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 96251d9..add4282 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -96,6 +96,4 @@ dependencies { androidTestImplementation("androidx.compose.ui:ui-test-junit4") debugImplementation("androidx.compose.ui:ui-tooling") debugImplementation("androidx.compose.ui:ui-test-manifest") - - // } \ No newline at end of file diff --git a/app/src/main/java/com/example/myapplication/database/entities/composeui/ItemList.kt b/app/src/main/java/com/example/myapplication/database/entities/composeui/ItemList.kt index 2a556eb..410dead 100644 --- a/app/src/main/java/com/example/myapplication/database/entities/composeui/ItemList.kt +++ b/app/src/main/java/com/example/myapplication/database/entities/composeui/ItemList.kt @@ -52,7 +52,7 @@ fun ItemList( val bikeWithItems = bikeWithItemsViewModel.bikeUiState.bikeWithItems!! var getUser by remember { mutableStateOf(currentUserViewModel.user) } - Log.d("Удачи","${getUser?.uid}") + Log.d("Пожалуйста, работай","${getUser?.uid}") LazyColumn { if (bikeWithItems.items.isEmpty()) { @@ -118,7 +118,7 @@ fun ItemList( onClick = { coroutineScope.launch { if (item.availableCount != 0) { - viewModel.addItemInCart(itemId = item.uid) + getUser?.uid?.let { viewModel.addItemInCart(userId = it,itemId = item.uid) } } } }, diff --git a/app/src/main/java/com/example/myapplication/database/entities/composeui/ItemListViewModel.kt b/app/src/main/java/com/example/myapplication/database/entities/composeui/ItemListViewModel.kt index a50d95b..d700c3f 100644 --- a/app/src/main/java/com/example/myapplication/database/entities/composeui/ItemListViewModel.kt +++ b/app/src/main/java/com/example/myapplication/database/entities/composeui/ItemListViewModel.kt @@ -23,9 +23,9 @@ class ItemListViewModel( ) } - suspend fun addItemInCart(itemId: Int, count: Int = 1) { + suspend fun addItemInCart(userId: Int, itemId: Int, count: Int = 1) { try { - userItemRepository.insertUserItem(UserItemCrossRef(1, itemId, count)) + userItemRepository.insertUserItem(UserItemCrossRef(userId, itemId, count)) } catch (_: Exception) { } diff --git a/local.properties b/local.properties deleted file mode 100644 index 929b9c0..0000000 --- a/local.properties +++ /dev/null @@ -1,8 +0,0 @@ -## This file must *NOT* be checked into Version Control Systems, -# as it contains information specific to your local configuration. -# -# Location of the SDK. This is only used by Gradle. -# For customization when using a Version Control System, please read the -# header note. -#Wed Dec 20 12:58:59 MSK 2023 -sdk.dir=C\:\\Users\\Maxim\\AppData\\Local\\Android\\Sdk diff --git a/server/data.json b/server/data.json index 40fa28d..ab5cdff 100644 --- a/server/data.json +++ b/server/data.json @@ -7,7 +7,7 @@ "items": [ { "id": 1, - "count": 1, + "count": 3, "bikeId": 1 }, { @@ -73,6 +73,66 @@ "bikeId": 1 } ] + }, + { + "id": 3, + "userId": 7, + "items": [ + { + "id": 1, + "dateTime": 2021, + "frozenWeight": 26.6, + "count": 2, + "bikeId": 1 + }, + { + "id": 4, + "dateTime": 2023, + "frozenWeight": 26.3, + "count": 1, + "bikeId": 2 + } + ] + }, + { + "id": 4, + "userId": 7, + "items": [ + { + "id": 1, + "dateTime": 2021, + "frozenWeight": 26.6, + "count": 2, + "bikeId": 1 + }, + { + "id": 4, + "dateTime": 2023, + "frozenWeight": 26.3, + "count": 1, + "bikeId": 2 + } + ] + }, + { + "id": 5, + "userId": 7, + "items": [ + { + "id": 1, + "dateTime": 2021, + "frozenWeight": 26.6, + "count": 3, + "bikeId": 1 + }, + { + "id": 4, + "dateTime": 2023, + "frozenWeight": 26.3, + "count": 1, + "bikeId": 2 + } + ] } ], "items": [