Skip to content

Commit

Permalink
Update order status with agrodealer ID respectively (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
MuindiStephen committed Sep 24, 2024
1 parent 812cf78 commit 68684f1
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ class FarmCycleRepository @Inject constructor(
return ordersDao.getSpecificOrdersForAgroDealerID(agrodealerId)
}

suspend fun updateOrderStatus(newStatus: String) {
ordersDao.updateOrderStatus(newStatus)
suspend fun updateOrderStatus(newStatus: String, agrodealerId: String) {
ordersDao.updateOrderStatus(newStatus, agrodealerId)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ interface OrdersDao {
@Query("SELECT * FROM orders WHERE agrodealerID =:agrodealerID")
fun getSpecificOrdersForAgroDealerID(agrodealerID: String): LiveData<List<OrderCheckoutByFarmer>>

@Query("UPDATE orders SET orderStatus = :newOrderStatus")
suspend fun updateOrderStatus(newOrderStatus: String)
@Query("UPDATE orders SET orderStatus = :newOrderStatus WHERE agrodealerID =:agrodealerID")
suspend fun updateOrderStatus(newOrderStatus: String, agrodealerID: String)
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class AgroDealerViewOrderListItemsInDetailFragment : Fragment() {
}

val orderDetails = args.orderInDetailAgroDealer
val agrodealerId = args.orderInDetailAgroDealer.agrodealerID

orderDetails.let {
orderDetailsAdapter.submitList(it.cartOrder)
Expand All @@ -56,8 +57,9 @@ class AgroDealerViewOrderListItemsInDetailFragment : Fragment() {
adapter = orderDetailsAdapter
}

// Update order status with respect to the agrodealer ID
btnChangeStatusOrders.setOnClickListener {
viewModel.updateOrderStatus("Approved")
viewModel.updateOrderStatus("Approved", agrodealerId )
displaySnackBar("Order Approved.")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,8 @@ class MainViewModel @Inject constructor(
}
}

fun updateOrderStatus(newStatus: String) = viewModelScope.launch {
repository.updateOrderStatus(newStatus)
fun updateOrderStatus(newStatus: String, agroDealerId: String) = viewModelScope.launch {
repository.updateOrderStatus(newStatus, agroDealerId)
}

}
Expand Down

0 comments on commit 68684f1

Please sign in to comment.