refactor: upgrade API endpoints to v3 and refactor navigation and response handling across controllers
This commit is contained in:
@@ -20,13 +20,26 @@ class PassengerNotificationController extends GetxController {
|
||||
var res = await CRUD().get(
|
||||
link: AppLink.getNotificationPassenger,
|
||||
payload: {'passenger_id': box.read(BoxName.passengerID)});
|
||||
if (res == "failure") {
|
||||
if (res == "failure" || res == "error") {
|
||||
MyDialog().getDialog('There is no notification yet'.tr, '', () {
|
||||
Get.back();
|
||||
Get.back();
|
||||
});
|
||||
} else {
|
||||
notificationData = jsonDecode(res);
|
||||
final decoded = jsonDecode(res);
|
||||
// التحقق من وجود البيانات في 'data' أو 'message'
|
||||
var rawData = decoded['data'] ?? decoded['message'];
|
||||
|
||||
if (decoded['status'] == 'error' || decoded['status'] == 'failure' || rawData == "No notification data found") {
|
||||
notificationData = {'status': 'success', 'message': []}; // قائمة فارغة لمنع الخطأ في UI
|
||||
} else {
|
||||
// التأكد أننا نخزن قائمة
|
||||
notificationData = {
|
||||
'status': 'success',
|
||||
'message': rawData is List ? rawData : [rawData]
|
||||
};
|
||||
}
|
||||
|
||||
isloading = false;
|
||||
update();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user