feat: refs #8020 controlVehiculos

This commit is contained in:
Sergio De la torre 2024-10-29 08:59:33 +01:00
parent 8cecd276b0
commit ccf56fdebf
2 changed files with 7 additions and 26 deletions

View File

@ -52,7 +52,7 @@ class ControlVehiculoUsuarioFragment(
if (userFk == vUserFK) {
val androidId: String = mobileApplication.dataStoreApp.readDataStoreKey(ANDROID_ID)
viewModel.machineGetWorkerPlate(mobileApplication.userId!!)
// viewModel.machineGetWorkerPlate(mobileApplication.userId!!)
viewModel.deviceProductionGetnameDevice(
androidId
)
@ -64,7 +64,8 @@ class ControlVehiculoUsuarioFragment(
binding.userInformation.visibility = INVISIBLE
binding.nameVehiclecontrol.visibility = INVISIBLE
binding.userImage.setOnClickListener { binding.mainToolbar.backButton.performClick() }
viewModel.machineGetWorkerPlate(mobileApplication.userId!!)
// viewModel.machineGetWorkerPlate(mobileApplication.userId!!)
binding.nameVehiclecontrol.visibility = VISIBLE
viewModel.getNameWorker(userFk)
}

View File

@ -108,35 +108,15 @@ class ControlVehiculoViewModel(val context: Context) : BaseViewModel(context) {
})
}
fun machineGetWorkerPlate(userId: Int) {
salix.machineGetWorkerPlate(
arrayListOf(userId)
).enqueue(object : SalixCallback<List<JsonObject>>(context) {
override fun onSuccess(response: Response<List<JsonObject>>) {
_responseMachine.value =
ResponseItemMachineControl(
response = if (response.body()!!.isEmpty()) {
""
} else {
response.body()!![0].entrySet().first().value.toString()
.replace("\"", "")
},
type = "getWorkerPlate"
)
}
})
}
fun getNameWorker(
workerId: Int
) {
salix.getNameWorker(
"""{"fields": ["firstName","lastName"],"where": {"id":$workerId}}"""
).enqueue(object : SalixCallback<NameWorker>(context) {
"""{"limit":1, "where":{"id":$workerId},"skip":0,"fields":["firstName","lastName"]}"""
).enqueue(object : SalixCallback<List<NameWorker>>(context) {
override fun onSuccess(response: Response<NameWorker>) {
_responseGetName.value = response.body()
override fun onSuccess(response: Response<List<NameWorker>>) {
_responseGetName.value = response.body()?.get(0)
}
})