Set search test result by api

This commit is contained in:
hanie.khodkari
2025-05-10 18:27:37 +03:30
parent 12758968c9
commit b43d5c90fd
3 changed files with 54 additions and 25 deletions
+27 -23
View File
@@ -99,7 +99,7 @@ class TestResultsProvider with ChangeNotifier {
void setLoading() {
isloading = true;
// notifyListeners();
notifyListeners();
}
// bool isChangeVerify = false;
@@ -140,30 +140,33 @@ class TestResultsProvider with ChangeNotifier {
return _filters;
}
void search(String value) {
Future<void> search(String value) async {
print(value);
items = [];
searchBoxValue = value;
originalItems!.forEach((result) {
if (result.name
.toString()
.toLowerCase()
.contains(searchBoxValue.toLowerCase()) ||
result.name
.toString()
.toUpperCase()
.contains(searchBoxValue.toUpperCase()) ||
result.name
.toString()
.toLowerCase()
.contains(searchBoxValue.toUpperCase()) ||
result.name
.toString()
.toUpperCase()
.contains(searchBoxValue.toLowerCase())) {
items!.add(result);
}
});
var response = await http.get(
Uri.parse(Url.searchTestResults(value)),
headers: {
'Authorization': User.token,
},
);
print(response.body);
var testResultData = json.decode(response.body);
for (var item in testResultData['data']) {
items!.add(
TestResultObject(
id: item['id'].toString(),
name: item['test_type'] != null ? item['test_type']['name'] : '',
deviceId:
item['device_id'] != null ? item['device_id'].toString() : '',
result: item['result'] == 'Accept' ? 'Accepted' : 'Not Accepted',
date: item['created_at'].toString().substring(0, 10),
hospital: item['user']['medical_center']['name'],
verified: item['verified'].toString(),
),
);
}
resetLoading();
notifyListeners();
}
@@ -270,8 +273,9 @@ class TestResultsProvider with ChangeNotifier {
),
);
}
items = originalItems;
pageNumber += 1;
search('');
// search('');
notifyListeners();
}