fix : change product list in root
This commit is contained in:
@@ -59,7 +59,7 @@ class BuyOutOfProvinceLogic extends GetxController {
|
|||||||
getStewardPurchaseOutOfProvince();
|
getStewardPurchaseOutOfProvince();
|
||||||
selectedProvince.listen((p0) => getCites());
|
selectedProvince.listen((p0) => getCites());
|
||||||
|
|
||||||
selectedProduct.value = outOfTheProvinceLogic.rolesProductsModel.first;
|
selectedProduct.value = rootLogic.rolesProductsModel.first;
|
||||||
setupListeners();
|
setupListeners();
|
||||||
|
|
||||||
debounce(
|
debounce(
|
||||||
@@ -220,7 +220,7 @@ class BuyOutOfProvinceLogic extends GetxController {
|
|||||||
carcassWeightController.text = item.weightOfCarcasses?.toInt().toString() ?? '';
|
carcassWeightController.text = item.weightOfCarcasses?.toInt().toString() ?? '';
|
||||||
selectedProvince.value = IranProvinceCityModel(name: item.province);
|
selectedProvince.value = IranProvinceCityModel(name: item.province);
|
||||||
selectedCity.value = IranProvinceCityModel(name: item.city);
|
selectedCity.value = IranProvinceCityModel(name: item.city);
|
||||||
selectedProduct.value = outOfTheProvinceLogic.rolesProductsModel.firstWhere(
|
selectedProduct.value = rootLogic.rolesProductsModel.firstWhere(
|
||||||
(element) => element.key == item.product!.key,
|
(element) => element.key == item.product!.key,
|
||||||
);
|
);
|
||||||
isSubmitButtonEnabled.value = true;
|
isSubmitButtonEnabled.value = true;
|
||||||
|
|||||||
@@ -407,7 +407,7 @@ class BuyOutOfProvincePage extends GetView<BuyOutOfProvinceLogic> {
|
|||||||
Widget _productDropDown() {
|
Widget _productDropDown() {
|
||||||
return Obx(() {
|
return Obx(() {
|
||||||
return OverlayDropdownWidget<ProductModel>(
|
return OverlayDropdownWidget<ProductModel>(
|
||||||
items: controller.outOfTheProvinceLogic.rolesProductsModel,
|
items: controller.rootLogic.rolesProductsModel,
|
||||||
height: 56,
|
height: 56,
|
||||||
hasDropIcon: false,
|
hasDropIcon: false,
|
||||||
background: Colors.white,
|
background: Colors.white,
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import 'package:rasadyar_auth/data/utils/safe_call.dart';
|
|||||||
import 'package:rasadyar_chicken/data/di/chicken_di.dart';
|
import 'package:rasadyar_chicken/data/di/chicken_di.dart';
|
||||||
import 'package:rasadyar_chicken/data/models/response/inventory/inventory_model.dart';
|
import 'package:rasadyar_chicken/data/models/response/inventory/inventory_model.dart';
|
||||||
import 'package:rasadyar_chicken/data/models/response/iran_province_city/iran_province_city_model.dart';
|
import 'package:rasadyar_chicken/data/models/response/iran_province_city/iran_province_city_model.dart';
|
||||||
|
import 'package:rasadyar_chicken/data/models/response/roles_products/roles_products.dart';
|
||||||
import 'package:rasadyar_chicken/data/repositories/chicken_repository.dart';
|
import 'package:rasadyar_chicken/data/repositories/chicken_repository.dart';
|
||||||
import 'package:rasadyar_chicken/data/repositories/chicken_repository_imp.dart';
|
import 'package:rasadyar_chicken/data/repositories/chicken_repository_imp.dart';
|
||||||
import 'package:rasadyar_chicken/presentation/pages/buy/view.dart';
|
import 'package:rasadyar_chicken/presentation/pages/buy/view.dart';
|
||||||
@@ -24,7 +25,7 @@ class RootLogic extends GetxController {
|
|||||||
List<Widget> pages = [BuyPage(), SalePage(), HomePage(), SegmentationPage(), ProfilePage()];
|
List<Widget> pages = [BuyPage(), SalePage(), HomePage(), SegmentationPage(), ProfilePage()];
|
||||||
|
|
||||||
final defaultRoutes = <int, String>{0: ChickenRoutes.buy, 1: ChickenRoutes.sale};
|
final defaultRoutes = <int, String>{0: ChickenRoutes.buy, 1: ChickenRoutes.sale};
|
||||||
|
RxList<ProductModel> rolesProductsModel = RxList<ProductModel>();
|
||||||
|
|
||||||
late DioRemote dioRemote;
|
late DioRemote dioRemote;
|
||||||
var tokenService = Get.find<TokenStorageService>();
|
var tokenService = Get.find<TokenStorageService>();
|
||||||
@@ -58,6 +59,9 @@ class RootLogic extends GetxController {
|
|||||||
if (inventoryModel.value == null) {
|
if (inventoryModel.value == null) {
|
||||||
getInventory();
|
getInventory();
|
||||||
}
|
}
|
||||||
|
if (rolesProductsModel.isEmpty) {
|
||||||
|
getRolesProducts();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -129,4 +133,17 @@ class RootLogic extends GetxController {
|
|||||||
provinces.clear();
|
provinces.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> getRolesProducts() async {
|
||||||
|
safeCall(
|
||||||
|
call: () async =>
|
||||||
|
await chickenRepository.getRolesProducts(token: tokenService.accessToken.value!),
|
||||||
|
onSuccess: (result) {
|
||||||
|
if (result != null) {
|
||||||
|
rolesProductsModel.value = result;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onError: (error, stacktrace) {},
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import 'package:rasadyar_core/core.dart';
|
|||||||
|
|
||||||
class SaleLogic extends GetxController {
|
class SaleLogic extends GetxController {
|
||||||
Rxn<List<AllocatedMadeModel>?> allocatedMadeModel = Rxn<List<AllocatedMadeModel>?>();
|
Rxn<List<AllocatedMadeModel>?> allocatedMadeModel = Rxn<List<AllocatedMadeModel>?>();
|
||||||
RxList<ProductModel> rolesProductsModel = RxList<ProductModel>();
|
|
||||||
|
|
||||||
RxList<GuildModel> guildsModel = <GuildModel>[].obs;
|
RxList<GuildModel> guildsModel = <GuildModel>[].obs;
|
||||||
|
|
||||||
@@ -24,7 +23,7 @@ class SaleLogic extends GetxController {
|
|||||||
void onReady() {
|
void onReady() {
|
||||||
super.onReady();
|
super.onReady();
|
||||||
getStewardDashBord();
|
getStewardDashBord();
|
||||||
getRolesProducts();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> getAllocatedMade() async {
|
Future<void> getAllocatedMade() async {
|
||||||
@@ -83,19 +82,6 @@ class SaleLogic extends GetxController {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> getRolesProducts() async {
|
|
||||||
safeCall(
|
|
||||||
call: () async => await rootLogic.chickenRepository.getRolesProducts(
|
|
||||||
token: rootLogic.tokenService.accessToken.value!,
|
|
||||||
),
|
|
||||||
onSuccess: (result) {
|
|
||||||
if (result != null) {
|
|
||||||
rolesProductsModel.value = result;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onError: (error, stacktrace) {},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> getGuilds() async {}
|
Future<void> getGuilds() async {}
|
||||||
|
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ class SalesOutOfProvinceSalesListLogic extends GetxController {
|
|||||||
void onReady() {
|
void onReady() {
|
||||||
super.onReady();
|
super.onReady();
|
||||||
|
|
||||||
selectedProduct.value = saleLogic.rolesProductsModel.first;
|
selectedProduct.value = rootLogic.rolesProductsModel.first;
|
||||||
debounce(
|
debounce(
|
||||||
searchedValue,
|
searchedValue,
|
||||||
(callback) => getOutProvinceSales(),
|
(callback) => getOutProvinceSales(),
|
||||||
@@ -140,7 +140,7 @@ class SalesOutOfProvinceSalesListLogic extends GetxController {
|
|||||||
selectedBuyer.value = buyerLogic.buyerList.value.data?.results?.firstWhere(
|
selectedBuyer.value = buyerLogic.buyerList.value.data?.results?.firstWhere(
|
||||||
(element) => element.key == item.buyer?.key,
|
(element) => element.key == item.buyer?.key,
|
||||||
);
|
);
|
||||||
selectedProduct.value = saleLogic.rolesProductsModel.first;
|
selectedProduct.value = rootLogic.rolesProductsModel.first;
|
||||||
key = item.key;
|
key = item.key;
|
||||||
isSaleSubmitButtonEnabled.value = true;
|
isSaleSubmitButtonEnabled.value = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -343,7 +343,7 @@ class SalesOutOfProvinceSalesListPage extends GetView<SalesOutOfProvinceSalesLis
|
|||||||
Widget _productDropDown() {
|
Widget _productDropDown() {
|
||||||
return Obx(() {
|
return Obx(() {
|
||||||
return OverlayDropdownWidget<ProductModel>(
|
return OverlayDropdownWidget<ProductModel>(
|
||||||
items: controller.saleLogic.rolesProductsModel,
|
items: controller.rootLogic.rolesProductsModel,
|
||||||
height: 56,
|
height: 56,
|
||||||
hasDropIcon: false,
|
hasDropIcon: false,
|
||||||
background: Colors.white,
|
background: Colors.white,
|
||||||
|
|||||||
@@ -22,10 +22,9 @@ class SegmentationLogic extends GetxController {
|
|||||||
RxnString searchedValue = RxnString();
|
RxnString searchedValue = RxnString();
|
||||||
|
|
||||||
GlobalKey<FormState> formKey = GlobalKey<FormState>();
|
GlobalKey<FormState> formKey = GlobalKey<FormState>();
|
||||||
TextEditingController weightController = TextEditingController();
|
TextEditingController weightController = TextEditingController(text: '0');
|
||||||
RxBool isSaleSubmitButtonEnabled = false.obs;
|
RxBool isSubmitButtonEnabled = false.obs;
|
||||||
|
|
||||||
RxList<ProductModel> rolesProductsModel = RxList<ProductModel>();
|
|
||||||
Rxn<ProductModel> selectedProduct = Rxn<ProductModel>();
|
Rxn<ProductModel> selectedProduct = Rxn<ProductModel>();
|
||||||
Rxn<SegmentationModel> selectedSegment = Rxn<SegmentationModel>();
|
Rxn<SegmentationModel> selectedSegment = Rxn<SegmentationModel>();
|
||||||
|
|
||||||
@@ -36,6 +35,7 @@ class SegmentationLogic extends GetxController {
|
|||||||
void onInit() {
|
void onInit() {
|
||||||
super.onInit();
|
super.onInit();
|
||||||
routesName = ['قطعهبندی'].toList();
|
routesName = ['قطعهبندی'].toList();
|
||||||
|
once(rootLogic.rolesProductsModel, (callback) => selectedProduct.value = callback.first);
|
||||||
getAllSegmentation();
|
getAllSegmentation();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,6 +61,11 @@ class SegmentationLogic extends GetxController {
|
|||||||
(callback) => getAllSegmentation(),
|
(callback) => getAllSegmentation(),
|
||||||
time: Duration(milliseconds: timeDebounce),
|
time: Duration(milliseconds: timeDebounce),
|
||||||
);
|
);
|
||||||
|
ever(selectedSegment, (_) {
|
||||||
|
validateForm();
|
||||||
|
});
|
||||||
|
|
||||||
|
weightController.addListener(() => validateForm());
|
||||||
}
|
}
|
||||||
|
|
||||||
void setEditData(SegmentationModel item) {
|
void setEditData(SegmentationModel item) {
|
||||||
@@ -69,13 +74,23 @@ class SegmentationLogic extends GetxController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void clearForm() {
|
void clearForm() {
|
||||||
weightController.clear();
|
weightController.text = '0';
|
||||||
isSaleSubmitButtonEnabled.value = false;
|
isSubmitButtonEnabled.value = false;
|
||||||
selectedProduct.value = null;
|
selectedProduct.value = null;
|
||||||
selectedSegment.value = null;
|
selectedSegment.value = null;
|
||||||
formKey.currentState?.reset();
|
formKey.currentState?.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void validateForm() {
|
||||||
|
isSubmitButtonEnabled = RxBool(
|
||||||
|
selectedProduct.value != null &&
|
||||||
|
selectedSegment.value != null &&
|
||||||
|
weightController.text.isNotEmpty &&
|
||||||
|
int.tryParse(weightController.text) != null &&
|
||||||
|
int.tryParse(weightController.text)! > 0,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> getAllSegmentation([bool isLoadingMore = false]) async {
|
Future<void> getAllSegmentation([bool isLoadingMore = false]) async {
|
||||||
if (isLoadingMore) {
|
if (isLoadingMore) {
|
||||||
isLoadingMoreAllocationsMade.value = true;
|
isLoadingMoreAllocationsMade.value = true;
|
||||||
@@ -134,22 +149,6 @@ class SegmentationLogic extends GetxController {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> getRolesProducts() async {
|
|
||||||
safeCall(
|
|
||||||
call: () async => await rootLogic.chickenRepository.getRolesProducts(
|
|
||||||
token: rootLogic.tokenService.accessToken.value!,
|
|
||||||
),
|
|
||||||
onSuccess: (result) {
|
|
||||||
if (result != null) {
|
|
||||||
rolesProductsModel.value = result;
|
|
||||||
|
|
||||||
selectedProduct.value = rolesProductsModel.first;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onError: (error, stacktrace) {},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<bool> editSegment() async {
|
Future<bool> editSegment() async {
|
||||||
var res = true;
|
var res = true;
|
||||||
safeCall(
|
safeCall(
|
||||||
|
|||||||
@@ -35,13 +35,14 @@ sealed class ChickenPages {
|
|||||||
page: () => RootPage(),
|
page: () => RootPage(),
|
||||||
middlewares: [AuthMiddleware()],
|
middlewares: [AuthMiddleware()],
|
||||||
binding: BindingsBuilder(() {
|
binding: BindingsBuilder(() {
|
||||||
Get.lazyPut(() => RootLogic());
|
|
||||||
Get.lazyPut(() => BaseLogic());
|
Get.lazyPut(() => BaseLogic());
|
||||||
|
Get.lazyPut(() => RootLogic());
|
||||||
Get.lazyPut(() => HomeLogic());
|
Get.lazyPut(() => HomeLogic());
|
||||||
Get.lazyPut(() => BuyLogic());
|
Get.lazyPut(() => BuyLogic());
|
||||||
Get.lazyPut(() => SaleLogic());
|
Get.lazyPut(() => SaleLogic());
|
||||||
Get.lazyPut(() => ProfileLogic());
|
Get.lazyPut(() => ProfileLogic());
|
||||||
Get.lazyPut(() => SegmentationLogic());
|
Get.lazyPut(() => SegmentationLogic());
|
||||||
|
Get.lazyPut(() => SearchLogic());
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user