60 lines
1.8 KiB
Dart
60 lines
1.8 KiB
Dart
import 'package:rasadyar_auth/data/utils/safe_call.dart';
|
|
import 'package:rasadyar_chicken/chicken.dart';
|
|
import 'package:rasadyar_chicken/data/models/response/bar_information/bar_information.dart';
|
|
import 'package:rasadyar_chicken/data/models/response/inventory/inventory_model.dart';
|
|
import 'package:rasadyar_chicken/data/models/response/kill_house_distribution_info/kill_house_distribution_info.dart';
|
|
import 'package:rasadyar_chicken/presentation/utils/utils.dart';
|
|
import 'package:rasadyar_core/core.dart';
|
|
|
|
class HomeLogic extends GetxController {
|
|
RootLogic rootLogic = Get.find<RootLogic>();
|
|
RxnInt totalWeightTodayBars = RxnInt();
|
|
Rxn<KillHouseDistributionInfo> killHouseDistributionInfo = Rxn<KillHouseDistributionInfo>();
|
|
|
|
RxBool isExpanded = false.obs;
|
|
|
|
|
|
@override
|
|
void onReady() {
|
|
super.onReady();
|
|
getTodayBars();
|
|
getDistributionInformation();
|
|
}
|
|
|
|
|
|
Future<void> getTodayBars() async {
|
|
await safeCall<BarInformation?>(
|
|
call: () async => await rootLogic.chickenRepository.getGeneralBarInformation(
|
|
token: rootLogic.tokenService.accessToken.value!,
|
|
queryParameters: buildQueryParams(fromDate: DateTime.now(), toDate: DateTime.now()),
|
|
),
|
|
onSuccess: (result) {
|
|
iLog(result);
|
|
if (result != null) {
|
|
totalWeightTodayBars.value = result.totalBarsWeight?.toInt();
|
|
}
|
|
},
|
|
onError: (error, stackTrace) {
|
|
|
|
},
|
|
);
|
|
}
|
|
|
|
Future<void> getDistributionInformation() async {
|
|
await safeCall<KillHouseDistributionInfo?>(
|
|
call: () async => await rootLogic.chickenRepository.getKillHouseDistributionInfo(
|
|
token: rootLogic.tokenService.accessToken.value!,
|
|
),
|
|
onSuccess: (result) {
|
|
if (result != null) {
|
|
killHouseDistributionInfo.value = result;
|
|
}
|
|
},
|
|
onError: (error, stackTrace) {},
|
|
);
|
|
}
|
|
|
|
|
|
|
|
}
|