Merge branch with resolved conflicts - restructured features and added new modules
This commit is contained in:
@@ -1,14 +1,15 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_chicken/data/models/poultry_export/poultry_export.dart';
|
||||
import 'package:rasadyar_chicken/data/models/request/kill_registration/kill_registration.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/all_poultry/all_poultry.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/approved_price/approved_price.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/kill_house_poultry/kill_house_poultry.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/kill_request_poultry/kill_request_poultry.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/poultry_hatching/poultry_hatching.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/sell_for_freezing/sell_for_freezing.dart';
|
||||
import 'package:rasadyar_chicken/features/poultry_science/genocide/logic.dart';
|
||||
import 'package:rasadyar_chicken/features/poultry_science/root/logic.dart';
|
||||
=
|
||||
import 'package:rasadyar_chicken/features/poultry_science/data/model/response/poultry_export/poultry_export.dart';
|
||||
import 'package:rasadyar_chicken/features/poultry_science/data/model/request/kill_registration/kill_registration.dart';
|
||||
import 'package:rasadyar_chicken/features/poultry_science/data/model/response/all_poultry/all_poultry.dart';
|
||||
import 'package:rasadyar_chicken/features/poultry_science/data/model/response/approved_price/approved_price.dart';
|
||||
import 'package:rasadyar_chicken/features/poultry_science/data/model/response/kill_house_poultry/kill_house_poultry.dart';
|
||||
import 'package:rasadyar_chicken/features/poultry_science/data/model/response/kill_request_poultry/kill_request_poultry.dart';
|
||||
import 'package:rasadyar_chicken/features/poultry_science/data/model/response/poultry_hatching/poultry_hatching.dart';
|
||||
import 'package:rasadyar_chicken/features/poultry_science/data/model/response/sell_for_freezing/sell_for_freezing.dart';
|
||||
import 'package:rasadyar_chicken/features/poultry_science/presentation/pages/genocide/logic.dart';
|
||||
import 'package:rasadyar_chicken/features/poultry_science/presentation/pages/root/logic.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
class KillingRegistrationLogic extends GetxController {
|
||||
@@ -26,7 +27,9 @@ class KillingRegistrationLogic extends GetxController {
|
||||
|
||||
TextEditingController quantityKillsController = TextEditingController();
|
||||
RxBool quantityKillsIsCompleted = false.obs;
|
||||
TextEditingController quantityLoseController = TextEditingController(text: 0.toString());
|
||||
TextEditingController quantityLoseController = TextEditingController(
|
||||
text: 0.toString(),
|
||||
);
|
||||
TextEditingController averageWeightKillsController = TextEditingController();
|
||||
RxBool averageWeightKillsIsCompleted = false.obs;
|
||||
TextEditingController priceFreeSaleController = TextEditingController();
|
||||
@@ -40,25 +43,23 @@ class KillingRegistrationLogic extends GetxController {
|
||||
RxBool isFreeSale = false.obs;
|
||||
|
||||
//step 1
|
||||
Rx<Resource<List<AllPoultry>>> allPoultryList = Resource<List<AllPoultry>>.loading().obs;
|
||||
Rx<Resource<List<AllPoultry>>> allPoultryList =
|
||||
Resource<List<AllPoultry>>.loading().obs;
|
||||
Rxn<AllPoultry> selectedPoultry = Rxn();
|
||||
|
||||
//step 2
|
||||
Rx<Resource<List<KillRequestPoultry>>> poultryList = Resource<List<KillRequestPoultry>>.success(
|
||||
[],
|
||||
).obs;
|
||||
Rx<Resource<List<KillRequestPoultry>>> poultryList =
|
||||
Resource<List<KillRequestPoultry>>.success([]).obs;
|
||||
Rxn<KillRequestPoultry> selectedKillRequestPoultry = Rxn();
|
||||
|
||||
//step 3
|
||||
Rx<Resource<List<PoultryHatching>>> poultryHatchingList = Resource<List<PoultryHatching>>.success(
|
||||
[],
|
||||
).obs;
|
||||
Rx<Resource<List<PoultryHatching>>> poultryHatchingList =
|
||||
Resource<List<PoultryHatching>>.success([]).obs;
|
||||
Rxn<PoultryHatching> selectedPoultryHatching = Rxn();
|
||||
|
||||
//step 5
|
||||
Rx<Resource<List<KillHousePoultry>>> killHouseList = Resource<List<KillHousePoultry>>.success(
|
||||
[],
|
||||
).obs;
|
||||
Rx<Resource<List<KillHousePoultry>>> killHouseList =
|
||||
Resource<List<KillHousePoultry>>.success([]).obs;
|
||||
Rxn<KillHousePoultry> selectedKillHouse = Rxn();
|
||||
|
||||
@override
|
||||
@@ -82,7 +83,12 @@ class KillingRegistrationLogic extends GetxController {
|
||||
});
|
||||
|
||||
everAll(
|
||||
[selectedPoultry, selectedKillRequestPoultry, selectedPoultryHatching, selectedKillHouse],
|
||||
[
|
||||
selectedPoultry,
|
||||
selectedKillRequestPoultry,
|
||||
selectedPoultryHatching,
|
||||
selectedKillHouse,
|
||||
],
|
||||
(callback) {
|
||||
checkSubmitButton();
|
||||
},
|
||||
@@ -104,12 +110,15 @@ class KillingRegistrationLogic extends GetxController {
|
||||
|
||||
void priceListener() {
|
||||
quantityKillsController.addListener(() {
|
||||
quantityKillsIsCompleted.value = quantityKillsController.text.trim().isNotEmpty;
|
||||
quantityKillsIsCompleted.value = quantityKillsController.text
|
||||
.trim()
|
||||
.isNotEmpty;
|
||||
|
||||
if (averageWeightKillsController.text.isNotEmpty &&
|
||||
quantityKillsController.text.trim().isNotEmpty) {
|
||||
generatedApprovedPrice.value = calculateApprovedPrice().toInt();
|
||||
priceFreeSaleController.text = generatedApprovedPrice.value.separatedByComma;
|
||||
priceFreeSaleController.text =
|
||||
generatedApprovedPrice.value.separatedByComma;
|
||||
|
||||
checkSubmitButton();
|
||||
} else {
|
||||
@@ -120,12 +129,15 @@ class KillingRegistrationLogic extends GetxController {
|
||||
});
|
||||
|
||||
averageWeightKillsController.addListener(() {
|
||||
averageWeightKillsIsCompleted.value = averageWeightKillsController.text.trim().isNotEmpty;
|
||||
averageWeightKillsIsCompleted.value = averageWeightKillsController.text
|
||||
.trim()
|
||||
.isNotEmpty;
|
||||
|
||||
if (averageWeightKillsController.text.trim().isNotEmpty &&
|
||||
quantityKillsController.text.trim().isNotEmpty) {
|
||||
generatedApprovedPrice.value = calculateApprovedPrice().toInt();
|
||||
priceFreeSaleController.text = generatedApprovedPrice.value.separatedByComma;
|
||||
priceFreeSaleController.text =
|
||||
generatedApprovedPrice.value.separatedByComma;
|
||||
checkSubmitButton();
|
||||
} else {
|
||||
generatedApprovedPrice.value = 0;
|
||||
@@ -177,7 +189,9 @@ class KillingRegistrationLogic extends GetxController {
|
||||
await safeCall(
|
||||
call: () async => await rootLogic.poultryRepository.getAllPoultry(
|
||||
token: tokenService.accessToken.value ?? '',
|
||||
queryParameters: buildRawQueryParams(role: gService.getRole(Module.chicken)),
|
||||
queryParameters: buildRawQueryParams(
|
||||
role: gService.getRole(Module.chicken),
|
||||
),
|
||||
),
|
||||
onSuccess: (result) {
|
||||
if (result != null) {
|
||||
@@ -185,7 +199,9 @@ class KillingRegistrationLogic extends GetxController {
|
||||
}
|
||||
},
|
||||
onError: (error, stackTrace) {
|
||||
allPoultryList.value = Resource<List<AllPoultry>>.error('$error -- $stackTrace');
|
||||
allPoultryList.value = Resource<List<AllPoultry>>.error(
|
||||
'$error -- $stackTrace',
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -230,11 +246,15 @@ class KillingRegistrationLogic extends GetxController {
|
||||
),
|
||||
onSuccess: (result) {
|
||||
if (result != null) {
|
||||
poultryList.value = Resource<List<KillRequestPoultry>>.success(result);
|
||||
poultryList.value = Resource<List<KillRequestPoultry>>.success(
|
||||
result,
|
||||
);
|
||||
}
|
||||
},
|
||||
onError: (error, stackTrace) {
|
||||
poultryList.value = Resource<List<KillRequestPoultry>>.error('$error -- $stackTrace');
|
||||
poultryList.value = Resource<List<KillRequestPoultry>>.error(
|
||||
'$error -- $stackTrace',
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -250,11 +270,15 @@ class KillingRegistrationLogic extends GetxController {
|
||||
),
|
||||
onSuccess: (result) {
|
||||
if (result != null) {
|
||||
poultryHatchingList.value = Resource<List<PoultryHatching>>.success(result);
|
||||
poultryHatchingList.value = Resource<List<PoultryHatching>>.success(
|
||||
result,
|
||||
);
|
||||
}
|
||||
},
|
||||
onError: (error, stackTrace) {
|
||||
poultryHatchingList.value = Resource<List<PoultryHatching>>.error('$error -- $stackTrace');
|
||||
poultryHatchingList.value = Resource<List<PoultryHatching>>.error(
|
||||
'$error -- $stackTrace',
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -265,16 +289,23 @@ class KillingRegistrationLogic extends GetxController {
|
||||
call: () async => await rootLogic.poultryRepository.getKillHouseList(
|
||||
token: tokenService.accessToken.value ?? '',
|
||||
queryParameters: buildRawQueryParams(
|
||||
queryParams: {'show_poultry': '', 'date': DateTime.now().formattedDashedGregorian},
|
||||
queryParams: {
|
||||
'show_poultry': '',
|
||||
'date': DateTime.now().formattedDashedGregorian,
|
||||
},
|
||||
),
|
||||
),
|
||||
onSuccess: (result) {
|
||||
if (result != null) {
|
||||
killHouseList.value = Resource<List<KillHousePoultry>>.success(result);
|
||||
killHouseList.value = Resource<List<KillHousePoultry>>.success(
|
||||
result,
|
||||
);
|
||||
}
|
||||
},
|
||||
onError: (error, stackTrace) {
|
||||
killHouseList.value = Resource<List<KillHousePoultry>>.error('$error -- $stackTrace');
|
||||
killHouseList.value = Resource<List<KillHousePoultry>>.error(
|
||||
'$error -- $stackTrace',
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -311,7 +342,11 @@ class KillingRegistrationLogic extends GetxController {
|
||||
selectedPoultryHatching.value != null &&
|
||||
quantityKillsController.text.isNotEmpty &&
|
||||
averageWeightKillsController.text.isNotEmpty &&
|
||||
((selectedKillRequestPoultry.value?.provinceAllowChooseKillHouse?.mandatory ?? false)
|
||||
((selectedKillRequestPoultry
|
||||
.value
|
||||
?.provinceAllowChooseKillHouse
|
||||
?.mandatory ??
|
||||
false)
|
||||
? selectedKillHouse.value != null
|
||||
: true);
|
||||
}
|
||||
@@ -352,10 +387,11 @@ class KillingRegistrationLogic extends GetxController {
|
||||
);
|
||||
|
||||
await safeCall(
|
||||
call: () async => await rootLogic.poultryRepository.submitKillRegistration(
|
||||
token: tokenService.accessToken.value ?? '',
|
||||
request: registrationRequest,
|
||||
),
|
||||
call: () async =>
|
||||
await rootLogic.poultryRepository.submitKillRegistration(
|
||||
token: tokenService.accessToken.value ?? '',
|
||||
request: registrationRequest,
|
||||
),
|
||||
onSuccess: (result) async {
|
||||
defaultShowSuccessMessage(
|
||||
'ثبت با موفقیت انجام شد',
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/all_poultry/all_poultry.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/kill_house_poultry/kill_house_poultry.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/kill_request_poultry/kill_request_poultry.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/poultry_hatching/poultry_hatching.dart';
|
||||
import 'package:rasadyar_chicken/features/poultry_science/data/model/response/all_poultry/all_poultry.dart';
|
||||
import 'package:rasadyar_chicken/features/poultry_science/data/model/response/kill_house_poultry/kill_house_poultry.dart';
|
||||
import 'package:rasadyar_chicken/features/poultry_science/data/model/response/kill_request_poultry/kill_request_poultry.dart';
|
||||
import 'package:rasadyar_chicken/features/poultry_science/data/model/response/poultry_hatching/poultry_hatching.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
import 'logic.dart';
|
||||
|
||||
Reference in New Issue
Block a user