Вроде робит, дальше допиливаем

This commit is contained in:
Кашин Максим 2023-12-23 02:04:02 +04:00
parent 37f2701ce7
commit f76e0ff450
5 changed files with 65 additions and 15 deletions

View File

@ -96,6 +96,4 @@ dependencies {
androidTestImplementation("androidx.compose.ui:ui-test-junit4") androidTestImplementation("androidx.compose.ui:ui-test-junit4")
debugImplementation("androidx.compose.ui:ui-tooling") debugImplementation("androidx.compose.ui:ui-tooling")
debugImplementation("androidx.compose.ui:ui-test-manifest") debugImplementation("androidx.compose.ui:ui-test-manifest")
//
} }

View File

@ -52,7 +52,7 @@ fun ItemList(
val bikeWithItems = bikeWithItemsViewModel.bikeUiState.bikeWithItems!! val bikeWithItems = bikeWithItemsViewModel.bikeUiState.bikeWithItems!!
var getUser by remember { mutableStateOf(currentUserViewModel.user) } var getUser by remember { mutableStateOf(currentUserViewModel.user) }
Log.d("Удачи","${getUser?.uid}") Log.d("Пожалуйста, работай","${getUser?.uid}")
LazyColumn { LazyColumn {
if (bikeWithItems.items.isEmpty()) { if (bikeWithItems.items.isEmpty()) {
@ -118,7 +118,7 @@ fun ItemList(
onClick = { onClick = {
coroutineScope.launch { coroutineScope.launch {
if (item.availableCount != 0) { if (item.availableCount != 0) {
viewModel.addItemInCart(itemId = item.uid) getUser?.uid?.let { viewModel.addItemInCart(userId = it,itemId = item.uid) }
} }
} }
}, },

View File

@ -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 { try {
userItemRepository.insertUserItem(UserItemCrossRef(1, itemId, count)) userItemRepository.insertUserItem(UserItemCrossRef(userId, itemId, count))
} catch (_: Exception) { } catch (_: Exception) {
} }

View File

@ -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

View File

@ -7,7 +7,7 @@
"items": [ "items": [
{ {
"id": 1, "id": 1,
"count": 1, "count": 3,
"bikeId": 1 "bikeId": 1
}, },
{ {
@ -73,6 +73,66 @@
"bikeId": 1 "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": [ "items": [