From e2300293a7e098abc652251747eb0771da91cb52 Mon Sep 17 00:00:00 2001 From: "mr.mojtaba" Date: Mon, 21 Jul 2025 12:04:43 +0330 Subject: [PATCH] feat : new segment logic --- .../segmentation_model.dart | 41 +- .../segmentation_model.freezed.dart | 428 ++++++++++++++++-- .../segmentation_model.g.dart | 56 ++- .../pages/segmentation/logic.dart | 11 +- .../presentation/pages/segmentation/view.dart | 63 ++- 5 files changed, 521 insertions(+), 78 deletions(-) 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 2ee7915..4fd3ad4 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 @@ -9,11 +9,11 @@ abstract class SegmentationModel with _$SegmentationModel { const factory SegmentationModel({ String? key, String? productKey, + String? guildKey, + int? weight, Buyer? buyer, DateTime? date, - int? weight, - String? result, - String? guildKey, + ToGuild? toGuild, }) = _SegmentationModel; factory SegmentationModel.fromJson(Map json) => @@ -22,7 +22,40 @@ abstract class SegmentationModel with _$SegmentationModel { @freezed abstract class Buyer with _$Buyer { - const factory Buyer({String? fullname, String? mobile, String? shop, String? type}) = _Buyer; + const factory Buyer({ + String? fullname, + String? mobile, + String? shop, + }) = _Buyer; factory Buyer.fromJson(Map json) => _$BuyerFromJson(json); } + +@freezed +abstract class ToGuild with _$ToGuild { + const factory ToGuild({ + String? key, + String? guildsName, + String? typeActivity, + String? areaActivity, + String? guildsId, + bool? steward, + User? user, + }) = _ToGuild; + + factory ToGuild.fromJson(Map json) => _$ToGuildFromJson(json); +} + +@freezed +abstract class User with _$User { + const factory User({ + String? fullname, + String? firstName, + String? lastName, + String? mobile, + String? nationalId, + String? city, + }) = _User; + + factory User.fromJson(Map json) => _$UserFromJson(json); +} 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 94c2aa9..8786599 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; Buyer? get buyer; DateTime? get date; int? get weight; String? get result; String? get guildKey; + String? get key; String? get productKey; String? get guildKey; 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.buyer, buyer) || other.buyer == buyer)&&(identical(other.date, date) || other.date == date)&&(identical(other.weight, weight) || other.weight == weight)&&(identical(other.result, result) || other.result == result)&&(identical(other.guildKey, guildKey) || other.guildKey == guildKey)); + 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)); } @JsonKey(includeFromJson: false, includeToJson: false) @override -int get hashCode => Object.hash(runtimeType,key,productKey,buyer,date,weight,result,guildKey); +int get hashCode => Object.hash(runtimeType,key,productKey,guildKey,weight,buyer,date,toGuild); @override String toString() { - return 'SegmentationModel(key: $key, productKey: $productKey, buyer: $buyer, date: $date, weight: $weight, result: $result, guildKey: $guildKey)'; + return 'SegmentationModel(key: $key, productKey: $productKey, guildKey: $guildKey, weight: $weight, buyer: $buyer, date: $date, toGuild: $toGuild)'; } @@ -49,11 +49,11 @@ abstract mixin class $SegmentationModelCopyWith<$Res> { factory $SegmentationModelCopyWith(SegmentationModel value, $Res Function(SegmentationModel) _then) = _$SegmentationModelCopyWithImpl; @useResult $Res call({ - String? key, String? productKey, Buyer? buyer, DateTime? date, int? weight, String? result, String? guildKey + String? key, String? productKey, String? guildKey, int? weight, Buyer? buyer, DateTime? date, ToGuild? toGuild }); -$BuyerCopyWith<$Res>? get buyer; +$BuyerCopyWith<$Res>? get buyer;$ToGuildCopyWith<$Res>? get toGuild; } /// @nodoc @@ -66,16 +66,16 @@ 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? buyer = freezed,Object? date = freezed,Object? weight = freezed,Object? result = freezed,Object? guildKey = freezed,}) { +@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,}) { 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?,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 -as DateTime?,weight: freezed == weight ? _self.weight : weight // ignore: cast_nullable_to_non_nullable -as int?,result: freezed == result ? _self.result : result // ignore: cast_nullable_to_non_nullable as String?,guildKey: freezed == guildKey ? _self.guildKey : guildKey // ignore: cast_nullable_to_non_nullable -as String?, +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 +as DateTime?,toGuild: freezed == toGuild ? _self.toGuild : toGuild // ignore: cast_nullable_to_non_nullable +as ToGuild?, )); } /// Create a copy of SegmentationModel @@ -90,6 +90,18 @@ $BuyerCopyWith<$Res>? get buyer { return $BuyerCopyWith<$Res>(_self.buyer!, (value) { return _then(_self.copyWith(buyer: value)); }); +}/// Create a copy of SegmentationModel +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$ToGuildCopyWith<$Res>? get toGuild { + if (_self.toGuild == null) { + return null; + } + + return $ToGuildCopyWith<$Res>(_self.toGuild!, (value) { + return _then(_self.copyWith(toGuild: value)); + }); } } @@ -98,16 +110,16 @@ $BuyerCopyWith<$Res>? get buyer { @JsonSerializable() class _SegmentationModel implements SegmentationModel { - const _SegmentationModel({this.key, this.productKey, this.buyer, this.date, this.weight, this.result, this.guildKey}); + const _SegmentationModel({this.key, this.productKey, this.guildKey, 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 int? weight; @override final Buyer? buyer; @override final DateTime? date; -@override final int? weight; -@override final String? result; -@override final String? guildKey; +@override final ToGuild? toGuild; /// Create a copy of SegmentationModel /// with the given fields replaced by the non-null parameter values. @@ -122,16 +134,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.buyer, buyer) || other.buyer == buyer)&&(identical(other.date, date) || other.date == date)&&(identical(other.weight, weight) || other.weight == weight)&&(identical(other.result, result) || other.result == result)&&(identical(other.guildKey, guildKey) || other.guildKey == guildKey)); + 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)); } @JsonKey(includeFromJson: false, includeToJson: false) @override -int get hashCode => Object.hash(runtimeType,key,productKey,buyer,date,weight,result,guildKey); +int get hashCode => Object.hash(runtimeType,key,productKey,guildKey,weight,buyer,date,toGuild); @override String toString() { - return 'SegmentationModel(key: $key, productKey: $productKey, buyer: $buyer, date: $date, weight: $weight, result: $result, guildKey: $guildKey)'; + return 'SegmentationModel(key: $key, productKey: $productKey, guildKey: $guildKey, weight: $weight, buyer: $buyer, date: $date, toGuild: $toGuild)'; } @@ -142,11 +154,11 @@ abstract mixin class _$SegmentationModelCopyWith<$Res> implements $SegmentationM factory _$SegmentationModelCopyWith(_SegmentationModel value, $Res Function(_SegmentationModel) _then) = __$SegmentationModelCopyWithImpl; @override @useResult $Res call({ - String? key, String? productKey, Buyer? buyer, DateTime? date, int? weight, String? result, String? guildKey + String? key, String? productKey, String? guildKey, int? weight, Buyer? buyer, DateTime? date, ToGuild? toGuild }); -@override $BuyerCopyWith<$Res>? get buyer; +@override $BuyerCopyWith<$Res>? get buyer;@override $ToGuildCopyWith<$Res>? get toGuild; } /// @nodoc @@ -159,16 +171,16 @@ 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? buyer = freezed,Object? date = freezed,Object? weight = freezed,Object? result = freezed,Object? guildKey = freezed,}) { +@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,}) { 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?,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 -as DateTime?,weight: freezed == weight ? _self.weight : weight // ignore: cast_nullable_to_non_nullable -as int?,result: freezed == result ? _self.result : result // ignore: cast_nullable_to_non_nullable as String?,guildKey: freezed == guildKey ? _self.guildKey : guildKey // ignore: cast_nullable_to_non_nullable -as String?, +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 +as DateTime?,toGuild: freezed == toGuild ? _self.toGuild : toGuild // ignore: cast_nullable_to_non_nullable +as ToGuild?, )); } @@ -184,6 +196,18 @@ $BuyerCopyWith<$Res>? get buyer { return $BuyerCopyWith<$Res>(_self.buyer!, (value) { return _then(_self.copyWith(buyer: value)); }); +}/// Create a copy of SegmentationModel +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$ToGuildCopyWith<$Res>? get toGuild { + if (_self.toGuild == null) { + return null; + } + + return $ToGuildCopyWith<$Res>(_self.toGuild!, (value) { + return _then(_self.copyWith(toGuild: value)); + }); } } @@ -191,7 +215,7 @@ $BuyerCopyWith<$Res>? get buyer { /// @nodoc mixin _$Buyer { - String? get fullname; String? get mobile; String? get shop; String? get type; + String? get fullname; String? get mobile; String? get shop; /// Create a copy of Buyer /// with the given fields replaced by the non-null parameter values. @JsonKey(includeFromJson: false, includeToJson: false) @@ -204,16 +228,16 @@ $BuyerCopyWith get copyWith => _$BuyerCopyWithImpl(this as Buyer, @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is Buyer&&(identical(other.fullname, fullname) || other.fullname == fullname)&&(identical(other.mobile, mobile) || other.mobile == mobile)&&(identical(other.shop, shop) || other.shop == shop)&&(identical(other.type, type) || other.type == type)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is Buyer&&(identical(other.fullname, fullname) || other.fullname == fullname)&&(identical(other.mobile, mobile) || other.mobile == mobile)&&(identical(other.shop, shop) || other.shop == shop)); } @JsonKey(includeFromJson: false, includeToJson: false) @override -int get hashCode => Object.hash(runtimeType,fullname,mobile,shop,type); +int get hashCode => Object.hash(runtimeType,fullname,mobile,shop); @override String toString() { - return 'Buyer(fullname: $fullname, mobile: $mobile, shop: $shop, type: $type)'; + return 'Buyer(fullname: $fullname, mobile: $mobile, shop: $shop)'; } @@ -224,7 +248,7 @@ abstract mixin class $BuyerCopyWith<$Res> { factory $BuyerCopyWith(Buyer value, $Res Function(Buyer) _then) = _$BuyerCopyWithImpl; @useResult $Res call({ - String? fullname, String? mobile, String? shop, String? type + String? fullname, String? mobile, String? shop }); @@ -241,12 +265,11 @@ class _$BuyerCopyWithImpl<$Res> /// Create a copy of Buyer /// with the given fields replaced by the non-null parameter values. -@pragma('vm:prefer-inline') @override $Res call({Object? fullname = freezed,Object? mobile = freezed,Object? shop = freezed,Object? type = freezed,}) { +@pragma('vm:prefer-inline') @override $Res call({Object? fullname = freezed,Object? mobile = freezed,Object? shop = freezed,}) { return _then(_self.copyWith( fullname: freezed == fullname ? _self.fullname : fullname // ignore: cast_nullable_to_non_nullable as String?,mobile: freezed == mobile ? _self.mobile : mobile // ignore: cast_nullable_to_non_nullable as String?,shop: freezed == shop ? _self.shop : shop // ignore: cast_nullable_to_non_nullable -as String?,type: freezed == type ? _self.type : type // ignore: cast_nullable_to_non_nullable as String?, )); } @@ -258,13 +281,12 @@ as String?, @JsonSerializable() class _Buyer implements Buyer { - const _Buyer({this.fullname, this.mobile, this.shop, this.type}); + const _Buyer({this.fullname, this.mobile, this.shop}); factory _Buyer.fromJson(Map json) => _$BuyerFromJson(json); @override final String? fullname; @override final String? mobile; @override final String? shop; -@override final String? type; /// Create a copy of Buyer /// with the given fields replaced by the non-null parameter values. @@ -279,16 +301,16 @@ Map toJson() { @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is _Buyer&&(identical(other.fullname, fullname) || other.fullname == fullname)&&(identical(other.mobile, mobile) || other.mobile == mobile)&&(identical(other.shop, shop) || other.shop == shop)&&(identical(other.type, type) || other.type == type)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is _Buyer&&(identical(other.fullname, fullname) || other.fullname == fullname)&&(identical(other.mobile, mobile) || other.mobile == mobile)&&(identical(other.shop, shop) || other.shop == shop)); } @JsonKey(includeFromJson: false, includeToJson: false) @override -int get hashCode => Object.hash(runtimeType,fullname,mobile,shop,type); +int get hashCode => Object.hash(runtimeType,fullname,mobile,shop); @override String toString() { - return 'Buyer(fullname: $fullname, mobile: $mobile, shop: $shop, type: $type)'; + return 'Buyer(fullname: $fullname, mobile: $mobile, shop: $shop)'; } @@ -299,7 +321,7 @@ abstract mixin class _$BuyerCopyWith<$Res> implements $BuyerCopyWith<$Res> { factory _$BuyerCopyWith(_Buyer value, $Res Function(_Buyer) _then) = __$BuyerCopyWithImpl; @override @useResult $Res call({ - String? fullname, String? mobile, String? shop, String? type + String? fullname, String? mobile, String? shop }); @@ -316,12 +338,334 @@ class __$BuyerCopyWithImpl<$Res> /// Create a copy of Buyer /// with the given fields replaced by the non-null parameter values. -@override @pragma('vm:prefer-inline') $Res call({Object? fullname = freezed,Object? mobile = freezed,Object? shop = freezed,Object? type = freezed,}) { +@override @pragma('vm:prefer-inline') $Res call({Object? fullname = freezed,Object? mobile = freezed,Object? shop = freezed,}) { return _then(_Buyer( fullname: freezed == fullname ? _self.fullname : fullname // ignore: cast_nullable_to_non_nullable as String?,mobile: freezed == mobile ? _self.mobile : mobile // ignore: cast_nullable_to_non_nullable as String?,shop: freezed == shop ? _self.shop : shop // ignore: cast_nullable_to_non_nullable -as String?,type: freezed == type ? _self.type : type // ignore: cast_nullable_to_non_nullable +as String?, + )); +} + + +} + + +/// @nodoc +mixin _$ToGuild { + + String? get key; String? get guildsName; String? get typeActivity; String? get areaActivity; String? get guildsId; bool? get steward; User? get user; +/// Create a copy of ToGuild +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$ToGuildCopyWith get copyWith => _$ToGuildCopyWithImpl(this as ToGuild, _$identity); + + /// Serializes this ToGuild to a JSON map. + Map toJson(); + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is ToGuild&&(identical(other.key, key) || other.key == key)&&(identical(other.guildsName, guildsName) || other.guildsName == guildsName)&&(identical(other.typeActivity, typeActivity) || other.typeActivity == typeActivity)&&(identical(other.areaActivity, areaActivity) || other.areaActivity == areaActivity)&&(identical(other.guildsId, guildsId) || other.guildsId == guildsId)&&(identical(other.steward, steward) || other.steward == steward)&&(identical(other.user, user) || other.user == user)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,key,guildsName,typeActivity,areaActivity,guildsId,steward,user); + +@override +String toString() { + return 'ToGuild(key: $key, guildsName: $guildsName, typeActivity: $typeActivity, areaActivity: $areaActivity, guildsId: $guildsId, steward: $steward, user: $user)'; +} + + +} + +/// @nodoc +abstract mixin class $ToGuildCopyWith<$Res> { + factory $ToGuildCopyWith(ToGuild value, $Res Function(ToGuild) _then) = _$ToGuildCopyWithImpl; +@useResult +$Res call({ + String? key, String? guildsName, String? typeActivity, String? areaActivity, String? guildsId, bool? steward, User? user +}); + + +$UserCopyWith<$Res>? get user; + +} +/// @nodoc +class _$ToGuildCopyWithImpl<$Res> + implements $ToGuildCopyWith<$Res> { + _$ToGuildCopyWithImpl(this._self, this._then); + + final ToGuild _self; + final $Res Function(ToGuild) _then; + +/// Create a copy of ToGuild +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? key = freezed,Object? guildsName = freezed,Object? typeActivity = freezed,Object? areaActivity = freezed,Object? guildsId = freezed,Object? steward = freezed,Object? user = freezed,}) { + return _then(_self.copyWith( +key: freezed == key ? _self.key : key // ignore: cast_nullable_to_non_nullable +as String?,guildsName: freezed == guildsName ? _self.guildsName : guildsName // ignore: cast_nullable_to_non_nullable +as String?,typeActivity: freezed == typeActivity ? _self.typeActivity : typeActivity // ignore: cast_nullable_to_non_nullable +as String?,areaActivity: freezed == areaActivity ? _self.areaActivity : areaActivity // ignore: cast_nullable_to_non_nullable +as String?,guildsId: freezed == guildsId ? _self.guildsId : guildsId // ignore: cast_nullable_to_non_nullable +as String?,steward: freezed == steward ? _self.steward : steward // ignore: cast_nullable_to_non_nullable +as bool?,user: freezed == user ? _self.user : user // ignore: cast_nullable_to_non_nullable +as User?, + )); +} +/// Create a copy of ToGuild +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$UserCopyWith<$Res>? get user { + if (_self.user == null) { + return null; + } + + return $UserCopyWith<$Res>(_self.user!, (value) { + return _then(_self.copyWith(user: value)); + }); +} +} + + +/// @nodoc +@JsonSerializable() + +class _ToGuild implements ToGuild { + const _ToGuild({this.key, this.guildsName, this.typeActivity, this.areaActivity, this.guildsId, this.steward, this.user}); + factory _ToGuild.fromJson(Map json) => _$ToGuildFromJson(json); + +@override final String? key; +@override final String? guildsName; +@override final String? typeActivity; +@override final String? areaActivity; +@override final String? guildsId; +@override final bool? steward; +@override final User? user; + +/// Create a copy of ToGuild +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$ToGuildCopyWith<_ToGuild> get copyWith => __$ToGuildCopyWithImpl<_ToGuild>(this, _$identity); + +@override +Map toJson() { + return _$ToGuildToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _ToGuild&&(identical(other.key, key) || other.key == key)&&(identical(other.guildsName, guildsName) || other.guildsName == guildsName)&&(identical(other.typeActivity, typeActivity) || other.typeActivity == typeActivity)&&(identical(other.areaActivity, areaActivity) || other.areaActivity == areaActivity)&&(identical(other.guildsId, guildsId) || other.guildsId == guildsId)&&(identical(other.steward, steward) || other.steward == steward)&&(identical(other.user, user) || other.user == user)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,key,guildsName,typeActivity,areaActivity,guildsId,steward,user); + +@override +String toString() { + return 'ToGuild(key: $key, guildsName: $guildsName, typeActivity: $typeActivity, areaActivity: $areaActivity, guildsId: $guildsId, steward: $steward, user: $user)'; +} + + +} + +/// @nodoc +abstract mixin class _$ToGuildCopyWith<$Res> implements $ToGuildCopyWith<$Res> { + factory _$ToGuildCopyWith(_ToGuild value, $Res Function(_ToGuild) _then) = __$ToGuildCopyWithImpl; +@override @useResult +$Res call({ + String? key, String? guildsName, String? typeActivity, String? areaActivity, String? guildsId, bool? steward, User? user +}); + + +@override $UserCopyWith<$Res>? get user; + +} +/// @nodoc +class __$ToGuildCopyWithImpl<$Res> + implements _$ToGuildCopyWith<$Res> { + __$ToGuildCopyWithImpl(this._self, this._then); + + final _ToGuild _self; + final $Res Function(_ToGuild) _then; + +/// Create a copy of ToGuild +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? key = freezed,Object? guildsName = freezed,Object? typeActivity = freezed,Object? areaActivity = freezed,Object? guildsId = freezed,Object? steward = freezed,Object? user = freezed,}) { + return _then(_ToGuild( +key: freezed == key ? _self.key : key // ignore: cast_nullable_to_non_nullable +as String?,guildsName: freezed == guildsName ? _self.guildsName : guildsName // ignore: cast_nullable_to_non_nullable +as String?,typeActivity: freezed == typeActivity ? _self.typeActivity : typeActivity // ignore: cast_nullable_to_non_nullable +as String?,areaActivity: freezed == areaActivity ? _self.areaActivity : areaActivity // ignore: cast_nullable_to_non_nullable +as String?,guildsId: freezed == guildsId ? _self.guildsId : guildsId // ignore: cast_nullable_to_non_nullable +as String?,steward: freezed == steward ? _self.steward : steward // ignore: cast_nullable_to_non_nullable +as bool?,user: freezed == user ? _self.user : user // ignore: cast_nullable_to_non_nullable +as User?, + )); +} + +/// Create a copy of ToGuild +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$UserCopyWith<$Res>? get user { + if (_self.user == null) { + return null; + } + + return $UserCopyWith<$Res>(_self.user!, (value) { + return _then(_self.copyWith(user: value)); + }); +} +} + + +/// @nodoc +mixin _$User { + + String? get fullname; String? get firstName; String? get lastName; String? get mobile; String? get nationalId; String? get city; +/// Create a copy of User +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$UserCopyWith get copyWith => _$UserCopyWithImpl(this as User, _$identity); + + /// Serializes this User to a JSON map. + Map toJson(); + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is User&&(identical(other.fullname, fullname) || other.fullname == fullname)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.mobile, mobile) || other.mobile == mobile)&&(identical(other.nationalId, nationalId) || other.nationalId == nationalId)&&(identical(other.city, city) || other.city == city)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,fullname,firstName,lastName,mobile,nationalId,city); + +@override +String toString() { + return 'User(fullname: $fullname, firstName: $firstName, lastName: $lastName, mobile: $mobile, nationalId: $nationalId, city: $city)'; +} + + +} + +/// @nodoc +abstract mixin class $UserCopyWith<$Res> { + factory $UserCopyWith(User value, $Res Function(User) _then) = _$UserCopyWithImpl; +@useResult +$Res call({ + String? fullname, String? firstName, String? lastName, String? mobile, String? nationalId, String? city +}); + + + + +} +/// @nodoc +class _$UserCopyWithImpl<$Res> + implements $UserCopyWith<$Res> { + _$UserCopyWithImpl(this._self, this._then); + + final User _self; + final $Res Function(User) _then; + +/// Create a copy of User +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? fullname = freezed,Object? firstName = freezed,Object? lastName = freezed,Object? mobile = freezed,Object? nationalId = freezed,Object? city = freezed,}) { + return _then(_self.copyWith( +fullname: freezed == fullname ? _self.fullname : fullname // ignore: cast_nullable_to_non_nullable +as String?,firstName: freezed == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable +as String?,lastName: freezed == lastName ? _self.lastName : lastName // ignore: cast_nullable_to_non_nullable +as String?,mobile: freezed == mobile ? _self.mobile : mobile // ignore: cast_nullable_to_non_nullable +as String?,nationalId: freezed == nationalId ? _self.nationalId : nationalId // ignore: cast_nullable_to_non_nullable +as String?,city: freezed == city ? _self.city : city // ignore: cast_nullable_to_non_nullable +as String?, + )); +} + +} + + +/// @nodoc +@JsonSerializable() + +class _User implements User { + const _User({this.fullname, this.firstName, this.lastName, this.mobile, this.nationalId, this.city}); + factory _User.fromJson(Map json) => _$UserFromJson(json); + +@override final String? fullname; +@override final String? firstName; +@override final String? lastName; +@override final String? mobile; +@override final String? nationalId; +@override final String? city; + +/// Create a copy of User +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$UserCopyWith<_User> get copyWith => __$UserCopyWithImpl<_User>(this, _$identity); + +@override +Map toJson() { + return _$UserToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _User&&(identical(other.fullname, fullname) || other.fullname == fullname)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.mobile, mobile) || other.mobile == mobile)&&(identical(other.nationalId, nationalId) || other.nationalId == nationalId)&&(identical(other.city, city) || other.city == city)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,fullname,firstName,lastName,mobile,nationalId,city); + +@override +String toString() { + return 'User(fullname: $fullname, firstName: $firstName, lastName: $lastName, mobile: $mobile, nationalId: $nationalId, city: $city)'; +} + + +} + +/// @nodoc +abstract mixin class _$UserCopyWith<$Res> implements $UserCopyWith<$Res> { + factory _$UserCopyWith(_User value, $Res Function(_User) _then) = __$UserCopyWithImpl; +@override @useResult +$Res call({ + String? fullname, String? firstName, String? lastName, String? mobile, String? nationalId, String? city +}); + + + + +} +/// @nodoc +class __$UserCopyWithImpl<$Res> + implements _$UserCopyWith<$Res> { + __$UserCopyWithImpl(this._self, this._then); + + final _User _self; + final $Res Function(_User) _then; + +/// Create a copy of User +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? fullname = freezed,Object? firstName = freezed,Object? lastName = freezed,Object? mobile = freezed,Object? nationalId = freezed,Object? city = freezed,}) { + return _then(_User( +fullname: freezed == fullname ? _self.fullname : fullname // ignore: cast_nullable_to_non_nullable +as String?,firstName: freezed == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable +as String?,lastName: freezed == lastName ? _self.lastName : lastName // ignore: cast_nullable_to_non_nullable +as String?,mobile: freezed == mobile ? _self.mobile : mobile // ignore: cast_nullable_to_non_nullable +as String?,nationalId: freezed == nationalId ? _self.nationalId : nationalId // ignore: cast_nullable_to_non_nullable +as String?,city: freezed == city ? _self.city : city // ignore: cast_nullable_to_non_nullable as String?, )); } 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 4834697..a51a7ee 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 @@ -10,38 +10,78 @@ _SegmentationModel _$SegmentationModelFromJson(Map json) => _SegmentationModel( key: json['key'] as String?, productKey: json['product_key'] as String?, + guildKey: json['guild_key'] as String?, + weight: (json['weight'] as num?)?.toInt(), buyer: json['buyer'] == null ? null : Buyer.fromJson(json['buyer'] as Map), date: json['date'] == null ? null : DateTime.parse(json['date'] as String), - weight: (json['weight'] as num?)?.toInt(), - result: json['result'] as String?, - guildKey: json['guild_key'] as String?, + toGuild: json['to_guild'] == null + ? null + : ToGuild.fromJson(json['to_guild'] as Map), ); Map _$SegmentationModelToJson(_SegmentationModel instance) => { 'key': instance.key, 'product_key': instance.productKey, + 'guild_key': instance.guildKey, + 'weight': instance.weight, 'buyer': instance.buyer, 'date': instance.date?.toIso8601String(), - 'weight': instance.weight, - 'result': instance.result, - 'guild_key': instance.guildKey, + 'to_guild': instance.toGuild, }; _Buyer _$BuyerFromJson(Map json) => _Buyer( fullname: json['fullname'] as String?, mobile: json['mobile'] as String?, shop: json['shop'] as String?, - type: json['type'] as String?, ); Map _$BuyerToJson(_Buyer instance) => { 'fullname': instance.fullname, 'mobile': instance.mobile, 'shop': instance.shop, - 'type': instance.type, +}; + +_ToGuild _$ToGuildFromJson(Map json) => _ToGuild( + key: json['key'] as String?, + guildsName: json['guilds_name'] as String?, + typeActivity: json['type_activity'] as String?, + areaActivity: json['area_activity'] as String?, + guildsId: json['guilds_id'] as String?, + steward: json['steward'] as bool?, + user: json['user'] == null + ? null + : User.fromJson(json['user'] as Map), +); + +Map _$ToGuildToJson(_ToGuild instance) => { + 'key': instance.key, + 'guilds_name': instance.guildsName, + 'type_activity': instance.typeActivity, + 'area_activity': instance.areaActivity, + 'guilds_id': instance.guildsId, + 'steward': instance.steward, + 'user': instance.user, +}; + +_User _$UserFromJson(Map json) => _User( + fullname: json['fullname'] as String?, + firstName: json['first_name'] as String?, + lastName: json['last_name'] as String?, + mobile: json['mobile'] as String?, + nationalId: json['national_id'] as String?, + city: json['city'] as String?, +); + +Map _$UserToJson(_User instance) => { + 'fullname': instance.fullname, + 'first_name': instance.firstName, + 'last_name': instance.lastName, + 'mobile': instance.mobile, + 'national_id': instance.nationalId, + 'city': instance.city, }; diff --git a/packages/chicken/lib/presentation/pages/segmentation/logic.dart b/packages/chicken/lib/presentation/pages/segmentation/logic.dart index f22d1f5..1bf5e90 100644 --- a/packages/chicken/lib/presentation/pages/segmentation/logic.dart +++ b/packages/chicken/lib/presentation/pages/segmentation/logic.dart @@ -35,7 +35,6 @@ class SegmentationLogic extends GetxController { RxList guildsModel = [].obs; - @override void onInit() { super.onInit(); @@ -82,12 +81,16 @@ class SegmentationLogic extends GetxController { void clearForm() { weightController.text = '0'; selectedSegment.value = null; + selectedGuildModel.value = null; } void validateForm() { var weight = int.tryParse(weightController.text.clearComma.trim()); isSubmitButtonEnabled.value = - selectedProduct.value != null && weightController.text.isNotEmpty && weight! > 0; + selectedProduct.value != null && + weightController.text.isNotEmpty && + weight! > 0 && + (saleType.value == 1 || (saleType.value == 2 && selectedGuildModel.value != null)); } Future getAllSegmentation([bool isLoadingMore = false]) async { @@ -177,9 +180,9 @@ class SegmentationLogic extends GetxController { weight: int.tryParse(weightController.text.clearComma) ?? 0, ); if (saleType.value == 2) { - segmentationModel.copyWith(guildKey: selectedGuildModel.value?.key); + segmentationModel = segmentationModel.copyWith(guildKey: selectedGuildModel.value?.key); } - safeCall( + await safeCall( call: () async => await rootLogic.chickenRepository.createSegmentation( token: rootLogic.tokenService.accessToken.value!, model: segmentationModel, diff --git a/packages/chicken/lib/presentation/pages/segmentation/view.dart b/packages/chicken/lib/presentation/pages/segmentation/view.dart index 361ec32..b3b898d 100644 --- a/packages/chicken/lib/presentation/pages/segmentation/view.dart +++ b/packages/chicken/lib/presentation/pages/segmentation/view.dart @@ -83,10 +83,21 @@ class SegmentationPage extends GetView { SizedBox(width: 12), Expanded( flex: 3, - child: Text( - item.date?.formattedJalaliDate ?? 'N/A', - textAlign: TextAlign.center, - style: AppFonts.yekan12.copyWith(color: AppColor.bgDark), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + spacing: 4, + children: [ + Text( + item.toGuild != null ? 'مباشر' : 'قطعه‌بند', + textAlign: TextAlign.center, + style: AppFonts.yekan14.copyWith(color: AppColor.blueNormal), + ), + Text( + item.date?.formattedJalaliDate ?? 'N/A', + textAlign: TextAlign.center, + style: AppFonts.yekan12.copyWith(color: AppColor.bgDark), + ), + ], ), ), SizedBox(width: 4), @@ -96,14 +107,18 @@ class SegmentationPage extends GetView { mainAxisAlignment: MainAxisAlignment.center, children: [ Text( - item.buyer?.fullname ?? 'N/A', + item.toGuild != null + ? item.toGuild?.user?.fullname ?? 'N/A' + : item.buyer?.fullname ?? 'N/A', textAlign: TextAlign.center, style: AppFonts.yekan14.copyWith(color: AppColor.blueNormal), ), SizedBox(height: 2), Text( - item.buyer?.shop ?? 'N/A', + item.toGuild != null + ? item.toGuild?.guildsName ?? 'N/A' + : item.buyer?.shop ?? 'N/A', textAlign: TextAlign.center, style: AppFonts.yekan14.copyWith(color: AppColor.bgDark), ), @@ -111,18 +126,10 @@ class SegmentationPage extends GetView { ), ), SizedBox(width: 4), - Expanded( - flex: 4, - child: Text( - item.date?.formattedJalaliDate, - textAlign: TextAlign.center, - style: AppFonts.yekan12.copyWith(color: AppColor.bgDark), - ), - ), Expanded( flex: 2, child: Text( - '${item.weight} KG', + '${item.weight.separatedByComma} KG', textAlign: TextAlign.center, style: AppFonts.yekan12.copyWith(color: AppColor.bgDark), ), @@ -178,9 +185,25 @@ class SegmentationPage extends GetView { ], ), ), - buildRow(title: 'مشخصات خریدار', value: item.buyer?.fullname ?? 'N/A'), - buildRow(title: 'تلفن خریدار', value: item.buyer?.mobile ?? 'N/A'), - buildRow(title: 'نام واحد', value: item.buyer?.shop ?? 'N/A'), + buildRow( + title: 'مشخصات خریدار', + value: item.toGuild != null + ? item.toGuild?.user?.fullname ?? 'N/A' + : item.buyer?.fullname ?? 'N/A', + ), + buildRow( + title: 'تلفن خریدار', + value: item.toGuild != null + ? item.toGuild?.user?.mobile ?? 'N/A' + : item.buyer?.mobile ?? 'N/A', + ), + buildRow( + title: 'نام واحد', + value: item.toGuild != null + ? item.toGuild?.guildsName ?? 'N/A' + : item.buyer?.shop ?? 'N/A', + ), + buildRow(title: 'ماهیت', value: item.toGuild != null ? 'مباشر' : 'قطعه‌بند'), buildRow(title: 'وزن قطعه‌بندی', value: '${item.weight?.separatedByComma}'), Row( @@ -268,7 +291,7 @@ class SegmentationPage extends GetView { controller.selectedGuildModel.refresh(); }, ), - Text('خودم', style: AppFonts.yekan14), + Text('قطعه‌بندی(مباشر)', style: AppFonts.yekan14), SizedBox(width: 12), Radio( value: 2, @@ -277,7 +300,7 @@ class SegmentationPage extends GetView { controller.saleType.value = value!; }, ), - Text('صنف/مباشر', style: AppFonts.yekan14), + Text('تخصیص به قطعه‌بند', style: AppFonts.yekan14), ], ); }, controller.saleType),