refs #6531 feat:last tickets

This commit is contained in:
Sergio De la torre 2024-02-27 09:40:45 +01:00
parent 9bf43e6dd0
commit 256f449630
2 changed files with 8 additions and 5 deletions

View File

@ -48,7 +48,7 @@ class ShowTicketFragment(var menuOrigin: String) :
}
setEvents()
//Tarea 6531
// viewModel.lastTicketGetByWorker(mobileApplication.userId!!)
viewModel.myLastTickets(mobileApplication.userId!!)
super.init()
}
@ -71,7 +71,7 @@ class ShowTicketFragment(var menuOrigin: String) :
binding.sacadorSwipe.setOnRefreshListener {
binding.sacadorSwipe.isRefreshing = true
//Tarea 6531
// viewModel.lastTicketGetByWorker(mobileApplication.userId!!)
viewModel.myLastTickets(mobileApplication.userId!!)
binding.sacadorSwipe.isRefreshing = false
}

View File

@ -1,6 +1,8 @@
package es.verdnatura.presentation.view.feature.precontrol
import android.content.Context
import android.os.Build
import androidx.annotation.RequiresApi
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import es.verdnatura.domain.SalixCallback
@ -53,11 +55,12 @@ class ShowTicketViewModel(val context: Context) : BaseViewModel(context) {
})
}
fun lastTicketGetByWorker(userId: Int) {
salix.lastTicketGetByWorker("""{"where": {"userFk": $userId},"order":"updated DESC","limit": 5}""")
fun myLastTickets(userId: Int) {
salix.myLastModified("""{"where": {"userFk": $userId}""")
.enqueue(object : SalixCallback<List<TicketStateSalix>>(context) {
@RequiresApi(Build.VERSION_CODES.O)
override fun onSuccess(response: Response<List<TicketStateSalix>>) {
_lastTicketList.value = response.body()?.let { TicketStateList(it) }
_lastTicketList.value = response.body()?.let { TicketStateList(it.sortedByDescending { it.created }) }
}
})