refactor: upgrade API endpoints to v3 and refactor navigation and response handling across controllers

This commit is contained in:
Hamza-Ayed
2026-04-28 01:13:15 +03:00
parent 13ef5f21b7
commit 6bfc15abb2
10 changed files with 366 additions and 220 deletions

View File

@@ -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();
}