Added Blood group pop up dialog in user card
This commit is contained in:
@@ -156,8 +156,13 @@ class UserListAdapter(
|
|||||||
|
|
||||||
builder.setPositiveButton("OK") { dialog, which ->
|
builder.setPositiveButton("OK") { dialog, which ->
|
||||||
val bloodGroup = etBloodGroup.text.toString()
|
val bloodGroup = etBloodGroup.text.toString()
|
||||||
if (bloodGroup.isEmpty()) {
|
if (bloodGroup.equals("Select Blood Group") || bloodGroup.isNullOrBlank()) {
|
||||||
etBloodGroup.error = "Please enter your blood group"
|
etBloodGroup.error = "Please enter your blood group"
|
||||||
|
Toast.makeText(
|
||||||
|
context,
|
||||||
|
"Please enter your blood group",
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
} else {
|
} else {
|
||||||
// Check if hemoCubeViewModel and testDetails are not null
|
// Check if hemoCubeViewModel and testDetails are not null
|
||||||
val testDetails = hemoCubeViewModel.testDetails
|
val testDetails = hemoCubeViewModel.testDetails
|
||||||
@@ -167,9 +172,17 @@ class UserListAdapter(
|
|||||||
.whereEqualTo("_id", testDetails?._id)
|
.whereEqualTo("_id", testDetails?._id)
|
||||||
.get()
|
.get()
|
||||||
.addOnSuccessListener { userdata ->
|
.addOnSuccessListener { userdata ->
|
||||||
if (userdata.documents.isNotEmpty()) {
|
if (userdata.isEmpty) {
|
||||||
|
// Handle the case when no documents are found (e.g., display a message)
|
||||||
|
Toast.makeText(
|
||||||
|
context,
|
||||||
|
"No user data found for the specified ID",
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
|
} else {
|
||||||
|
val document = userdata.documents[0]
|
||||||
db.collection("patientData")
|
db.collection("patientData")
|
||||||
.document(userdata.documents[0].id)
|
.document(document.id)
|
||||||
.update("bloodGroup", bloodGroup)
|
.update("bloodGroup", bloodGroup)
|
||||||
.addOnSuccessListener {
|
.addOnSuccessListener {
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
@@ -178,8 +191,6 @@ class UserListAdapter(
|
|||||||
Toast.LENGTH_SHORT
|
Toast.LENGTH_SHORT
|
||||||
).show()
|
).show()
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
.addOnFailureListener { e ->
|
.addOnFailureListener { e ->
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
context,
|
context,
|
||||||
@@ -187,10 +198,15 @@ class UserListAdapter(
|
|||||||
Toast.LENGTH_SHORT
|
Toast.LENGTH_SHORT
|
||||||
).show()
|
).show()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.addOnFailureListener { e ->
|
||||||
|
Toast.makeText(
|
||||||
|
context,
|
||||||
|
"Error fetching user data: ${e.message}",
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Handle the selected blood group here
|
// Handle the selected blood group here
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user