checkForNewRequests method
dynamic
checkForNewRequests()
Implementation
checkForNewRequests() async {
try {
var url =
"/dashboard/booking?page=1&pageSize=${rowsPerPage.value}";
final query = getQuery();
final response = await Requests.getDio(showLoadingDialog: false).get(url + query);
if (response.statusCode == 200) {
if (response.data["total"] == 0) {
return;
}
final total = response.data["total"];
if (total != totalRequests.value) {
DefaultSnackbar.show('New requests', 'New requests are available now, check them out');
totalRequests.value = response.data["total"];
currentPage.value = 1;
totalPages.value = (totalRequests.value / rowsPerPage.value).ceil();
requestsLists.value =
(response.data["data"] as List<dynamic>).map((json) {
return BookingModel.fromJson(json);
}).toList();
}
}
} catch (e) {
debugPrint('error checking new requests ${e.toString()}');
}
}