fixed pagination

This commit is contained in:
Username1548
2025-03-13 02:30:10 +07:00
parent 102dc9ee55
commit 9d53760137
38 changed files with 778 additions and 294 deletions

View File

@@ -1,4 +1,4 @@
import 'package:eatvio_app/features/feed/models/plan_pagination_model.dart';
import 'package:eatvio_app/features/plans/enums/chosen_plan_state_enum.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
part 'chosen_plan_model.freezed.dart';
@@ -11,8 +11,8 @@ class ChosenPlanModel with _$ChosenPlanModel {
@JsonKey() required int id,
@JsonKey(name: 'option_type') required String optionType,
@JsonKey(name: 'start_date') required DateTime startDate,
@JsonKey(name: 'last_state') required ChosenPlanStateEnum chosenPlanState,
@JsonKey(name: 'chat_id') required String chatId,
@JsonKey(name: 'plan') required PlanModel plan,
}) = _ChosenPlanModel;

View File

@@ -26,10 +26,10 @@ mixin _$ChosenPlanModel {
String get optionType => throw _privateConstructorUsedError;
@JsonKey(name: 'start_date')
DateTime get startDate => throw _privateConstructorUsedError;
@JsonKey(name: 'last_state')
ChosenPlanStateEnum get chosenPlanState => throw _privateConstructorUsedError;
@JsonKey(name: 'chat_id')
String get chatId => throw _privateConstructorUsedError;
@JsonKey(name: 'plan')
PlanModel get plan => throw _privateConstructorUsedError;
/// Serializes this ChosenPlanModel to a JSON map.
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
@@ -51,10 +51,8 @@ abstract class $ChosenPlanModelCopyWith<$Res> {
{@JsonKey() int id,
@JsonKey(name: 'option_type') String optionType,
@JsonKey(name: 'start_date') DateTime startDate,
@JsonKey(name: 'chat_id') String chatId,
@JsonKey(name: 'plan') PlanModel plan});
$PlanModelCopyWith<$Res> get plan;
@JsonKey(name: 'last_state') ChosenPlanStateEnum chosenPlanState,
@JsonKey(name: 'chat_id') String chatId});
}
/// @nodoc
@@ -75,8 +73,8 @@ class _$ChosenPlanModelCopyWithImpl<$Res, $Val extends ChosenPlanModel>
Object? id = null,
Object? optionType = null,
Object? startDate = null,
Object? chosenPlanState = null,
Object? chatId = null,
Object? plan = null,
}) {
return _then(_value.copyWith(
id: null == id
@@ -91,26 +89,16 @@ class _$ChosenPlanModelCopyWithImpl<$Res, $Val extends ChosenPlanModel>
? _value.startDate
: startDate // ignore: cast_nullable_to_non_nullable
as DateTime,
chosenPlanState: null == chosenPlanState
? _value.chosenPlanState
: chosenPlanState // ignore: cast_nullable_to_non_nullable
as ChosenPlanStateEnum,
chatId: null == chatId
? _value.chatId
: chatId // ignore: cast_nullable_to_non_nullable
as String,
plan: null == plan
? _value.plan
: plan // ignore: cast_nullable_to_non_nullable
as PlanModel,
) as $Val);
}
/// Create a copy of ChosenPlanModel
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$PlanModelCopyWith<$Res> get plan {
return $PlanModelCopyWith<$Res>(_value.plan, (value) {
return _then(_value.copyWith(plan: value) as $Val);
});
}
}
/// @nodoc
@@ -125,11 +113,8 @@ abstract class _$$ChosenPlanModelImplCopyWith<$Res>
{@JsonKey() int id,
@JsonKey(name: 'option_type') String optionType,
@JsonKey(name: 'start_date') DateTime startDate,
@JsonKey(name: 'chat_id') String chatId,
@JsonKey(name: 'plan') PlanModel plan});
@override
$PlanModelCopyWith<$Res> get plan;
@JsonKey(name: 'last_state') ChosenPlanStateEnum chosenPlanState,
@JsonKey(name: 'chat_id') String chatId});
}
/// @nodoc
@@ -148,8 +133,8 @@ class __$$ChosenPlanModelImplCopyWithImpl<$Res>
Object? id = null,
Object? optionType = null,
Object? startDate = null,
Object? chosenPlanState = null,
Object? chatId = null,
Object? plan = null,
}) {
return _then(_$ChosenPlanModelImpl(
id: null == id
@@ -164,14 +149,14 @@ class __$$ChosenPlanModelImplCopyWithImpl<$Res>
? _value.startDate
: startDate // ignore: cast_nullable_to_non_nullable
as DateTime,
chosenPlanState: null == chosenPlanState
? _value.chosenPlanState
: chosenPlanState // ignore: cast_nullable_to_non_nullable
as ChosenPlanStateEnum,
chatId: null == chatId
? _value.chatId
: chatId // ignore: cast_nullable_to_non_nullable
as String,
plan: null == plan
? _value.plan
: plan // ignore: cast_nullable_to_non_nullable
as PlanModel,
));
}
}
@@ -183,8 +168,8 @@ class _$ChosenPlanModelImpl implements _ChosenPlanModel {
{@JsonKey() required this.id,
@JsonKey(name: 'option_type') required this.optionType,
@JsonKey(name: 'start_date') required this.startDate,
@JsonKey(name: 'chat_id') required this.chatId,
@JsonKey(name: 'plan') required this.plan});
@JsonKey(name: 'last_state') required this.chosenPlanState,
@JsonKey(name: 'chat_id') required this.chatId});
factory _$ChosenPlanModelImpl.fromJson(Map<String, dynamic> json) =>
_$$ChosenPlanModelImplFromJson(json);
@@ -199,15 +184,15 @@ class _$ChosenPlanModelImpl implements _ChosenPlanModel {
@JsonKey(name: 'start_date')
final DateTime startDate;
@override
@JsonKey(name: 'last_state')
final ChosenPlanStateEnum chosenPlanState;
@override
@JsonKey(name: 'chat_id')
final String chatId;
@override
@JsonKey(name: 'plan')
final PlanModel plan;
@override
String toString() {
return 'ChosenPlanModel(id: $id, optionType: $optionType, startDate: $startDate, chatId: $chatId, plan: $plan)';
return 'ChosenPlanModel(id: $id, optionType: $optionType, startDate: $startDate, chosenPlanState: $chosenPlanState, chatId: $chatId)';
}
@override
@@ -220,14 +205,15 @@ class _$ChosenPlanModelImpl implements _ChosenPlanModel {
other.optionType == optionType) &&
(identical(other.startDate, startDate) ||
other.startDate == startDate) &&
(identical(other.chatId, chatId) || other.chatId == chatId) &&
(identical(other.plan, plan) || other.plan == plan));
(identical(other.chosenPlanState, chosenPlanState) ||
other.chosenPlanState == chosenPlanState) &&
(identical(other.chatId, chatId) || other.chatId == chatId));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode =>
Object.hash(runtimeType, id, optionType, startDate, chatId, plan);
int get hashCode => Object.hash(
runtimeType, id, optionType, startDate, chosenPlanState, chatId);
/// Create a copy of ChosenPlanModel
/// with the given fields replaced by the non-null parameter values.
@@ -251,8 +237,9 @@ abstract class _ChosenPlanModel implements ChosenPlanModel {
{@JsonKey() required final int id,
@JsonKey(name: 'option_type') required final String optionType,
@JsonKey(name: 'start_date') required final DateTime startDate,
@JsonKey(name: 'chat_id') required final String chatId,
@JsonKey(name: 'plan') required final PlanModel plan}) =
@JsonKey(name: 'last_state')
required final ChosenPlanStateEnum chosenPlanState,
@JsonKey(name: 'chat_id') required final String chatId}) =
_$ChosenPlanModelImpl;
factory _ChosenPlanModel.fromJson(Map<String, dynamic> json) =
@@ -268,11 +255,11 @@ abstract class _ChosenPlanModel implements ChosenPlanModel {
@JsonKey(name: 'start_date')
DateTime get startDate;
@override
@JsonKey(name: 'last_state')
ChosenPlanStateEnum get chosenPlanState;
@override
@JsonKey(name: 'chat_id')
String get chatId;
@override
@JsonKey(name: 'plan')
PlanModel get plan;
/// Create a copy of ChosenPlanModel
/// with the given fields replaced by the non-null parameter values.

View File

@@ -12,8 +12,9 @@ _$ChosenPlanModelImpl _$$ChosenPlanModelImplFromJson(
id: (json['id'] as num).toInt(),
optionType: json['option_type'] as String,
startDate: DateTime.parse(json['start_date'] as String),
chosenPlanState:
$enumDecode(_$ChosenPlanStateEnumEnumMap, json['last_state']),
chatId: json['chat_id'] as String,
plan: PlanModel.fromJson(json['plan'] as Map<String, dynamic>),
);
Map<String, dynamic> _$$ChosenPlanModelImplToJson(
@@ -22,6 +23,23 @@ Map<String, dynamic> _$$ChosenPlanModelImplToJson(
'id': instance.id,
'option_type': instance.optionType,
'start_date': instance.startDate.toIso8601String(),
'last_state': _$ChosenPlanStateEnumEnumMap[instance.chosenPlanState]!,
'chat_id': instance.chatId,
'plan': instance.plan,
};
const _$ChosenPlanStateEnumEnumMap = {
ChosenPlanStateEnum.stateInited: 'initied',
ChosenPlanStateEnum.stateStartDateHasBeenSet: 'start_date_has_been_set',
ChosenPlanStateEnum.stateInCoordination: 'in_coordination',
ChosenPlanStateEnum.stateStarted: 'started',
ChosenPlanStateEnum.stateInProgress: 'in_progress',
ChosenPlanStateEnum.statePendingPayment: 'pending_payment',
ChosenPlanStateEnum.stateConfirmedByConsultant: 'confirmed_by_consultant',
ChosenPlanStateEnum.statePaid: 'paid',
ChosenPlanStateEnum.stateCanceledByTheInitiator: 'canceled_by_the_initiator',
ChosenPlanStateEnum.stateLastDayStarted: 'last_day_started',
ChosenPlanStateEnum.stateLastDayFinished: 'last_day_finished',
ChosenPlanStateEnum.stateComplained: 'complained',
ChosenPlanStateEnum.stateDone: 'done',
ChosenPlanStateEnum.stateChargeWasCollected: 'charge_was_collected',
};