diff --git a/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/viewmodels/DeliveryViewModel.kt b/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/viewmodels/DeliveryViewModel.kt index b869e747..d48cd094 100644 --- a/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/viewmodels/DeliveryViewModel.kt +++ b/app/src/main/java/es/verdnatura/presentation/view/feature/delivery/viewmodels/DeliveryViewModel.kt @@ -5,7 +5,6 @@ import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.lifecycle.map import es.verdnatura.domain.SalixCallback -import es.verdnatura.domain.formatWithQuotes import es.verdnatura.presentation.base.BaseViewModel import es.verdnatura.presentation.common.Event import es.verdnatura.presentation.common.ResponseItemVO @@ -24,7 +23,6 @@ import es.verdnatura.presentation.view.feature.delivery.model.RouteDeliveryList import es.verdnatura.presentation.view.feature.delivery.model.RouteInfo import es.verdnatura.presentation.view.feature.delivery.model.RouteList import es.verdnatura.presentation.view.feature.delivery.model.Ticket -import es.verdnatura.presentation.view.feature.delivery.model.TicketObservation import okhttp3.MediaType import okhttp3.MultipartBody import okhttp3.RequestBody @@ -74,6 +72,11 @@ class DeliveryViewModel(val context: Context) : BaseViewModel(context) { private val _responseSign by lazy { MutableLiveData() } val responseSign: LiveData = _responseSign + private val _responseNotes by lazy { MutableLiveData() } + val responseNotes: LiveData = _responseNotes + var loadNotes: LiveData> = _responseNotes.map { Event(it) } + + private val _expeditionList by lazy { MutableLiveData() } val expeditionList: LiveData = _expeditionList @@ -176,12 +179,12 @@ class DeliveryViewModel(val context: Context) : BaseViewModel(context) { ] }""".trim() ).enqueue(object : SalixCallback>(context) { - override fun onSuccess(response: Response>) { + override fun onSuccess(response: Response>) { - _routeInfoList.value = response.body()?.let { RouteDeliveryList(it) } + _routeInfoList.value = response.body()?.let { RouteDeliveryList(it) } - } - }) + } + }) } @@ -299,23 +302,7 @@ class DeliveryViewModel(val context: Context) : BaseViewModel(context) { }) } - fun addNotes( - listTickets: MutableList, note: String - ) { - salix.addNote( - arrayListOf(listTickets[0].Id, note).formatWithQuotes() - ).enqueue(object : SalixCallback(context) {}) - } - - fun addNotesFromDropOff( - ticketObservation: TicketObservation - - ) { - salix.addNoteFromDropOff( - ticketObservation - ).enqueue(object : SalixCallback(context) {}) - } fun updateNotesFromDropOff( ticketFK: Long, description: String @@ -324,7 +311,29 @@ class DeliveryViewModel(val context: Context) : BaseViewModel(context) { salix.updateNoteFromDropOff( where = """{"ticketFk" : $ticketFK,"observationTypeFk":10}""", params = hashMapOf("description" to description) - ).enqueue(object : SalixCallback(context) {}) + ).enqueue(object : SalixCallback(context) { + override fun onSuccess(response: Response) { + _responseNotes.value = true + super.onSuccess(response) + + } + }) + } + + fun addFropOff( + ticketFK: Long, note: String + + ) { + salix.addFropOff( + ticketFK, note + + ).enqueue(object : SalixCallback(context) { + override fun onSuccess(response: Response) { + _responseNotes.value = true + super.onSuccess(response) + + } + }) } fun imageUpload(