payment
This commit is contained in:
@@ -1500,6 +1500,8 @@ abstract class _$$OrderAddedItemsImplCopyWith<$Res> {
|
||||
) = __$$OrderAddedItemsImplCopyWithImpl<$Res>;
|
||||
@useResult
|
||||
$Res call({Order? order});
|
||||
|
||||
$OrderCopyWith<$Res>? get order;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@@ -1525,6 +1527,20 @@ class __$$OrderAddedItemsImplCopyWithImpl<$Res>
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// Create a copy of CheckoutFormEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$OrderCopyWith<$Res>? get order {
|
||||
if (_value.order == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $OrderCopyWith<$Res>(_value.order!, (value) {
|
||||
return _then(_value.copyWith(order: value));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@@ -1720,6 +1736,7 @@ abstract class $CheckoutFormStateCopyWith<$Res> {
|
||||
bool isLoading,
|
||||
});
|
||||
|
||||
$OrderCopyWith<$Res>? get orderAdded;
|
||||
$TableCopyWith<$Res>? get table;
|
||||
}
|
||||
|
||||
@@ -1811,6 +1828,20 @@ class _$CheckoutFormStateCopyWithImpl<$Res, $Val extends CheckoutFormState>
|
||||
);
|
||||
}
|
||||
|
||||
/// Create a copy of CheckoutFormState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$OrderCopyWith<$Res>? get orderAdded {
|
||||
if (_value.orderAdded == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $OrderCopyWith<$Res>(_value.orderAdded!, (value) {
|
||||
return _then(_value.copyWith(orderAdded: value) as $Val);
|
||||
});
|
||||
}
|
||||
|
||||
/// Create a copy of CheckoutFormState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@@ -1851,6 +1882,8 @@ abstract class _$$CheckoutFormStateImplCopyWith<$Res>
|
||||
bool isLoading,
|
||||
});
|
||||
|
||||
@override
|
||||
$OrderCopyWith<$Res>? get orderAdded;
|
||||
@override
|
||||
$TableCopyWith<$Res>? get table;
|
||||
}
|
||||
|
||||
@@ -108,6 +108,7 @@ class OrderLoaderBloc extends Bloc<OrderLoaderEvent, OrderLoaderState> {
|
||||
failureOption: none(),
|
||||
page: state.page + 1,
|
||||
hasReachedMax: orders.orders.length < 10,
|
||||
totalOrder: orders.totalCount,
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
@@ -955,6 +955,7 @@ mixin _$OrderLoaderState {
|
||||
String? get search => throw _privateConstructorUsedError;
|
||||
DateTime get startDate => throw _privateConstructorUsedError;
|
||||
DateTime get endDate => throw _privateConstructorUsedError;
|
||||
int get totalOrder => throw _privateConstructorUsedError;
|
||||
bool get isFetching => throw _privateConstructorUsedError;
|
||||
bool get isFetchingById => throw _privateConstructorUsedError;
|
||||
bool get hasReachedMax => throw _privateConstructorUsedError;
|
||||
@@ -983,6 +984,7 @@ abstract class $OrderLoaderStateCopyWith<$Res> {
|
||||
String? search,
|
||||
DateTime startDate,
|
||||
DateTime endDate,
|
||||
int totalOrder,
|
||||
bool isFetching,
|
||||
bool isFetchingById,
|
||||
bool hasReachedMax,
|
||||
@@ -1016,6 +1018,7 @@ class _$OrderLoaderStateCopyWithImpl<$Res, $Val extends OrderLoaderState>
|
||||
Object? search = freezed,
|
||||
Object? startDate = null,
|
||||
Object? endDate = null,
|
||||
Object? totalOrder = null,
|
||||
Object? isFetching = null,
|
||||
Object? isFetchingById = null,
|
||||
Object? hasReachedMax = null,
|
||||
@@ -1055,6 +1058,10 @@ class _$OrderLoaderStateCopyWithImpl<$Res, $Val extends OrderLoaderState>
|
||||
? _value.endDate
|
||||
: endDate // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
totalOrder: null == totalOrder
|
||||
? _value.totalOrder
|
||||
: totalOrder // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
isFetching: null == isFetching
|
||||
? _value.isFetching
|
||||
: isFetching // ignore: cast_nullable_to_non_nullable
|
||||
@@ -1119,6 +1126,7 @@ abstract class _$$OrderLoaderStateImplCopyWith<$Res>
|
||||
String? search,
|
||||
DateTime startDate,
|
||||
DateTime endDate,
|
||||
int totalOrder,
|
||||
bool isFetching,
|
||||
bool isFetchingById,
|
||||
bool hasReachedMax,
|
||||
@@ -1153,6 +1161,7 @@ class __$$OrderLoaderStateImplCopyWithImpl<$Res>
|
||||
Object? search = freezed,
|
||||
Object? startDate = null,
|
||||
Object? endDate = null,
|
||||
Object? totalOrder = null,
|
||||
Object? isFetching = null,
|
||||
Object? isFetchingById = null,
|
||||
Object? hasReachedMax = null,
|
||||
@@ -1192,6 +1201,10 @@ class __$$OrderLoaderStateImplCopyWithImpl<$Res>
|
||||
? _value.endDate
|
||||
: endDate // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
totalOrder: null == totalOrder
|
||||
? _value.totalOrder
|
||||
: totalOrder // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
isFetching: null == isFetching
|
||||
? _value.isFetching
|
||||
: isFetching // ignore: cast_nullable_to_non_nullable
|
||||
@@ -1225,6 +1238,7 @@ class _$OrderLoaderStateImpl implements _OrderLoaderState {
|
||||
this.search,
|
||||
required this.startDate,
|
||||
required this.endDate,
|
||||
this.totalOrder = 0,
|
||||
this.isFetching = false,
|
||||
this.isFetchingById = false,
|
||||
this.hasReachedMax = false,
|
||||
@@ -1255,6 +1269,9 @@ class _$OrderLoaderStateImpl implements _OrderLoaderState {
|
||||
final DateTime endDate;
|
||||
@override
|
||||
@JsonKey()
|
||||
final int totalOrder;
|
||||
@override
|
||||
@JsonKey()
|
||||
final bool isFetching;
|
||||
@override
|
||||
@JsonKey()
|
||||
@@ -1268,7 +1285,7 @@ class _$OrderLoaderStateImpl implements _OrderLoaderState {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'OrderLoaderState(orders: $orders, failureOption: $failureOption, failureOptionGetById: $failureOptionGetById, order: $order, selectedOrder: $selectedOrder, search: $search, startDate: $startDate, endDate: $endDate, isFetching: $isFetching, isFetchingById: $isFetchingById, hasReachedMax: $hasReachedMax, page: $page)';
|
||||
return 'OrderLoaderState(orders: $orders, failureOption: $failureOption, failureOptionGetById: $failureOptionGetById, order: $order, selectedOrder: $selectedOrder, search: $search, startDate: $startDate, endDate: $endDate, totalOrder: $totalOrder, isFetching: $isFetching, isFetchingById: $isFetchingById, hasReachedMax: $hasReachedMax, page: $page)';
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -1288,6 +1305,8 @@ class _$OrderLoaderStateImpl implements _OrderLoaderState {
|
||||
(identical(other.startDate, startDate) ||
|
||||
other.startDate == startDate) &&
|
||||
(identical(other.endDate, endDate) || other.endDate == endDate) &&
|
||||
(identical(other.totalOrder, totalOrder) ||
|
||||
other.totalOrder == totalOrder) &&
|
||||
(identical(other.isFetching, isFetching) ||
|
||||
other.isFetching == isFetching) &&
|
||||
(identical(other.isFetchingById, isFetchingById) ||
|
||||
@@ -1308,6 +1327,7 @@ class _$OrderLoaderStateImpl implements _OrderLoaderState {
|
||||
search,
|
||||
startDate,
|
||||
endDate,
|
||||
totalOrder,
|
||||
isFetching,
|
||||
isFetchingById,
|
||||
hasReachedMax,
|
||||
@@ -1336,6 +1356,7 @@ abstract class _OrderLoaderState implements OrderLoaderState {
|
||||
final String? search,
|
||||
required final DateTime startDate,
|
||||
required final DateTime endDate,
|
||||
final int totalOrder,
|
||||
final bool isFetching,
|
||||
final bool isFetchingById,
|
||||
final bool hasReachedMax,
|
||||
@@ -1359,6 +1380,8 @@ abstract class _OrderLoaderState implements OrderLoaderState {
|
||||
@override
|
||||
DateTime get endDate;
|
||||
@override
|
||||
int get totalOrder;
|
||||
@override
|
||||
bool get isFetching;
|
||||
@override
|
||||
bool get isFetchingById;
|
||||
|
||||
@@ -11,6 +11,7 @@ class OrderLoaderState with _$OrderLoaderState {
|
||||
String? search,
|
||||
required DateTime startDate,
|
||||
required DateTime endDate,
|
||||
@Default(0) int totalOrder,
|
||||
@Default(false) bool isFetching,
|
||||
@Default(false) bool isFetchingById,
|
||||
@Default(false) bool hasReachedMax,
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:dartz/dartz.dart' hide Order;
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:injectable/injectable.dart' hide Order;
|
||||
|
||||
import '../../../domain/order/order.dart';
|
||||
import '../../../domain/payment_method/payment_method.dart';
|
||||
|
||||
part 'payment_form_event.dart';
|
||||
part 'payment_form_state.dart';
|
||||
part 'payment_form_bloc.freezed.dart';
|
||||
|
||||
@injectable
|
||||
class PaymentFormBloc extends Bloc<PaymentFormEvent, PaymentFormState> {
|
||||
final IOrderRepository _repository;
|
||||
PaymentFormBloc(this._repository) : super(PaymentFormState.initial()) {
|
||||
on<PaymentFormEvent>(_onPaymentFormEvent);
|
||||
}
|
||||
|
||||
Future<void> _onPaymentFormEvent(
|
||||
PaymentFormEvent event,
|
||||
Emitter<PaymentFormState> emit,
|
||||
) {
|
||||
return event.map(
|
||||
setOrder: (e) async {
|
||||
List<OrderItem> pendingItems = e.order.orderItems
|
||||
.where((item) => item.status == 'pending')
|
||||
.toList();
|
||||
|
||||
emit(state.copyWith(order: e.order, pendingItems: pendingItems));
|
||||
},
|
||||
setPaymentMethod: (e) async {
|
||||
emit(state.copyWith(paymentMethod: e.paymentMethod));
|
||||
},
|
||||
submitted: (e) async {
|
||||
Either<OrderFailure, Payment> failureOrPayment;
|
||||
|
||||
emit(state.copyWith(isSubmitting: true, failureOrPayment: none()));
|
||||
|
||||
final request = PaymentRequest(
|
||||
orderId: state.order.id,
|
||||
paymentMethodId: state.paymentMethod?.id ?? '',
|
||||
amount: state.order.totalAmount,
|
||||
transactionId: '',
|
||||
splitNumber: 1,
|
||||
splitTotal: 1,
|
||||
splitDescription: '',
|
||||
paymentOrderItems: state.pendingItems
|
||||
.map(
|
||||
(item) => PaymentItemRequest(
|
||||
orderItemId: item.id,
|
||||
amount: item.totalPrice,
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
);
|
||||
|
||||
failureOrPayment = await _repository.createPayment(request: request);
|
||||
|
||||
emit(
|
||||
state.copyWith(
|
||||
isSubmitting: false,
|
||||
failureOrPayment: optionOf(failureOrPayment),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,795 @@
|
||||
// coverage:ignore-file
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
||||
|
||||
part of 'payment_form_bloc.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
T _$identity<T>(T value) => value;
|
||||
|
||||
final _privateConstructorUsedError = UnsupportedError(
|
||||
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models',
|
||||
);
|
||||
|
||||
/// @nodoc
|
||||
mixin _$PaymentFormEvent {
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function(Order order) setOrder,
|
||||
required TResult Function(PaymentMethod paymentMethod) setPaymentMethod,
|
||||
required TResult Function() submitted,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function(Order order)? setOrder,
|
||||
TResult? Function(PaymentMethod paymentMethod)? setPaymentMethod,
|
||||
TResult? Function()? submitted,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function(Order order)? setOrder,
|
||||
TResult Function(PaymentMethod paymentMethod)? setPaymentMethod,
|
||||
TResult Function()? submitted,
|
||||
required TResult orElse(),
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_SetOrder value) setOrder,
|
||||
required TResult Function(_SetPayment value) setPaymentMethod,
|
||||
required TResult Function(_Submitted value) submitted,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_SetOrder value)? setOrder,
|
||||
TResult? Function(_SetPayment value)? setPaymentMethod,
|
||||
TResult? Function(_Submitted value)? submitted,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_SetOrder value)? setOrder,
|
||||
TResult Function(_SetPayment value)? setPaymentMethod,
|
||||
TResult Function(_Submitted value)? submitted,
|
||||
required TResult orElse(),
|
||||
}) => throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $PaymentFormEventCopyWith<$Res> {
|
||||
factory $PaymentFormEventCopyWith(
|
||||
PaymentFormEvent value,
|
||||
$Res Function(PaymentFormEvent) then,
|
||||
) = _$PaymentFormEventCopyWithImpl<$Res, PaymentFormEvent>;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$PaymentFormEventCopyWithImpl<$Res, $Val extends PaymentFormEvent>
|
||||
implements $PaymentFormEventCopyWith<$Res> {
|
||||
_$PaymentFormEventCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of PaymentFormEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$SetOrderImplCopyWith<$Res> {
|
||||
factory _$$SetOrderImplCopyWith(
|
||||
_$SetOrderImpl value,
|
||||
$Res Function(_$SetOrderImpl) then,
|
||||
) = __$$SetOrderImplCopyWithImpl<$Res>;
|
||||
@useResult
|
||||
$Res call({Order order});
|
||||
|
||||
$OrderCopyWith<$Res> get order;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$SetOrderImplCopyWithImpl<$Res>
|
||||
extends _$PaymentFormEventCopyWithImpl<$Res, _$SetOrderImpl>
|
||||
implements _$$SetOrderImplCopyWith<$Res> {
|
||||
__$$SetOrderImplCopyWithImpl(
|
||||
_$SetOrderImpl _value,
|
||||
$Res Function(_$SetOrderImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of PaymentFormEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({Object? order = null}) {
|
||||
return _then(
|
||||
_$SetOrderImpl(
|
||||
null == order
|
||||
? _value.order
|
||||
: order // ignore: cast_nullable_to_non_nullable
|
||||
as Order,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// Create a copy of PaymentFormEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$OrderCopyWith<$Res> get order {
|
||||
return $OrderCopyWith<$Res>(_value.order, (value) {
|
||||
return _then(_value.copyWith(order: value));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$SetOrderImpl implements _SetOrder {
|
||||
const _$SetOrderImpl(this.order);
|
||||
|
||||
@override
|
||||
final Order order;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'PaymentFormEvent.setOrder(order: $order)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$SetOrderImpl &&
|
||||
(identical(other.order, order) || other.order == order));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, order);
|
||||
|
||||
/// Create a copy of PaymentFormEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$SetOrderImplCopyWith<_$SetOrderImpl> get copyWith =>
|
||||
__$$SetOrderImplCopyWithImpl<_$SetOrderImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function(Order order) setOrder,
|
||||
required TResult Function(PaymentMethod paymentMethod) setPaymentMethod,
|
||||
required TResult Function() submitted,
|
||||
}) {
|
||||
return setOrder(order);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function(Order order)? setOrder,
|
||||
TResult? Function(PaymentMethod paymentMethod)? setPaymentMethod,
|
||||
TResult? Function()? submitted,
|
||||
}) {
|
||||
return setOrder?.call(order);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function(Order order)? setOrder,
|
||||
TResult Function(PaymentMethod paymentMethod)? setPaymentMethod,
|
||||
TResult Function()? submitted,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (setOrder != null) {
|
||||
return setOrder(order);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_SetOrder value) setOrder,
|
||||
required TResult Function(_SetPayment value) setPaymentMethod,
|
||||
required TResult Function(_Submitted value) submitted,
|
||||
}) {
|
||||
return setOrder(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_SetOrder value)? setOrder,
|
||||
TResult? Function(_SetPayment value)? setPaymentMethod,
|
||||
TResult? Function(_Submitted value)? submitted,
|
||||
}) {
|
||||
return setOrder?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_SetOrder value)? setOrder,
|
||||
TResult Function(_SetPayment value)? setPaymentMethod,
|
||||
TResult Function(_Submitted value)? submitted,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (setOrder != null) {
|
||||
return setOrder(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _SetOrder implements PaymentFormEvent {
|
||||
const factory _SetOrder(final Order order) = _$SetOrderImpl;
|
||||
|
||||
Order get order;
|
||||
|
||||
/// Create a copy of PaymentFormEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$SetOrderImplCopyWith<_$SetOrderImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$SetPaymentImplCopyWith<$Res> {
|
||||
factory _$$SetPaymentImplCopyWith(
|
||||
_$SetPaymentImpl value,
|
||||
$Res Function(_$SetPaymentImpl) then,
|
||||
) = __$$SetPaymentImplCopyWithImpl<$Res>;
|
||||
@useResult
|
||||
$Res call({PaymentMethod paymentMethod});
|
||||
|
||||
$PaymentMethodCopyWith<$Res> get paymentMethod;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$SetPaymentImplCopyWithImpl<$Res>
|
||||
extends _$PaymentFormEventCopyWithImpl<$Res, _$SetPaymentImpl>
|
||||
implements _$$SetPaymentImplCopyWith<$Res> {
|
||||
__$$SetPaymentImplCopyWithImpl(
|
||||
_$SetPaymentImpl _value,
|
||||
$Res Function(_$SetPaymentImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of PaymentFormEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({Object? paymentMethod = null}) {
|
||||
return _then(
|
||||
_$SetPaymentImpl(
|
||||
null == paymentMethod
|
||||
? _value.paymentMethod
|
||||
: paymentMethod // ignore: cast_nullable_to_non_nullable
|
||||
as PaymentMethod,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// Create a copy of PaymentFormEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$PaymentMethodCopyWith<$Res> get paymentMethod {
|
||||
return $PaymentMethodCopyWith<$Res>(_value.paymentMethod, (value) {
|
||||
return _then(_value.copyWith(paymentMethod: value));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$SetPaymentImpl implements _SetPayment {
|
||||
const _$SetPaymentImpl(this.paymentMethod);
|
||||
|
||||
@override
|
||||
final PaymentMethod paymentMethod;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'PaymentFormEvent.setPaymentMethod(paymentMethod: $paymentMethod)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$SetPaymentImpl &&
|
||||
(identical(other.paymentMethod, paymentMethod) ||
|
||||
other.paymentMethod == paymentMethod));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, paymentMethod);
|
||||
|
||||
/// Create a copy of PaymentFormEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$SetPaymentImplCopyWith<_$SetPaymentImpl> get copyWith =>
|
||||
__$$SetPaymentImplCopyWithImpl<_$SetPaymentImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function(Order order) setOrder,
|
||||
required TResult Function(PaymentMethod paymentMethod) setPaymentMethod,
|
||||
required TResult Function() submitted,
|
||||
}) {
|
||||
return setPaymentMethod(paymentMethod);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function(Order order)? setOrder,
|
||||
TResult? Function(PaymentMethod paymentMethod)? setPaymentMethod,
|
||||
TResult? Function()? submitted,
|
||||
}) {
|
||||
return setPaymentMethod?.call(paymentMethod);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function(Order order)? setOrder,
|
||||
TResult Function(PaymentMethod paymentMethod)? setPaymentMethod,
|
||||
TResult Function()? submitted,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (setPaymentMethod != null) {
|
||||
return setPaymentMethod(paymentMethod);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_SetOrder value) setOrder,
|
||||
required TResult Function(_SetPayment value) setPaymentMethod,
|
||||
required TResult Function(_Submitted value) submitted,
|
||||
}) {
|
||||
return setPaymentMethod(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_SetOrder value)? setOrder,
|
||||
TResult? Function(_SetPayment value)? setPaymentMethod,
|
||||
TResult? Function(_Submitted value)? submitted,
|
||||
}) {
|
||||
return setPaymentMethod?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_SetOrder value)? setOrder,
|
||||
TResult Function(_SetPayment value)? setPaymentMethod,
|
||||
TResult Function(_Submitted value)? submitted,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (setPaymentMethod != null) {
|
||||
return setPaymentMethod(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _SetPayment implements PaymentFormEvent {
|
||||
const factory _SetPayment(final PaymentMethod paymentMethod) =
|
||||
_$SetPaymentImpl;
|
||||
|
||||
PaymentMethod get paymentMethod;
|
||||
|
||||
/// Create a copy of PaymentFormEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$SetPaymentImplCopyWith<_$SetPaymentImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$SubmittedImplCopyWith<$Res> {
|
||||
factory _$$SubmittedImplCopyWith(
|
||||
_$SubmittedImpl value,
|
||||
$Res Function(_$SubmittedImpl) then,
|
||||
) = __$$SubmittedImplCopyWithImpl<$Res>;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$SubmittedImplCopyWithImpl<$Res>
|
||||
extends _$PaymentFormEventCopyWithImpl<$Res, _$SubmittedImpl>
|
||||
implements _$$SubmittedImplCopyWith<$Res> {
|
||||
__$$SubmittedImplCopyWithImpl(
|
||||
_$SubmittedImpl _value,
|
||||
$Res Function(_$SubmittedImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of PaymentFormEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$SubmittedImpl implements _Submitted {
|
||||
const _$SubmittedImpl();
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'PaymentFormEvent.submitted()';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType && other is _$SubmittedImpl);
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => runtimeType.hashCode;
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function(Order order) setOrder,
|
||||
required TResult Function(PaymentMethod paymentMethod) setPaymentMethod,
|
||||
required TResult Function() submitted,
|
||||
}) {
|
||||
return submitted();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function(Order order)? setOrder,
|
||||
TResult? Function(PaymentMethod paymentMethod)? setPaymentMethod,
|
||||
TResult? Function()? submitted,
|
||||
}) {
|
||||
return submitted?.call();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function(Order order)? setOrder,
|
||||
TResult Function(PaymentMethod paymentMethod)? setPaymentMethod,
|
||||
TResult Function()? submitted,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (submitted != null) {
|
||||
return submitted();
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_SetOrder value) setOrder,
|
||||
required TResult Function(_SetPayment value) setPaymentMethod,
|
||||
required TResult Function(_Submitted value) submitted,
|
||||
}) {
|
||||
return submitted(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_SetOrder value)? setOrder,
|
||||
TResult? Function(_SetPayment value)? setPaymentMethod,
|
||||
TResult? Function(_Submitted value)? submitted,
|
||||
}) {
|
||||
return submitted?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_SetOrder value)? setOrder,
|
||||
TResult Function(_SetPayment value)? setPaymentMethod,
|
||||
TResult Function(_Submitted value)? submitted,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (submitted != null) {
|
||||
return submitted(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _Submitted implements PaymentFormEvent {
|
||||
const factory _Submitted() = _$SubmittedImpl;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$PaymentFormState {
|
||||
Order get order => throw _privateConstructorUsedError;
|
||||
List<OrderItem> get pendingItems => throw _privateConstructorUsedError;
|
||||
Option<Either<OrderFailure, Payment>> get failureOrPayment =>
|
||||
throw _privateConstructorUsedError;
|
||||
PaymentMethod? get paymentMethod => throw _privateConstructorUsedError;
|
||||
bool get isSubmitting => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of PaymentFormState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$PaymentFormStateCopyWith<PaymentFormState> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $PaymentFormStateCopyWith<$Res> {
|
||||
factory $PaymentFormStateCopyWith(
|
||||
PaymentFormState value,
|
||||
$Res Function(PaymentFormState) then,
|
||||
) = _$PaymentFormStateCopyWithImpl<$Res, PaymentFormState>;
|
||||
@useResult
|
||||
$Res call({
|
||||
Order order,
|
||||
List<OrderItem> pendingItems,
|
||||
Option<Either<OrderFailure, Payment>> failureOrPayment,
|
||||
PaymentMethod? paymentMethod,
|
||||
bool isSubmitting,
|
||||
});
|
||||
|
||||
$OrderCopyWith<$Res> get order;
|
||||
$PaymentMethodCopyWith<$Res>? get paymentMethod;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$PaymentFormStateCopyWithImpl<$Res, $Val extends PaymentFormState>
|
||||
implements $PaymentFormStateCopyWith<$Res> {
|
||||
_$PaymentFormStateCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of PaymentFormState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? order = null,
|
||||
Object? pendingItems = null,
|
||||
Object? failureOrPayment = null,
|
||||
Object? paymentMethod = freezed,
|
||||
Object? isSubmitting = null,
|
||||
}) {
|
||||
return _then(
|
||||
_value.copyWith(
|
||||
order: null == order
|
||||
? _value.order
|
||||
: order // ignore: cast_nullable_to_non_nullable
|
||||
as Order,
|
||||
pendingItems: null == pendingItems
|
||||
? _value.pendingItems
|
||||
: pendingItems // ignore: cast_nullable_to_non_nullable
|
||||
as List<OrderItem>,
|
||||
failureOrPayment: null == failureOrPayment
|
||||
? _value.failureOrPayment
|
||||
: failureOrPayment // ignore: cast_nullable_to_non_nullable
|
||||
as Option<Either<OrderFailure, Payment>>,
|
||||
paymentMethod: freezed == paymentMethod
|
||||
? _value.paymentMethod
|
||||
: paymentMethod // ignore: cast_nullable_to_non_nullable
|
||||
as PaymentMethod?,
|
||||
isSubmitting: null == isSubmitting
|
||||
? _value.isSubmitting
|
||||
: isSubmitting // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
)
|
||||
as $Val,
|
||||
);
|
||||
}
|
||||
|
||||
/// Create a copy of PaymentFormState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$OrderCopyWith<$Res> get order {
|
||||
return $OrderCopyWith<$Res>(_value.order, (value) {
|
||||
return _then(_value.copyWith(order: value) as $Val);
|
||||
});
|
||||
}
|
||||
|
||||
/// Create a copy of PaymentFormState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$PaymentMethodCopyWith<$Res>? get paymentMethod {
|
||||
if (_value.paymentMethod == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $PaymentMethodCopyWith<$Res>(_value.paymentMethod!, (value) {
|
||||
return _then(_value.copyWith(paymentMethod: value) as $Val);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$PaymentFormStateImplCopyWith<$Res>
|
||||
implements $PaymentFormStateCopyWith<$Res> {
|
||||
factory _$$PaymentFormStateImplCopyWith(
|
||||
_$PaymentFormStateImpl value,
|
||||
$Res Function(_$PaymentFormStateImpl) then,
|
||||
) = __$$PaymentFormStateImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({
|
||||
Order order,
|
||||
List<OrderItem> pendingItems,
|
||||
Option<Either<OrderFailure, Payment>> failureOrPayment,
|
||||
PaymentMethod? paymentMethod,
|
||||
bool isSubmitting,
|
||||
});
|
||||
|
||||
@override
|
||||
$OrderCopyWith<$Res> get order;
|
||||
@override
|
||||
$PaymentMethodCopyWith<$Res>? get paymentMethod;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$PaymentFormStateImplCopyWithImpl<$Res>
|
||||
extends _$PaymentFormStateCopyWithImpl<$Res, _$PaymentFormStateImpl>
|
||||
implements _$$PaymentFormStateImplCopyWith<$Res> {
|
||||
__$$PaymentFormStateImplCopyWithImpl(
|
||||
_$PaymentFormStateImpl _value,
|
||||
$Res Function(_$PaymentFormStateImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of PaymentFormState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? order = null,
|
||||
Object? pendingItems = null,
|
||||
Object? failureOrPayment = null,
|
||||
Object? paymentMethod = freezed,
|
||||
Object? isSubmitting = null,
|
||||
}) {
|
||||
return _then(
|
||||
_$PaymentFormStateImpl(
|
||||
order: null == order
|
||||
? _value.order
|
||||
: order // ignore: cast_nullable_to_non_nullable
|
||||
as Order,
|
||||
pendingItems: null == pendingItems
|
||||
? _value._pendingItems
|
||||
: pendingItems // ignore: cast_nullable_to_non_nullable
|
||||
as List<OrderItem>,
|
||||
failureOrPayment: null == failureOrPayment
|
||||
? _value.failureOrPayment
|
||||
: failureOrPayment // ignore: cast_nullable_to_non_nullable
|
||||
as Option<Either<OrderFailure, Payment>>,
|
||||
paymentMethod: freezed == paymentMethod
|
||||
? _value.paymentMethod
|
||||
: paymentMethod // ignore: cast_nullable_to_non_nullable
|
||||
as PaymentMethod?,
|
||||
isSubmitting: null == isSubmitting
|
||||
? _value.isSubmitting
|
||||
: isSubmitting // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$PaymentFormStateImpl implements _PaymentFormState {
|
||||
_$PaymentFormStateImpl({
|
||||
required this.order,
|
||||
required final List<OrderItem> pendingItems,
|
||||
required this.failureOrPayment,
|
||||
this.paymentMethod,
|
||||
this.isSubmitting = false,
|
||||
}) : _pendingItems = pendingItems;
|
||||
|
||||
@override
|
||||
final Order order;
|
||||
final List<OrderItem> _pendingItems;
|
||||
@override
|
||||
List<OrderItem> get pendingItems {
|
||||
if (_pendingItems is EqualUnmodifiableListView) return _pendingItems;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_pendingItems);
|
||||
}
|
||||
|
||||
@override
|
||||
final Option<Either<OrderFailure, Payment>> failureOrPayment;
|
||||
@override
|
||||
final PaymentMethod? paymentMethod;
|
||||
@override
|
||||
@JsonKey()
|
||||
final bool isSubmitting;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'PaymentFormState(order: $order, pendingItems: $pendingItems, failureOrPayment: $failureOrPayment, paymentMethod: $paymentMethod, isSubmitting: $isSubmitting)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$PaymentFormStateImpl &&
|
||||
(identical(other.order, order) || other.order == order) &&
|
||||
const DeepCollectionEquality().equals(
|
||||
other._pendingItems,
|
||||
_pendingItems,
|
||||
) &&
|
||||
(identical(other.failureOrPayment, failureOrPayment) ||
|
||||
other.failureOrPayment == failureOrPayment) &&
|
||||
(identical(other.paymentMethod, paymentMethod) ||
|
||||
other.paymentMethod == paymentMethod) &&
|
||||
(identical(other.isSubmitting, isSubmitting) ||
|
||||
other.isSubmitting == isSubmitting));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(
|
||||
runtimeType,
|
||||
order,
|
||||
const DeepCollectionEquality().hash(_pendingItems),
|
||||
failureOrPayment,
|
||||
paymentMethod,
|
||||
isSubmitting,
|
||||
);
|
||||
|
||||
/// Create a copy of PaymentFormState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$PaymentFormStateImplCopyWith<_$PaymentFormStateImpl> get copyWith =>
|
||||
__$$PaymentFormStateImplCopyWithImpl<_$PaymentFormStateImpl>(
|
||||
this,
|
||||
_$identity,
|
||||
);
|
||||
}
|
||||
|
||||
abstract class _PaymentFormState implements PaymentFormState {
|
||||
factory _PaymentFormState({
|
||||
required final Order order,
|
||||
required final List<OrderItem> pendingItems,
|
||||
required final Option<Either<OrderFailure, Payment>> failureOrPayment,
|
||||
final PaymentMethod? paymentMethod,
|
||||
final bool isSubmitting,
|
||||
}) = _$PaymentFormStateImpl;
|
||||
|
||||
@override
|
||||
Order get order;
|
||||
@override
|
||||
List<OrderItem> get pendingItems;
|
||||
@override
|
||||
Option<Either<OrderFailure, Payment>> get failureOrPayment;
|
||||
@override
|
||||
PaymentMethod? get paymentMethod;
|
||||
@override
|
||||
bool get isSubmitting;
|
||||
|
||||
/// Create a copy of PaymentFormState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$PaymentFormStateImplCopyWith<_$PaymentFormStateImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
part of 'payment_form_bloc.dart';
|
||||
|
||||
@freezed
|
||||
class PaymentFormEvent with _$PaymentFormEvent {
|
||||
const factory PaymentFormEvent.setOrder(Order order) = _SetOrder;
|
||||
const factory PaymentFormEvent.setPaymentMethod(PaymentMethod paymentMethod) =
|
||||
_SetPayment;
|
||||
const factory PaymentFormEvent.submitted() = _Submitted;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
part of 'payment_form_bloc.dart';
|
||||
|
||||
@freezed
|
||||
class PaymentFormState with _$PaymentFormState {
|
||||
factory PaymentFormState({
|
||||
required Order order,
|
||||
required List<OrderItem> pendingItems,
|
||||
required Option<Either<OrderFailure, Payment>> failureOrPayment,
|
||||
PaymentMethod? paymentMethod,
|
||||
@Default(false) bool isSubmitting,
|
||||
}) = _PaymentFormState;
|
||||
|
||||
factory PaymentFormState.initial() => PaymentFormState(
|
||||
order: Order.empty(),
|
||||
pendingItems: [],
|
||||
failureOrPayment: none(),
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user