feat : change app inspector and exception handling
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -309,7 +309,7 @@ class HomePage extends GetView<HomeLogic> {
|
||||
),
|
||||
],
|
||||
);
|
||||
}, controller.inventoryModel),
|
||||
}, controller.rootLogic.inventoryModel),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -345,7 +345,7 @@ class HomePage extends GetView<HomeLogic> {
|
||||
],
|
||||
),
|
||||
);
|
||||
}, controller.inventoryModel);
|
||||
}, controller.rootLogic.inventoryModel);
|
||||
}
|
||||
|
||||
Widget _todayShipmentWidget() {
|
||||
|
||||
Reference in New Issue
Block a user