feat : change app inspector and exception handling

This commit is contained in:
2025-07-12 17:06:29 +03:30
parent e52674de37
commit 0fc16569a6
24 changed files with 472 additions and 322 deletions

View File

@@ -9,20 +9,19 @@ import 'package:rasadyar_core/core.dart';
class HomeLogic extends GetxController {
RootLogic rootLogic = Get.find<RootLogic>();
RxnInt totalWeightTodayBars = RxnInt();
Rxn<InventoryModel> inventoryModel = Rxn<InventoryModel>();
Rxn<KillHouseDistributionInfo> killHouseDistributionInfo = Rxn<KillHouseDistributionInfo>();
RxBool isExpanded = false.obs;
@override
void onInit() {
super.onInit();
void onReady() {
super.onReady();
getTodayBars();
getInventory();
getDistributionInformation();
}
Future<void> getTodayBars() async {
await safeCall<BarInformation?>(
call: () async => await rootLogic.chickenRepository.getGeneralBarInformation(
@@ -30,51 +29,22 @@ class HomeLogic extends GetxController {
queryParameters: buildQueryParams(fromDate: DateTime.now(), toDate: DateTime.now()),
),
onSuccess: (result) {
iLog(result);
if (result != null) {
totalWeightTodayBars.value = result.totalBarsWeight?.toInt();
}
},
onError: (error, stackTrace) {
switch (error.response?.statusCode) {
case 401:
errorHandler(error);
break;
case 403:
errorHandler(error);
break;
default:
errorHandler(error);
}
},
);
}
Future<void> getInventory() async {
await safeCall<List<InventoryModel>?>(
call: () async => await rootLogic.chickenRepository.getInventory(token: rootLogic.tokenService.accessToken.value!),
onSuccess: (result) {
if (result != null) {
inventoryModel.value = result.first;
}
},
onError: (error, stackTrace) {
switch (error.response?.statusCode) {
case 401:
errorHandler(error);
break;
case 403:
errorHandler(error);
break;
default:
errorHandler(error);
}
},
);
}
Future<void> getDistributionInformation() async {
await safeCall<KillHouseDistributionInfo?>(
call: () async => await rootLogic.chickenRepository.getKillHouseDistributionInfo(token: rootLogic.tokenService.accessToken.value!),
call: () async => await rootLogic.chickenRepository.getKillHouseDistributionInfo(
token: rootLogic.tokenService.accessToken.value!,
),
onSuccess: (result) {
if (result != null) {
killHouseDistributionInfo.value = result;
@@ -85,19 +55,5 @@ class HomeLogic extends GetxController {
}
void errorHandler(DioException error) {
handleGeneric(error, () {
rootLogic.tokenService.deleteTokens();
});
}
@override
void onReady() {
super.onReady();
}
@override
void onClose() {
super.onClose();
}
}