From 99503a2d72cc6f9e2e4dc579f5e807ae64aceab3 Mon Sep 17 00:00:00 2001 From: "mr.mojtaba" Date: Mon, 21 Jul 2025 15:06:19 +0330 Subject: [PATCH] fix : new ui changes --- .../datasource/remote/chicken_remote_imp.dart | 2 +- .../segmentation_model.dart | 1 + .../segmentation_model.freezed.dart | 27 ++++++++++--------- .../segmentation_model.g.dart | 2 ++ .../pages/buy_in_province_all/view.dart | 14 +++++++--- .../pages/buy_in_province_waiting/view.dart | 17 +++++++++--- .../pages/sales_in_province/view.dart | 18 ++++++++----- .../pages/sales_out_of_province/logic.dart | 1 + .../pages/sales_out_of_province/view.dart | 2 +- .../pages/segmentation/logic.dart | 2 +- .../lib/infrastructure/remote/dio_remote.dart | 6 +++++ .../lib/utils/network/safe_call_utils.dart | 3 ++- 12 files changed, 66 insertions(+), 29 deletions(-) diff --git a/packages/chicken/lib/data/datasource/remote/chicken_remote_imp.dart b/packages/chicken/lib/data/datasource/remote/chicken_remote_imp.dart index d0ecd35..c317b5c 100644 --- a/packages/chicken/lib/data/datasource/remote/chicken_remote_imp.dart +++ b/packages/chicken/lib/data/datasource/remote/chicken_remote_imp.dart @@ -472,7 +472,7 @@ class ChickenRemoteDatasourceImp implements ChickenRemoteDatasource { required String token, required String key, }) async { - var res = await _httpClient.delete( + var res = await _httpClient.delete( '/app-segmentation/0/', queryParameters: {'key': key}, headers: {'Authorization': 'Bearer $token'}, diff --git a/packages/chicken/lib/data/models/response/segmentation_model/segmentation_model.dart b/packages/chicken/lib/data/models/response/segmentation_model/segmentation_model.dart index 4fd3ad4..c9b1052 100644 --- a/packages/chicken/lib/data/models/response/segmentation_model/segmentation_model.dart +++ b/packages/chicken/lib/data/models/response/segmentation_model/segmentation_model.dart @@ -10,6 +10,7 @@ abstract class SegmentationModel with _$SegmentationModel { String? key, String? productKey, String? guildKey, + String? result, int? weight, Buyer? buyer, DateTime? date, diff --git a/packages/chicken/lib/data/models/response/segmentation_model/segmentation_model.freezed.dart b/packages/chicken/lib/data/models/response/segmentation_model/segmentation_model.freezed.dart index 8786599..9de3533 100644 --- a/packages/chicken/lib/data/models/response/segmentation_model/segmentation_model.freezed.dart +++ b/packages/chicken/lib/data/models/response/segmentation_model/segmentation_model.freezed.dart @@ -16,7 +16,7 @@ T _$identity(T value) => value; /// @nodoc mixin _$SegmentationModel { - String? get key; String? get productKey; String? get guildKey; int? get weight; Buyer? get buyer; DateTime? get date; ToGuild? get toGuild; + String? get key; String? get productKey; String? get guildKey; String? get result; int? get weight; Buyer? get buyer; DateTime? get date; ToGuild? get toGuild; /// Create a copy of SegmentationModel /// with the given fields replaced by the non-null parameter values. @JsonKey(includeFromJson: false, includeToJson: false) @@ -29,16 +29,16 @@ $SegmentationModelCopyWith get copyWith => _$SegmentationMode @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is SegmentationModel&&(identical(other.key, key) || other.key == key)&&(identical(other.productKey, productKey) || other.productKey == productKey)&&(identical(other.guildKey, guildKey) || other.guildKey == guildKey)&&(identical(other.weight, weight) || other.weight == weight)&&(identical(other.buyer, buyer) || other.buyer == buyer)&&(identical(other.date, date) || other.date == date)&&(identical(other.toGuild, toGuild) || other.toGuild == toGuild)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is SegmentationModel&&(identical(other.key, key) || other.key == key)&&(identical(other.productKey, productKey) || other.productKey == productKey)&&(identical(other.guildKey, guildKey) || other.guildKey == guildKey)&&(identical(other.result, result) || other.result == result)&&(identical(other.weight, weight) || other.weight == weight)&&(identical(other.buyer, buyer) || other.buyer == buyer)&&(identical(other.date, date) || other.date == date)&&(identical(other.toGuild, toGuild) || other.toGuild == toGuild)); } @JsonKey(includeFromJson: false, includeToJson: false) @override -int get hashCode => Object.hash(runtimeType,key,productKey,guildKey,weight,buyer,date,toGuild); +int get hashCode => Object.hash(runtimeType,key,productKey,guildKey,result,weight,buyer,date,toGuild); @override String toString() { - return 'SegmentationModel(key: $key, productKey: $productKey, guildKey: $guildKey, weight: $weight, buyer: $buyer, date: $date, toGuild: $toGuild)'; + return 'SegmentationModel(key: $key, productKey: $productKey, guildKey: $guildKey, result: $result, weight: $weight, buyer: $buyer, date: $date, toGuild: $toGuild)'; } @@ -49,7 +49,7 @@ abstract mixin class $SegmentationModelCopyWith<$Res> { factory $SegmentationModelCopyWith(SegmentationModel value, $Res Function(SegmentationModel) _then) = _$SegmentationModelCopyWithImpl; @useResult $Res call({ - String? key, String? productKey, String? guildKey, int? weight, Buyer? buyer, DateTime? date, ToGuild? toGuild + String? key, String? productKey, String? guildKey, String? result, int? weight, Buyer? buyer, DateTime? date, ToGuild? toGuild }); @@ -66,11 +66,12 @@ class _$SegmentationModelCopyWithImpl<$Res> /// Create a copy of SegmentationModel /// with the given fields replaced by the non-null parameter values. -@pragma('vm:prefer-inline') @override $Res call({Object? key = freezed,Object? productKey = freezed,Object? guildKey = freezed,Object? weight = freezed,Object? buyer = freezed,Object? date = freezed,Object? toGuild = freezed,}) { +@pragma('vm:prefer-inline') @override $Res call({Object? key = freezed,Object? productKey = freezed,Object? guildKey = freezed,Object? result = freezed,Object? weight = freezed,Object? buyer = freezed,Object? date = freezed,Object? toGuild = freezed,}) { return _then(_self.copyWith( key: freezed == key ? _self.key : key // ignore: cast_nullable_to_non_nullable as String?,productKey: freezed == productKey ? _self.productKey : productKey // ignore: cast_nullable_to_non_nullable as String?,guildKey: freezed == guildKey ? _self.guildKey : guildKey // ignore: cast_nullable_to_non_nullable +as String?,result: freezed == result ? _self.result : result // ignore: cast_nullable_to_non_nullable as String?,weight: freezed == weight ? _self.weight : weight // ignore: cast_nullable_to_non_nullable as int?,buyer: freezed == buyer ? _self.buyer : buyer // ignore: cast_nullable_to_non_nullable as Buyer?,date: freezed == date ? _self.date : date // ignore: cast_nullable_to_non_nullable @@ -110,12 +111,13 @@ $ToGuildCopyWith<$Res>? get toGuild { @JsonSerializable() class _SegmentationModel implements SegmentationModel { - const _SegmentationModel({this.key, this.productKey, this.guildKey, this.weight, this.buyer, this.date, this.toGuild}); + const _SegmentationModel({this.key, this.productKey, this.guildKey, this.result, this.weight, this.buyer, this.date, this.toGuild}); factory _SegmentationModel.fromJson(Map json) => _$SegmentationModelFromJson(json); @override final String? key; @override final String? productKey; @override final String? guildKey; +@override final String? result; @override final int? weight; @override final Buyer? buyer; @override final DateTime? date; @@ -134,16 +136,16 @@ Map toJson() { @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is _SegmentationModel&&(identical(other.key, key) || other.key == key)&&(identical(other.productKey, productKey) || other.productKey == productKey)&&(identical(other.guildKey, guildKey) || other.guildKey == guildKey)&&(identical(other.weight, weight) || other.weight == weight)&&(identical(other.buyer, buyer) || other.buyer == buyer)&&(identical(other.date, date) || other.date == date)&&(identical(other.toGuild, toGuild) || other.toGuild == toGuild)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is _SegmentationModel&&(identical(other.key, key) || other.key == key)&&(identical(other.productKey, productKey) || other.productKey == productKey)&&(identical(other.guildKey, guildKey) || other.guildKey == guildKey)&&(identical(other.result, result) || other.result == result)&&(identical(other.weight, weight) || other.weight == weight)&&(identical(other.buyer, buyer) || other.buyer == buyer)&&(identical(other.date, date) || other.date == date)&&(identical(other.toGuild, toGuild) || other.toGuild == toGuild)); } @JsonKey(includeFromJson: false, includeToJson: false) @override -int get hashCode => Object.hash(runtimeType,key,productKey,guildKey,weight,buyer,date,toGuild); +int get hashCode => Object.hash(runtimeType,key,productKey,guildKey,result,weight,buyer,date,toGuild); @override String toString() { - return 'SegmentationModel(key: $key, productKey: $productKey, guildKey: $guildKey, weight: $weight, buyer: $buyer, date: $date, toGuild: $toGuild)'; + return 'SegmentationModel(key: $key, productKey: $productKey, guildKey: $guildKey, result: $result, weight: $weight, buyer: $buyer, date: $date, toGuild: $toGuild)'; } @@ -154,7 +156,7 @@ abstract mixin class _$SegmentationModelCopyWith<$Res> implements $SegmentationM factory _$SegmentationModelCopyWith(_SegmentationModel value, $Res Function(_SegmentationModel) _then) = __$SegmentationModelCopyWithImpl; @override @useResult $Res call({ - String? key, String? productKey, String? guildKey, int? weight, Buyer? buyer, DateTime? date, ToGuild? toGuild + String? key, String? productKey, String? guildKey, String? result, int? weight, Buyer? buyer, DateTime? date, ToGuild? toGuild }); @@ -171,11 +173,12 @@ class __$SegmentationModelCopyWithImpl<$Res> /// Create a copy of SegmentationModel /// with the given fields replaced by the non-null parameter values. -@override @pragma('vm:prefer-inline') $Res call({Object? key = freezed,Object? productKey = freezed,Object? guildKey = freezed,Object? weight = freezed,Object? buyer = freezed,Object? date = freezed,Object? toGuild = freezed,}) { +@override @pragma('vm:prefer-inline') $Res call({Object? key = freezed,Object? productKey = freezed,Object? guildKey = freezed,Object? result = freezed,Object? weight = freezed,Object? buyer = freezed,Object? date = freezed,Object? toGuild = freezed,}) { return _then(_SegmentationModel( key: freezed == key ? _self.key : key // ignore: cast_nullable_to_non_nullable as String?,productKey: freezed == productKey ? _self.productKey : productKey // ignore: cast_nullable_to_non_nullable as String?,guildKey: freezed == guildKey ? _self.guildKey : guildKey // ignore: cast_nullable_to_non_nullable +as String?,result: freezed == result ? _self.result : result // ignore: cast_nullable_to_non_nullable as String?,weight: freezed == weight ? _self.weight : weight // ignore: cast_nullable_to_non_nullable as int?,buyer: freezed == buyer ? _self.buyer : buyer // ignore: cast_nullable_to_non_nullable as Buyer?,date: freezed == date ? _self.date : date // ignore: cast_nullable_to_non_nullable diff --git a/packages/chicken/lib/data/models/response/segmentation_model/segmentation_model.g.dart b/packages/chicken/lib/data/models/response/segmentation_model/segmentation_model.g.dart index a51a7ee..6f4411a 100644 --- a/packages/chicken/lib/data/models/response/segmentation_model/segmentation_model.g.dart +++ b/packages/chicken/lib/data/models/response/segmentation_model/segmentation_model.g.dart @@ -11,6 +11,7 @@ _SegmentationModel _$SegmentationModelFromJson(Map json) => key: json['key'] as String?, productKey: json['product_key'] as String?, guildKey: json['guild_key'] as String?, + result: json['result'] as String?, weight: (json['weight'] as num?)?.toInt(), buyer: json['buyer'] == null ? null @@ -28,6 +29,7 @@ Map _$SegmentationModelToJson(_SegmentationModel instance) => 'key': instance.key, 'product_key': instance.productKey, 'guild_key': instance.guildKey, + 'result': instance.result, 'weight': instance.weight, 'buyer': instance.buyer, 'date': instance.date?.toIso8601String(), diff --git a/packages/chicken/lib/presentation/pages/buy_in_province_all/view.dart b/packages/chicken/lib/presentation/pages/buy_in_province_all/view.dart index 3ddd066..bb2586b 100644 --- a/packages/chicken/lib/presentation/pages/buy_in_province_all/view.dart +++ b/packages/chicken/lib/presentation/pages/buy_in_province_all/view.dart @@ -74,6 +74,7 @@ class BuyInProvinceAllPage extends GetView { Expanded( flex: 3, child: Column( + spacing: 3, mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ @@ -98,7 +99,11 @@ class BuyInProvinceAllPage extends GetView { ], ), - SizedBox(height: 2), + Text( + item.steward?.guildsName ?? 'N/A', + textAlign: TextAlign.start, + style: AppFonts.yekan12.copyWith(color: AppColor.bgDark), + ), ], ), ), @@ -186,7 +191,7 @@ class BuyInProvinceAllPage extends GetView { ), buildRow( - title: 'نام و نام خانوادگی فروشنده', + title: 'مشخصات فروشنده', value: item.steward?.user?.fullname ?? 'N/A', ), buildRow( @@ -194,7 +199,10 @@ class BuyInProvinceAllPage extends GetView { value: item.steward?.user?.mobile ?? 'N/A', valueStyle: AppFonts.yekan14.copyWith(color: AppColor.blueNormal), ), - + buildRow( + title: 'نوع تخصیص', + value: item.allocationType?.faAllocationType ?? 'N/A', + ), buildRow(title: 'محصول', value: item.product?.name ?? 'N/A'), buildRow( title: 'وزن خریداری شده', diff --git a/packages/chicken/lib/presentation/pages/buy_in_province_waiting/view.dart b/packages/chicken/lib/presentation/pages/buy_in_province_waiting/view.dart index 6658f35..d439b53 100644 --- a/packages/chicken/lib/presentation/pages/buy_in_province_waiting/view.dart +++ b/packages/chicken/lib/presentation/pages/buy_in_province_waiting/view.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:rasadyar_chicken/data/models/response/waiting_arrival/waiting_arrival.dart'; +import 'package:rasadyar_chicken/presentation/utils/string_utils.dart'; import 'package:rasadyar_chicken/presentation/widget/list_item/list_item.dart'; import 'package:rasadyar_chicken/presentation/widget/list_row_item.dart'; import 'package:rasadyar_core/core.dart'; @@ -75,7 +76,7 @@ class BuyInProvinceWaitingPage extends GetView { spacing: 3, children: [ Text( - item.toSteward?.user?.fullname ?? 'N/A', + item.steward?.user?.fullname ?? 'N/A', textAlign: TextAlign.start, style: AppFonts.yekan12.copyWith(color: AppColor.blueNormal), ), @@ -90,6 +91,7 @@ class BuyInProvinceWaitingPage extends GetView { Expanded( flex: 3, child: Column( + spacing: 3, mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ @@ -114,7 +116,11 @@ class BuyInProvinceWaitingPage extends GetView { ], ), - SizedBox(height: 2), + Text( + item.steward?.guildsName ?? 'N/A', + textAlign: TextAlign.start, + style: AppFonts.yekan12.copyWith(color: AppColor.bgDark), + ), ], ), ), @@ -197,7 +203,7 @@ class BuyInProvinceWaitingPage extends GetView { ), buildRow( - title: 'نام و نام خانوادگی فروشنده', + title: 'مشخصات فروشنده', value: item.steward?.user?.fullname ?? 'N/A', ), buildRow( @@ -205,7 +211,10 @@ class BuyInProvinceWaitingPage extends GetView { value: item.steward?.user?.mobile ?? 'N/A', valueStyle: AppFonts.yekan14.copyWith(color: AppColor.blueNormal), ), - + buildRow( + title: 'نوع تخصیص', + value: item.allocationType?.faAllocationType ?? 'N/A', + ), buildRow(title: 'محصول', value: item.product?.name ?? 'N/A'), buildRow( title: 'وزن خریداری شده', diff --git a/packages/chicken/lib/presentation/pages/sales_in_province/view.dart b/packages/chicken/lib/presentation/pages/sales_in_province/view.dart index c3e30c5..7b5afb6 100644 --- a/packages/chicken/lib/presentation/pages/sales_in_province/view.dart +++ b/packages/chicken/lib/presentation/pages/sales_in_province/view.dart @@ -145,7 +145,7 @@ class SalesInProvincePage extends GetView { spacing: 4, children: [ Text( - item.steward?.user?.fullname ?? 'N/A', + controller.getBuyerInformation(item)?.user?.fullname ?? 'N/A', textAlign: TextAlign.center, style: AppFonts.yekan14.copyWith(color: AppColor.blueNormal), ), @@ -219,8 +219,10 @@ class SalesInProvincePage extends GetView { Row( mainAxisAlignment: MainAxisAlignment.start, children: [ + + Text( - item.steward?.user?.fullname ?? 'N/A', + controller.getBuyerInformation(item)?.user?.fullname ?? 'N/A', textAlign: TextAlign.center, style: AppFonts.yekan16.copyWith(color: AppColor.greenDark), ), @@ -284,18 +286,22 @@ class SalesInProvincePage extends GetView { ), ), - buildRow( - title: 'نام و نام خانوادگی فروشنده', + /* buildRow( + title: 'مشخصات خریدار', value: controller.getBuyerInformation(item)?.user?.fullname ?? 'N/A', - ), + ),*/ buildRow( - title: 'تلفن فروشنده', + title: 'تلفن خریدار', value: controller.getBuyerInformation(item)?.user?.mobile ?? 'N/A', valueStyle: AppFonts.yekan14.copyWith(color: AppColor.blueNormal), ), buildRow(title: 'نوع فروش', value: item.sellType?.faItem ?? 'N/A'), buildRow(title: 'محصول', value: item.product?.name ?? 'N/A'), + buildRow( + title: 'نوع تخصیص', + value: item.allocationType?.faAllocationType ?? 'N/A', + ), buildRow( title: 'وزن خریداری شده', value: '${item.weightOfCarcasses?.separatedByComma} کیلوگرم', diff --git a/packages/chicken/lib/presentation/pages/sales_out_of_province/logic.dart b/packages/chicken/lib/presentation/pages/sales_out_of_province/logic.dart index 1f8e19e..3ebc74c 100644 --- a/packages/chicken/lib/presentation/pages/sales_out_of_province/logic.dart +++ b/packages/chicken/lib/presentation/pages/sales_out_of_province/logic.dart @@ -66,6 +66,7 @@ class SalesOutOfProvinceLogic extends GetxController { (callback) => getOutProvinceSales(), time: Duration(milliseconds: timeDebounce), ); + setupListeners(); } void setSearchValue(String? value) { diff --git a/packages/chicken/lib/presentation/pages/sales_out_of_province/view.dart b/packages/chicken/lib/presentation/pages/sales_out_of_province/view.dart index d33e434..8ee11f9 100644 --- a/packages/chicken/lib/presentation/pages/sales_out_of_province/view.dart +++ b/packages/chicken/lib/presentation/pages/sales_out_of_province/view.dart @@ -188,7 +188,7 @@ class SalesOutOfProvincePage extends GetView { mainAxisAlignment: MainAxisAlignment.start, children: [ Text( - '${item.province}-${item.city}', + '${item.province} - ${item.city}', textAlign: TextAlign.center, style: AppFonts.yekan16.copyWith(color: AppColor.greenDark), ), diff --git a/packages/chicken/lib/presentation/pages/segmentation/logic.dart b/packages/chicken/lib/presentation/pages/segmentation/logic.dart index 1bf5e90..7844168 100644 --- a/packages/chicken/lib/presentation/pages/segmentation/logic.dart +++ b/packages/chicken/lib/presentation/pages/segmentation/logic.dart @@ -144,7 +144,7 @@ class SegmentationLogic extends GetxController { Future deleteSegmentation(String key) async { await safeCall( - showError: true, + showError: false, call: () => rootLogic.chickenRepository.deleteSegmentation( token: rootLogic.tokenService.accessToken.value!, key: key, diff --git a/packages/core/lib/infrastructure/remote/dio_remote.dart b/packages/core/lib/infrastructure/remote/dio_remote.dart index b5b179e..3cfcd98 100644 --- a/packages/core/lib/infrastructure/remote/dio_remote.dart +++ b/packages/core/lib/infrastructure/remote/dio_remote.dart @@ -128,6 +128,12 @@ class DioRemote implements IHttpClient { options: Options(headers: headers), cancelToken: ApiHandler.globalCancelToken, ); + if (fromJson != null) { + final rawData = response.data; + final parsedData = rawData is Map ? fromJson(rawData) : null; + response.data = parsedData; + return DioResponse(response); + } return DioResponse(response); } diff --git a/packages/core/lib/utils/network/safe_call_utils.dart b/packages/core/lib/utils/network/safe_call_utils.dart index c0005a3..18588b6 100644 --- a/packages/core/lib/utils/network/safe_call_utils.dart +++ b/packages/core/lib/utils/network/safe_call_utils.dart @@ -60,6 +60,7 @@ Future gSafeCall({ } catch (error, stackTrace) { retryCount++; + eLog('Error in gSafeCall: $error, retryCount: $retryCount , stackTrace : $stackTrace '); if (error is DioException && error.response?.statusCode == 401) { if (showError) { @@ -79,7 +80,7 @@ Future gSafeCall({ return null; } - // صبر قبل از retry + if (retryCount <= maxRetries) { await Future.delayed(retryDelay); }