Compare commits
2 Commits
7961c9d8c5
...
35f02e6b76
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
35f02e6b76 | ||
|
|
6b42cd86ff |
@ -3,6 +3,7 @@ import 'package:dartz/dartz.dart' hide Order;
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:injectable/injectable.dart' hide Order;
|
||||
|
||||
import '../../../common/types/split_type.dart';
|
||||
import '../../../domain/order/order.dart';
|
||||
import '../../../domain/payment_method/payment_method.dart';
|
||||
|
||||
@ -64,6 +65,39 @@ class PaymentFormBloc extends Bloc<PaymentFormEvent, PaymentFormState> {
|
||||
),
|
||||
);
|
||||
},
|
||||
submittedSplitBill: (e) async {
|
||||
Either<OrderFailure, Payment> failureOrPayment;
|
||||
|
||||
emit(
|
||||
state.copyWith(isSubmitting: true, failureOrPaymentSplitBill: none()),
|
||||
);
|
||||
|
||||
final request = PaymentSplitBillRequest(
|
||||
orderId: state.order.id,
|
||||
paymentMethodId: state.paymentMethod?.id ?? '',
|
||||
amount: state.order.totalAmount,
|
||||
customerId: e.customerId ?? '',
|
||||
type: e.splitType ?? SplitType.unknown,
|
||||
customerName: e.customerName ?? '',
|
||||
items: state.pendingItems
|
||||
.map(
|
||||
(item) => PaymentItemSplitBillRequest(
|
||||
orderItemId: item.id,
|
||||
quantity: item.quantity,
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
);
|
||||
|
||||
failureOrPayment = await _repository.createSplitBill(request);
|
||||
|
||||
emit(
|
||||
state.copyWith(
|
||||
isSubmitting: false,
|
||||
failureOrPaymentSplitBill: optionOf(failureOrPayment),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,18 +22,36 @@ mixin _$PaymentFormEvent {
|
||||
required TResult Function(Order order) setOrder,
|
||||
required TResult Function(PaymentMethod paymentMethod) setPaymentMethod,
|
||||
required TResult Function() submitted,
|
||||
required TResult Function(
|
||||
SplitType? splitType,
|
||||
String? customerId,
|
||||
String? customerName,
|
||||
)
|
||||
submittedSplitBill,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function(Order order)? setOrder,
|
||||
TResult? Function(PaymentMethod paymentMethod)? setPaymentMethod,
|
||||
TResult? Function()? submitted,
|
||||
TResult? Function(
|
||||
SplitType? splitType,
|
||||
String? customerId,
|
||||
String? customerName,
|
||||
)?
|
||||
submittedSplitBill,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function(Order order)? setOrder,
|
||||
TResult Function(PaymentMethod paymentMethod)? setPaymentMethod,
|
||||
TResult Function()? submitted,
|
||||
TResult Function(
|
||||
SplitType? splitType,
|
||||
String? customerId,
|
||||
String? customerName,
|
||||
)?
|
||||
submittedSplitBill,
|
||||
required TResult orElse(),
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
@ -41,18 +59,21 @@ mixin _$PaymentFormEvent {
|
||||
required TResult Function(_SetOrder value) setOrder,
|
||||
required TResult Function(_SetPayment value) setPaymentMethod,
|
||||
required TResult Function(_Submitted value) submitted,
|
||||
required TResult Function(_SubmittedSplitBill value) submittedSplitBill,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_SetOrder value)? setOrder,
|
||||
TResult? Function(_SetPayment value)? setPaymentMethod,
|
||||
TResult? Function(_Submitted value)? submitted,
|
||||
TResult? Function(_SubmittedSplitBill value)? submittedSplitBill,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_SetOrder value)? setOrder,
|
||||
TResult Function(_SetPayment value)? setPaymentMethod,
|
||||
TResult Function(_Submitted value)? submitted,
|
||||
TResult Function(_SubmittedSplitBill value)? submittedSplitBill,
|
||||
required TResult orElse(),
|
||||
}) => throw _privateConstructorUsedError;
|
||||
}
|
||||
@ -164,6 +185,12 @@ class _$SetOrderImpl implements _SetOrder {
|
||||
required TResult Function(Order order) setOrder,
|
||||
required TResult Function(PaymentMethod paymentMethod) setPaymentMethod,
|
||||
required TResult Function() submitted,
|
||||
required TResult Function(
|
||||
SplitType? splitType,
|
||||
String? customerId,
|
||||
String? customerName,
|
||||
)
|
||||
submittedSplitBill,
|
||||
}) {
|
||||
return setOrder(order);
|
||||
}
|
||||
@ -174,6 +201,12 @@ class _$SetOrderImpl implements _SetOrder {
|
||||
TResult? Function(Order order)? setOrder,
|
||||
TResult? Function(PaymentMethod paymentMethod)? setPaymentMethod,
|
||||
TResult? Function()? submitted,
|
||||
TResult? Function(
|
||||
SplitType? splitType,
|
||||
String? customerId,
|
||||
String? customerName,
|
||||
)?
|
||||
submittedSplitBill,
|
||||
}) {
|
||||
return setOrder?.call(order);
|
||||
}
|
||||
@ -184,6 +217,12 @@ class _$SetOrderImpl implements _SetOrder {
|
||||
TResult Function(Order order)? setOrder,
|
||||
TResult Function(PaymentMethod paymentMethod)? setPaymentMethod,
|
||||
TResult Function()? submitted,
|
||||
TResult Function(
|
||||
SplitType? splitType,
|
||||
String? customerId,
|
||||
String? customerName,
|
||||
)?
|
||||
submittedSplitBill,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (setOrder != null) {
|
||||
@ -198,6 +237,7 @@ class _$SetOrderImpl implements _SetOrder {
|
||||
required TResult Function(_SetOrder value) setOrder,
|
||||
required TResult Function(_SetPayment value) setPaymentMethod,
|
||||
required TResult Function(_Submitted value) submitted,
|
||||
required TResult Function(_SubmittedSplitBill value) submittedSplitBill,
|
||||
}) {
|
||||
return setOrder(this);
|
||||
}
|
||||
@ -208,6 +248,7 @@ class _$SetOrderImpl implements _SetOrder {
|
||||
TResult? Function(_SetOrder value)? setOrder,
|
||||
TResult? Function(_SetPayment value)? setPaymentMethod,
|
||||
TResult? Function(_Submitted value)? submitted,
|
||||
TResult? Function(_SubmittedSplitBill value)? submittedSplitBill,
|
||||
}) {
|
||||
return setOrder?.call(this);
|
||||
}
|
||||
@ -218,6 +259,7 @@ class _$SetOrderImpl implements _SetOrder {
|
||||
TResult Function(_SetOrder value)? setOrder,
|
||||
TResult Function(_SetPayment value)? setPaymentMethod,
|
||||
TResult Function(_Submitted value)? submitted,
|
||||
TResult Function(_SubmittedSplitBill value)? submittedSplitBill,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (setOrder != null) {
|
||||
@ -325,6 +367,12 @@ class _$SetPaymentImpl implements _SetPayment {
|
||||
required TResult Function(Order order) setOrder,
|
||||
required TResult Function(PaymentMethod paymentMethod) setPaymentMethod,
|
||||
required TResult Function() submitted,
|
||||
required TResult Function(
|
||||
SplitType? splitType,
|
||||
String? customerId,
|
||||
String? customerName,
|
||||
)
|
||||
submittedSplitBill,
|
||||
}) {
|
||||
return setPaymentMethod(paymentMethod);
|
||||
}
|
||||
@ -335,6 +383,12 @@ class _$SetPaymentImpl implements _SetPayment {
|
||||
TResult? Function(Order order)? setOrder,
|
||||
TResult? Function(PaymentMethod paymentMethod)? setPaymentMethod,
|
||||
TResult? Function()? submitted,
|
||||
TResult? Function(
|
||||
SplitType? splitType,
|
||||
String? customerId,
|
||||
String? customerName,
|
||||
)?
|
||||
submittedSplitBill,
|
||||
}) {
|
||||
return setPaymentMethod?.call(paymentMethod);
|
||||
}
|
||||
@ -345,6 +399,12 @@ class _$SetPaymentImpl implements _SetPayment {
|
||||
TResult Function(Order order)? setOrder,
|
||||
TResult Function(PaymentMethod paymentMethod)? setPaymentMethod,
|
||||
TResult Function()? submitted,
|
||||
TResult Function(
|
||||
SplitType? splitType,
|
||||
String? customerId,
|
||||
String? customerName,
|
||||
)?
|
||||
submittedSplitBill,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (setPaymentMethod != null) {
|
||||
@ -359,6 +419,7 @@ class _$SetPaymentImpl implements _SetPayment {
|
||||
required TResult Function(_SetOrder value) setOrder,
|
||||
required TResult Function(_SetPayment value) setPaymentMethod,
|
||||
required TResult Function(_Submitted value) submitted,
|
||||
required TResult Function(_SubmittedSplitBill value) submittedSplitBill,
|
||||
}) {
|
||||
return setPaymentMethod(this);
|
||||
}
|
||||
@ -369,6 +430,7 @@ class _$SetPaymentImpl implements _SetPayment {
|
||||
TResult? Function(_SetOrder value)? setOrder,
|
||||
TResult? Function(_SetPayment value)? setPaymentMethod,
|
||||
TResult? Function(_Submitted value)? submitted,
|
||||
TResult? Function(_SubmittedSplitBill value)? submittedSplitBill,
|
||||
}) {
|
||||
return setPaymentMethod?.call(this);
|
||||
}
|
||||
@ -379,6 +441,7 @@ class _$SetPaymentImpl implements _SetPayment {
|
||||
TResult Function(_SetOrder value)? setOrder,
|
||||
TResult Function(_SetPayment value)? setPaymentMethod,
|
||||
TResult Function(_Submitted value)? submitted,
|
||||
TResult Function(_SubmittedSplitBill value)? submittedSplitBill,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (setPaymentMethod != null) {
|
||||
@ -447,6 +510,12 @@ class _$SubmittedImpl implements _Submitted {
|
||||
required TResult Function(Order order) setOrder,
|
||||
required TResult Function(PaymentMethod paymentMethod) setPaymentMethod,
|
||||
required TResult Function() submitted,
|
||||
required TResult Function(
|
||||
SplitType? splitType,
|
||||
String? customerId,
|
||||
String? customerName,
|
||||
)
|
||||
submittedSplitBill,
|
||||
}) {
|
||||
return submitted();
|
||||
}
|
||||
@ -457,6 +526,12 @@ class _$SubmittedImpl implements _Submitted {
|
||||
TResult? Function(Order order)? setOrder,
|
||||
TResult? Function(PaymentMethod paymentMethod)? setPaymentMethod,
|
||||
TResult? Function()? submitted,
|
||||
TResult? Function(
|
||||
SplitType? splitType,
|
||||
String? customerId,
|
||||
String? customerName,
|
||||
)?
|
||||
submittedSplitBill,
|
||||
}) {
|
||||
return submitted?.call();
|
||||
}
|
||||
@ -467,6 +542,12 @@ class _$SubmittedImpl implements _Submitted {
|
||||
TResult Function(Order order)? setOrder,
|
||||
TResult Function(PaymentMethod paymentMethod)? setPaymentMethod,
|
||||
TResult Function()? submitted,
|
||||
TResult Function(
|
||||
SplitType? splitType,
|
||||
String? customerId,
|
||||
String? customerName,
|
||||
)?
|
||||
submittedSplitBill,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (submitted != null) {
|
||||
@ -481,6 +562,7 @@ class _$SubmittedImpl implements _Submitted {
|
||||
required TResult Function(_SetOrder value) setOrder,
|
||||
required TResult Function(_SetPayment value) setPaymentMethod,
|
||||
required TResult Function(_Submitted value) submitted,
|
||||
required TResult Function(_SubmittedSplitBill value) submittedSplitBill,
|
||||
}) {
|
||||
return submitted(this);
|
||||
}
|
||||
@ -491,6 +573,7 @@ class _$SubmittedImpl implements _Submitted {
|
||||
TResult? Function(_SetOrder value)? setOrder,
|
||||
TResult? Function(_SetPayment value)? setPaymentMethod,
|
||||
TResult? Function(_Submitted value)? submitted,
|
||||
TResult? Function(_SubmittedSplitBill value)? submittedSplitBill,
|
||||
}) {
|
||||
return submitted?.call(this);
|
||||
}
|
||||
@ -501,6 +584,7 @@ class _$SubmittedImpl implements _Submitted {
|
||||
TResult Function(_SetOrder value)? setOrder,
|
||||
TResult Function(_SetPayment value)? setPaymentMethod,
|
||||
TResult Function(_Submitted value)? submitted,
|
||||
TResult Function(_SubmittedSplitBill value)? submittedSplitBill,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (submitted != null) {
|
||||
@ -514,12 +598,218 @@ abstract class _Submitted implements PaymentFormEvent {
|
||||
const factory _Submitted() = _$SubmittedImpl;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$SubmittedSplitBillImplCopyWith<$Res> {
|
||||
factory _$$SubmittedSplitBillImplCopyWith(
|
||||
_$SubmittedSplitBillImpl value,
|
||||
$Res Function(_$SubmittedSplitBillImpl) then,
|
||||
) = __$$SubmittedSplitBillImplCopyWithImpl<$Res>;
|
||||
@useResult
|
||||
$Res call({SplitType? splitType, String? customerId, String? customerName});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$SubmittedSplitBillImplCopyWithImpl<$Res>
|
||||
extends _$PaymentFormEventCopyWithImpl<$Res, _$SubmittedSplitBillImpl>
|
||||
implements _$$SubmittedSplitBillImplCopyWith<$Res> {
|
||||
__$$SubmittedSplitBillImplCopyWithImpl(
|
||||
_$SubmittedSplitBillImpl _value,
|
||||
$Res Function(_$SubmittedSplitBillImpl) _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? splitType = freezed,
|
||||
Object? customerId = freezed,
|
||||
Object? customerName = freezed,
|
||||
}) {
|
||||
return _then(
|
||||
_$SubmittedSplitBillImpl(
|
||||
splitType: freezed == splitType
|
||||
? _value.splitType
|
||||
: splitType // ignore: cast_nullable_to_non_nullable
|
||||
as SplitType?,
|
||||
customerId: freezed == customerId
|
||||
? _value.customerId
|
||||
: customerId // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
customerName: freezed == customerName
|
||||
? _value.customerName
|
||||
: customerName // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$SubmittedSplitBillImpl implements _SubmittedSplitBill {
|
||||
const _$SubmittedSplitBillImpl({
|
||||
this.splitType,
|
||||
this.customerId,
|
||||
this.customerName,
|
||||
});
|
||||
|
||||
@override
|
||||
final SplitType? splitType;
|
||||
@override
|
||||
final String? customerId;
|
||||
@override
|
||||
final String? customerName;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'PaymentFormEvent.submittedSplitBill(splitType: $splitType, customerId: $customerId, customerName: $customerName)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$SubmittedSplitBillImpl &&
|
||||
(identical(other.splitType, splitType) ||
|
||||
other.splitType == splitType) &&
|
||||
(identical(other.customerId, customerId) ||
|
||||
other.customerId == customerId) &&
|
||||
(identical(other.customerName, customerName) ||
|
||||
other.customerName == customerName));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
Object.hash(runtimeType, splitType, customerId, customerName);
|
||||
|
||||
/// 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')
|
||||
_$$SubmittedSplitBillImplCopyWith<_$SubmittedSplitBillImpl> get copyWith =>
|
||||
__$$SubmittedSplitBillImplCopyWithImpl<_$SubmittedSplitBillImpl>(
|
||||
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,
|
||||
required TResult Function(
|
||||
SplitType? splitType,
|
||||
String? customerId,
|
||||
String? customerName,
|
||||
)
|
||||
submittedSplitBill,
|
||||
}) {
|
||||
return submittedSplitBill(splitType, customerId, customerName);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function(Order order)? setOrder,
|
||||
TResult? Function(PaymentMethod paymentMethod)? setPaymentMethod,
|
||||
TResult? Function()? submitted,
|
||||
TResult? Function(
|
||||
SplitType? splitType,
|
||||
String? customerId,
|
||||
String? customerName,
|
||||
)?
|
||||
submittedSplitBill,
|
||||
}) {
|
||||
return submittedSplitBill?.call(splitType, customerId, customerName);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function(Order order)? setOrder,
|
||||
TResult Function(PaymentMethod paymentMethod)? setPaymentMethod,
|
||||
TResult Function()? submitted,
|
||||
TResult Function(
|
||||
SplitType? splitType,
|
||||
String? customerId,
|
||||
String? customerName,
|
||||
)?
|
||||
submittedSplitBill,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (submittedSplitBill != null) {
|
||||
return submittedSplitBill(splitType, customerId, customerName);
|
||||
}
|
||||
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,
|
||||
required TResult Function(_SubmittedSplitBill value) submittedSplitBill,
|
||||
}) {
|
||||
return submittedSplitBill(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_SetOrder value)? setOrder,
|
||||
TResult? Function(_SetPayment value)? setPaymentMethod,
|
||||
TResult? Function(_Submitted value)? submitted,
|
||||
TResult? Function(_SubmittedSplitBill value)? submittedSplitBill,
|
||||
}) {
|
||||
return submittedSplitBill?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_SetOrder value)? setOrder,
|
||||
TResult Function(_SetPayment value)? setPaymentMethod,
|
||||
TResult Function(_Submitted value)? submitted,
|
||||
TResult Function(_SubmittedSplitBill value)? submittedSplitBill,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (submittedSplitBill != null) {
|
||||
return submittedSplitBill(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _SubmittedSplitBill implements PaymentFormEvent {
|
||||
const factory _SubmittedSplitBill({
|
||||
final SplitType? splitType,
|
||||
final String? customerId,
|
||||
final String? customerName,
|
||||
}) = _$SubmittedSplitBillImpl;
|
||||
|
||||
SplitType? get splitType;
|
||||
String? get customerId;
|
||||
String? get customerName;
|
||||
|
||||
/// Create a copy of PaymentFormEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$SubmittedSplitBillImplCopyWith<_$SubmittedSplitBillImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$PaymentFormState {
|
||||
Order get order => throw _privateConstructorUsedError;
|
||||
List<OrderItem> get pendingItems => throw _privateConstructorUsedError;
|
||||
Option<Either<OrderFailure, Payment>> get failureOrPayment =>
|
||||
throw _privateConstructorUsedError;
|
||||
Option<Either<OrderFailure, Payment>> get failureOrPaymentSplitBill =>
|
||||
throw _privateConstructorUsedError;
|
||||
PaymentMethod? get paymentMethod => throw _privateConstructorUsedError;
|
||||
bool get isSubmitting => throw _privateConstructorUsedError;
|
||||
|
||||
@ -541,6 +831,7 @@ abstract class $PaymentFormStateCopyWith<$Res> {
|
||||
Order order,
|
||||
List<OrderItem> pendingItems,
|
||||
Option<Either<OrderFailure, Payment>> failureOrPayment,
|
||||
Option<Either<OrderFailure, Payment>> failureOrPaymentSplitBill,
|
||||
PaymentMethod? paymentMethod,
|
||||
bool isSubmitting,
|
||||
});
|
||||
@ -567,6 +858,7 @@ class _$PaymentFormStateCopyWithImpl<$Res, $Val extends PaymentFormState>
|
||||
Object? order = null,
|
||||
Object? pendingItems = null,
|
||||
Object? failureOrPayment = null,
|
||||
Object? failureOrPaymentSplitBill = null,
|
||||
Object? paymentMethod = freezed,
|
||||
Object? isSubmitting = null,
|
||||
}) {
|
||||
@ -584,6 +876,10 @@ class _$PaymentFormStateCopyWithImpl<$Res, $Val extends PaymentFormState>
|
||||
? _value.failureOrPayment
|
||||
: failureOrPayment // ignore: cast_nullable_to_non_nullable
|
||||
as Option<Either<OrderFailure, Payment>>,
|
||||
failureOrPaymentSplitBill: null == failureOrPaymentSplitBill
|
||||
? _value.failureOrPaymentSplitBill
|
||||
: failureOrPaymentSplitBill // ignore: cast_nullable_to_non_nullable
|
||||
as Option<Either<OrderFailure, Payment>>,
|
||||
paymentMethod: freezed == paymentMethod
|
||||
? _value.paymentMethod
|
||||
: paymentMethod // ignore: cast_nullable_to_non_nullable
|
||||
@ -635,6 +931,7 @@ abstract class _$$PaymentFormStateImplCopyWith<$Res>
|
||||
Order order,
|
||||
List<OrderItem> pendingItems,
|
||||
Option<Either<OrderFailure, Payment>> failureOrPayment,
|
||||
Option<Either<OrderFailure, Payment>> failureOrPaymentSplitBill,
|
||||
PaymentMethod? paymentMethod,
|
||||
bool isSubmitting,
|
||||
});
|
||||
@ -662,6 +959,7 @@ class __$$PaymentFormStateImplCopyWithImpl<$Res>
|
||||
Object? order = null,
|
||||
Object? pendingItems = null,
|
||||
Object? failureOrPayment = null,
|
||||
Object? failureOrPaymentSplitBill = null,
|
||||
Object? paymentMethod = freezed,
|
||||
Object? isSubmitting = null,
|
||||
}) {
|
||||
@ -679,6 +977,10 @@ class __$$PaymentFormStateImplCopyWithImpl<$Res>
|
||||
? _value.failureOrPayment
|
||||
: failureOrPayment // ignore: cast_nullable_to_non_nullable
|
||||
as Option<Either<OrderFailure, Payment>>,
|
||||
failureOrPaymentSplitBill: null == failureOrPaymentSplitBill
|
||||
? _value.failureOrPaymentSplitBill
|
||||
: failureOrPaymentSplitBill // ignore: cast_nullable_to_non_nullable
|
||||
as Option<Either<OrderFailure, Payment>>,
|
||||
paymentMethod: freezed == paymentMethod
|
||||
? _value.paymentMethod
|
||||
: paymentMethod // ignore: cast_nullable_to_non_nullable
|
||||
@ -699,6 +1001,7 @@ class _$PaymentFormStateImpl implements _PaymentFormState {
|
||||
required this.order,
|
||||
required final List<OrderItem> pendingItems,
|
||||
required this.failureOrPayment,
|
||||
required this.failureOrPaymentSplitBill,
|
||||
this.paymentMethod,
|
||||
this.isSubmitting = false,
|
||||
}) : _pendingItems = pendingItems;
|
||||
@ -716,6 +1019,8 @@ class _$PaymentFormStateImpl implements _PaymentFormState {
|
||||
@override
|
||||
final Option<Either<OrderFailure, Payment>> failureOrPayment;
|
||||
@override
|
||||
final Option<Either<OrderFailure, Payment>> failureOrPaymentSplitBill;
|
||||
@override
|
||||
final PaymentMethod? paymentMethod;
|
||||
@override
|
||||
@JsonKey()
|
||||
@ -723,7 +1028,7 @@ class _$PaymentFormStateImpl implements _PaymentFormState {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'PaymentFormState(order: $order, pendingItems: $pendingItems, failureOrPayment: $failureOrPayment, paymentMethod: $paymentMethod, isSubmitting: $isSubmitting)';
|
||||
return 'PaymentFormState(order: $order, pendingItems: $pendingItems, failureOrPayment: $failureOrPayment, failureOrPaymentSplitBill: $failureOrPaymentSplitBill, paymentMethod: $paymentMethod, isSubmitting: $isSubmitting)';
|
||||
}
|
||||
|
||||
@override
|
||||
@ -738,6 +1043,11 @@ class _$PaymentFormStateImpl implements _PaymentFormState {
|
||||
) &&
|
||||
(identical(other.failureOrPayment, failureOrPayment) ||
|
||||
other.failureOrPayment == failureOrPayment) &&
|
||||
(identical(
|
||||
other.failureOrPaymentSplitBill,
|
||||
failureOrPaymentSplitBill,
|
||||
) ||
|
||||
other.failureOrPaymentSplitBill == failureOrPaymentSplitBill) &&
|
||||
(identical(other.paymentMethod, paymentMethod) ||
|
||||
other.paymentMethod == paymentMethod) &&
|
||||
(identical(other.isSubmitting, isSubmitting) ||
|
||||
@ -750,6 +1060,7 @@ class _$PaymentFormStateImpl implements _PaymentFormState {
|
||||
order,
|
||||
const DeepCollectionEquality().hash(_pendingItems),
|
||||
failureOrPayment,
|
||||
failureOrPaymentSplitBill,
|
||||
paymentMethod,
|
||||
isSubmitting,
|
||||
);
|
||||
@ -771,6 +1082,8 @@ abstract class _PaymentFormState implements PaymentFormState {
|
||||
required final Order order,
|
||||
required final List<OrderItem> pendingItems,
|
||||
required final Option<Either<OrderFailure, Payment>> failureOrPayment,
|
||||
required final Option<Either<OrderFailure, Payment>>
|
||||
failureOrPaymentSplitBill,
|
||||
final PaymentMethod? paymentMethod,
|
||||
final bool isSubmitting,
|
||||
}) = _$PaymentFormStateImpl;
|
||||
@ -782,6 +1095,8 @@ abstract class _PaymentFormState implements PaymentFormState {
|
||||
@override
|
||||
Option<Either<OrderFailure, Payment>> get failureOrPayment;
|
||||
@override
|
||||
Option<Either<OrderFailure, Payment>> get failureOrPaymentSplitBill;
|
||||
@override
|
||||
PaymentMethod? get paymentMethod;
|
||||
@override
|
||||
bool get isSubmitting;
|
||||
|
||||
@ -6,4 +6,9 @@ class PaymentFormEvent with _$PaymentFormEvent {
|
||||
const factory PaymentFormEvent.setPaymentMethod(PaymentMethod paymentMethod) =
|
||||
_SetPayment;
|
||||
const factory PaymentFormEvent.submitted() = _Submitted;
|
||||
const factory PaymentFormEvent.submittedSplitBill({
|
||||
SplitType? splitType,
|
||||
String? customerId,
|
||||
String? customerName,
|
||||
}) = _SubmittedSplitBill;
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ class PaymentFormState with _$PaymentFormState {
|
||||
required Order order,
|
||||
required List<OrderItem> pendingItems,
|
||||
required Option<Either<OrderFailure, Payment>> failureOrPayment,
|
||||
required Option<Either<OrderFailure, Payment>> failureOrPaymentSplitBill,
|
||||
PaymentMethod? paymentMethod,
|
||||
@Default(false) bool isSubmitting,
|
||||
}) = _PaymentFormState;
|
||||
@ -14,5 +15,6 @@ class PaymentFormState with _$PaymentFormState {
|
||||
order: Order.empty(),
|
||||
pendingItems: [],
|
||||
failureOrPayment: none(),
|
||||
failureOrPaymentSplitBill: none(),
|
||||
);
|
||||
}
|
||||
|
||||
@ -0,0 +1,85 @@
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:injectable/injectable.dart' hide Order;
|
||||
|
||||
import '../../../common/extension/extension.dart';
|
||||
import '../../../common/types/split_type.dart';
|
||||
import '../../../domain/customer/customer.dart';
|
||||
import '../../../domain/order/order.dart';
|
||||
|
||||
part 'split_bill_form_event.dart';
|
||||
part 'split_bill_form_state.dart';
|
||||
part 'split_bill_form_bloc.freezed.dart';
|
||||
|
||||
@injectable
|
||||
class SplitBillFormBloc extends Bloc<SplitBillFormEvent, SplitBillFormState> {
|
||||
SplitBillFormBloc() : super(SplitBillFormState.initial()) {
|
||||
on<SplitBillFormEvent>(_onSplitBillFormEvent);
|
||||
}
|
||||
|
||||
Future<void> _onSplitBillFormEvent(
|
||||
SplitBillFormEvent event,
|
||||
Emitter<SplitBillFormState> 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,
|
||||
splitType: e.order.splitType.isEmpty
|
||||
? SplitType.amount
|
||||
: e.order.splitType.toSplitType(),
|
||||
),
|
||||
);
|
||||
},
|
||||
customerChanged: (e) async {
|
||||
emit(state.copyWith(customer: e.customer));
|
||||
},
|
||||
customerNameChanged: (e) async {
|
||||
emit(state.copyWith(customerName: e.customerName));
|
||||
},
|
||||
splitTypeChanged: (e) async {
|
||||
emit(
|
||||
state.copyWith(
|
||||
splitType: e.splitType,
|
||||
totalAmount: 0,
|
||||
selectedProducts: {},
|
||||
),
|
||||
);
|
||||
},
|
||||
itemQuantityChanged: (e) async {
|
||||
final newQuantities = Map<String, int>.from(state.selectedProducts);
|
||||
|
||||
if (e.quantity > 0) {
|
||||
newQuantities[e.itemId] = e.quantity;
|
||||
} else {
|
||||
newQuantities.remove(e.itemId);
|
||||
}
|
||||
|
||||
// Recalculate total price
|
||||
int newTotal = 0;
|
||||
for (var entry in newQuantities.entries) {
|
||||
final item = state.pendingItems.firstWhere(
|
||||
(item) => item.id == entry.key,
|
||||
);
|
||||
newTotal += item.unitPrice.toInt() * entry.value;
|
||||
}
|
||||
|
||||
emit(
|
||||
state.copyWith(
|
||||
selectedProducts: newQuantities,
|
||||
totalAmount: newTotal,
|
||||
),
|
||||
);
|
||||
},
|
||||
amountChanged: (e) async {
|
||||
emit(state.copyWith(totalAmount: e.amount));
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,17 @@
|
||||
part of 'split_bill_form_bloc.dart';
|
||||
|
||||
@freezed
|
||||
class SplitBillFormEvent with _$SplitBillFormEvent {
|
||||
const factory SplitBillFormEvent.setOrder(Order order) = _SetOrder;
|
||||
const factory SplitBillFormEvent.customerChanged(Customer customer) =
|
||||
_CustomerChanged;
|
||||
const factory SplitBillFormEvent.customerNameChanged(String customerName) =
|
||||
_CustomerNameChanged;
|
||||
const factory SplitBillFormEvent.splitTypeChanged(SplitType splitType) =
|
||||
_SplitTypeChanged;
|
||||
const factory SplitBillFormEvent.itemQuantityChanged({
|
||||
required String itemId,
|
||||
required int quantity,
|
||||
}) = _ItemQuantityChanged;
|
||||
const factory SplitBillFormEvent.amountChanged(int amount) = _AmountChanged;
|
||||
}
|
||||
@ -0,0 +1,23 @@
|
||||
part of 'split_bill_form_bloc.dart';
|
||||
|
||||
@freezed
|
||||
class SplitBillFormState with _$SplitBillFormState {
|
||||
factory SplitBillFormState({
|
||||
required Order order,
|
||||
required List<OrderItem> pendingItems,
|
||||
Customer? customer,
|
||||
required String customerName,
|
||||
required SplitType splitType,
|
||||
required Map<String, int> selectedProducts,
|
||||
@Default(0) int totalAmount,
|
||||
@Default(false) bool isConfirming,
|
||||
}) = _SplitBillFormState;
|
||||
|
||||
factory SplitBillFormState.initial() => SplitBillFormState(
|
||||
order: Order.empty(),
|
||||
pendingItems: [],
|
||||
customerName: '',
|
||||
splitType: SplitType.amount,
|
||||
selectedProducts: {},
|
||||
);
|
||||
}
|
||||
@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
import '../../domain/table/table.dart';
|
||||
import '../types/split_type.dart';
|
||||
import '../types/void_type.dart';
|
||||
|
||||
part 'build_context_extension.dart';
|
||||
|
||||
@ -39,12 +39,23 @@ extension StringX on String {
|
||||
|
||||
VoidType toVoidType() {
|
||||
switch (this) {
|
||||
case 'all':
|
||||
case 'ALL':
|
||||
return VoidType.all;
|
||||
case 'item':
|
||||
case 'ITEM':
|
||||
return VoidType.item;
|
||||
default:
|
||||
return VoidType.unknown;
|
||||
}
|
||||
}
|
||||
|
||||
SplitType toSplitType() {
|
||||
switch (this) {
|
||||
case 'AMOUNT':
|
||||
return SplitType.amount;
|
||||
case 'ITEM':
|
||||
return SplitType.item;
|
||||
default:
|
||||
return SplitType.unknown;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
12
lib/common/types/split_type.dart
Normal file
12
lib/common/types/split_type.dart
Normal file
@ -0,0 +1,12 @@
|
||||
enum SplitType { amount, item, unknown }
|
||||
|
||||
extension SplitTypeX on SplitType {
|
||||
String toStringType() => switch (this) {
|
||||
SplitType.amount => 'AMOUNT',
|
||||
SplitType.item => 'ITEM',
|
||||
SplitType.unknown => 'unknown',
|
||||
};
|
||||
|
||||
bool get isAmount => this == SplitType.amount;
|
||||
bool get isItem => this == SplitType.item;
|
||||
}
|
||||
@ -35,3 +35,37 @@ class PaymentItemRequest with _$PaymentItemRequest {
|
||||
factory PaymentItemRequest.empty() =>
|
||||
const PaymentItemRequest(orderItemId: '', amount: 0);
|
||||
}
|
||||
|
||||
@freezed
|
||||
class PaymentSplitBillRequest with _$PaymentSplitBillRequest {
|
||||
const factory PaymentSplitBillRequest({
|
||||
required String orderId,
|
||||
required String paymentMethodId,
|
||||
required String customerId,
|
||||
required String customerName,
|
||||
required SplitType type, // e.g., "AMOUNT" or "ITEM"
|
||||
required int amount,
|
||||
required List<PaymentItemSplitBillRequest> items,
|
||||
}) = _PaymentSplitBillRequest;
|
||||
|
||||
factory PaymentSplitBillRequest.empty() => const PaymentSplitBillRequest(
|
||||
orderId: '',
|
||||
paymentMethodId: '',
|
||||
customerId: '',
|
||||
type: SplitType.unknown,
|
||||
amount: 0,
|
||||
items: [],
|
||||
customerName: '',
|
||||
);
|
||||
}
|
||||
|
||||
@freezed
|
||||
class PaymentItemSplitBillRequest with _$PaymentItemSplitBillRequest {
|
||||
const factory PaymentItemSplitBillRequest({
|
||||
required String orderItemId,
|
||||
required int quantity,
|
||||
}) = _PaymentItemSplitBillRequest;
|
||||
|
||||
factory PaymentItemSplitBillRequest.empty() =>
|
||||
const PaymentItemSplitBillRequest(orderItemId: '', quantity: 0);
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@ import 'package:dartz/dartz.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
import '../../common/api/api_failure.dart';
|
||||
import '../../common/types/split_type.dart';
|
||||
|
||||
part 'order.freezed.dart';
|
||||
|
||||
|
||||
@ -2455,6 +2455,470 @@ abstract class _PaymentItemRequest implements PaymentItemRequest {
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$PaymentSplitBillRequest {
|
||||
String get orderId => throw _privateConstructorUsedError;
|
||||
String get paymentMethodId => throw _privateConstructorUsedError;
|
||||
String get customerId => throw _privateConstructorUsedError;
|
||||
String get customerName => throw _privateConstructorUsedError;
|
||||
SplitType get type =>
|
||||
throw _privateConstructorUsedError; // e.g., "AMOUNT" or "ITEM"
|
||||
int get amount => throw _privateConstructorUsedError;
|
||||
List<PaymentItemSplitBillRequest> get items =>
|
||||
throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of PaymentSplitBillRequest
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$PaymentSplitBillRequestCopyWith<PaymentSplitBillRequest> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $PaymentSplitBillRequestCopyWith<$Res> {
|
||||
factory $PaymentSplitBillRequestCopyWith(
|
||||
PaymentSplitBillRequest value,
|
||||
$Res Function(PaymentSplitBillRequest) then,
|
||||
) = _$PaymentSplitBillRequestCopyWithImpl<$Res, PaymentSplitBillRequest>;
|
||||
@useResult
|
||||
$Res call({
|
||||
String orderId,
|
||||
String paymentMethodId,
|
||||
String customerId,
|
||||
String customerName,
|
||||
SplitType type,
|
||||
int amount,
|
||||
List<PaymentItemSplitBillRequest> items,
|
||||
});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$PaymentSplitBillRequestCopyWithImpl<
|
||||
$Res,
|
||||
$Val extends PaymentSplitBillRequest
|
||||
>
|
||||
implements $PaymentSplitBillRequestCopyWith<$Res> {
|
||||
_$PaymentSplitBillRequestCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of PaymentSplitBillRequest
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? orderId = null,
|
||||
Object? paymentMethodId = null,
|
||||
Object? customerId = null,
|
||||
Object? customerName = null,
|
||||
Object? type = null,
|
||||
Object? amount = null,
|
||||
Object? items = null,
|
||||
}) {
|
||||
return _then(
|
||||
_value.copyWith(
|
||||
orderId: null == orderId
|
||||
? _value.orderId
|
||||
: orderId // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
paymentMethodId: null == paymentMethodId
|
||||
? _value.paymentMethodId
|
||||
: paymentMethodId // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
customerId: null == customerId
|
||||
? _value.customerId
|
||||
: customerId // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
customerName: null == customerName
|
||||
? _value.customerName
|
||||
: customerName // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
type: null == type
|
||||
? _value.type
|
||||
: type // ignore: cast_nullable_to_non_nullable
|
||||
as SplitType,
|
||||
amount: null == amount
|
||||
? _value.amount
|
||||
: amount // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
items: null == items
|
||||
? _value.items
|
||||
: items // ignore: cast_nullable_to_non_nullable
|
||||
as List<PaymentItemSplitBillRequest>,
|
||||
)
|
||||
as $Val,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$PaymentSplitBillRequestImplCopyWith<$Res>
|
||||
implements $PaymentSplitBillRequestCopyWith<$Res> {
|
||||
factory _$$PaymentSplitBillRequestImplCopyWith(
|
||||
_$PaymentSplitBillRequestImpl value,
|
||||
$Res Function(_$PaymentSplitBillRequestImpl) then,
|
||||
) = __$$PaymentSplitBillRequestImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({
|
||||
String orderId,
|
||||
String paymentMethodId,
|
||||
String customerId,
|
||||
String customerName,
|
||||
SplitType type,
|
||||
int amount,
|
||||
List<PaymentItemSplitBillRequest> items,
|
||||
});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$PaymentSplitBillRequestImplCopyWithImpl<$Res>
|
||||
extends
|
||||
_$PaymentSplitBillRequestCopyWithImpl<
|
||||
$Res,
|
||||
_$PaymentSplitBillRequestImpl
|
||||
>
|
||||
implements _$$PaymentSplitBillRequestImplCopyWith<$Res> {
|
||||
__$$PaymentSplitBillRequestImplCopyWithImpl(
|
||||
_$PaymentSplitBillRequestImpl _value,
|
||||
$Res Function(_$PaymentSplitBillRequestImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of PaymentSplitBillRequest
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? orderId = null,
|
||||
Object? paymentMethodId = null,
|
||||
Object? customerId = null,
|
||||
Object? customerName = null,
|
||||
Object? type = null,
|
||||
Object? amount = null,
|
||||
Object? items = null,
|
||||
}) {
|
||||
return _then(
|
||||
_$PaymentSplitBillRequestImpl(
|
||||
orderId: null == orderId
|
||||
? _value.orderId
|
||||
: orderId // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
paymentMethodId: null == paymentMethodId
|
||||
? _value.paymentMethodId
|
||||
: paymentMethodId // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
customerId: null == customerId
|
||||
? _value.customerId
|
||||
: customerId // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
customerName: null == customerName
|
||||
? _value.customerName
|
||||
: customerName // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
type: null == type
|
||||
? _value.type
|
||||
: type // ignore: cast_nullable_to_non_nullable
|
||||
as SplitType,
|
||||
amount: null == amount
|
||||
? _value.amount
|
||||
: amount // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
items: null == items
|
||||
? _value._items
|
||||
: items // ignore: cast_nullable_to_non_nullable
|
||||
as List<PaymentItemSplitBillRequest>,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$PaymentSplitBillRequestImpl implements _PaymentSplitBillRequest {
|
||||
const _$PaymentSplitBillRequestImpl({
|
||||
required this.orderId,
|
||||
required this.paymentMethodId,
|
||||
required this.customerId,
|
||||
required this.customerName,
|
||||
required this.type,
|
||||
required this.amount,
|
||||
required final List<PaymentItemSplitBillRequest> items,
|
||||
}) : _items = items;
|
||||
|
||||
@override
|
||||
final String orderId;
|
||||
@override
|
||||
final String paymentMethodId;
|
||||
@override
|
||||
final String customerId;
|
||||
@override
|
||||
final String customerName;
|
||||
@override
|
||||
final SplitType type;
|
||||
// e.g., "AMOUNT" or "ITEM"
|
||||
@override
|
||||
final int amount;
|
||||
final List<PaymentItemSplitBillRequest> _items;
|
||||
@override
|
||||
List<PaymentItemSplitBillRequest> get items {
|
||||
if (_items is EqualUnmodifiableListView) return _items;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_items);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'PaymentSplitBillRequest(orderId: $orderId, paymentMethodId: $paymentMethodId, customerId: $customerId, customerName: $customerName, type: $type, amount: $amount, items: $items)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$PaymentSplitBillRequestImpl &&
|
||||
(identical(other.orderId, orderId) || other.orderId == orderId) &&
|
||||
(identical(other.paymentMethodId, paymentMethodId) ||
|
||||
other.paymentMethodId == paymentMethodId) &&
|
||||
(identical(other.customerId, customerId) ||
|
||||
other.customerId == customerId) &&
|
||||
(identical(other.customerName, customerName) ||
|
||||
other.customerName == customerName) &&
|
||||
(identical(other.type, type) || other.type == type) &&
|
||||
(identical(other.amount, amount) || other.amount == amount) &&
|
||||
const DeepCollectionEquality().equals(other._items, _items));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(
|
||||
runtimeType,
|
||||
orderId,
|
||||
paymentMethodId,
|
||||
customerId,
|
||||
customerName,
|
||||
type,
|
||||
amount,
|
||||
const DeepCollectionEquality().hash(_items),
|
||||
);
|
||||
|
||||
/// Create a copy of PaymentSplitBillRequest
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$PaymentSplitBillRequestImplCopyWith<_$PaymentSplitBillRequestImpl>
|
||||
get copyWith =>
|
||||
__$$PaymentSplitBillRequestImplCopyWithImpl<
|
||||
_$PaymentSplitBillRequestImpl
|
||||
>(this, _$identity);
|
||||
}
|
||||
|
||||
abstract class _PaymentSplitBillRequest implements PaymentSplitBillRequest {
|
||||
const factory _PaymentSplitBillRequest({
|
||||
required final String orderId,
|
||||
required final String paymentMethodId,
|
||||
required final String customerId,
|
||||
required final String customerName,
|
||||
required final SplitType type,
|
||||
required final int amount,
|
||||
required final List<PaymentItemSplitBillRequest> items,
|
||||
}) = _$PaymentSplitBillRequestImpl;
|
||||
|
||||
@override
|
||||
String get orderId;
|
||||
@override
|
||||
String get paymentMethodId;
|
||||
@override
|
||||
String get customerId;
|
||||
@override
|
||||
String get customerName;
|
||||
@override
|
||||
SplitType get type; // e.g., "AMOUNT" or "ITEM"
|
||||
@override
|
||||
int get amount;
|
||||
@override
|
||||
List<PaymentItemSplitBillRequest> get items;
|
||||
|
||||
/// Create a copy of PaymentSplitBillRequest
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$PaymentSplitBillRequestImplCopyWith<_$PaymentSplitBillRequestImpl>
|
||||
get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$PaymentItemSplitBillRequest {
|
||||
String get orderItemId => throw _privateConstructorUsedError;
|
||||
int get quantity => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of PaymentItemSplitBillRequest
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$PaymentItemSplitBillRequestCopyWith<PaymentItemSplitBillRequest>
|
||||
get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $PaymentItemSplitBillRequestCopyWith<$Res> {
|
||||
factory $PaymentItemSplitBillRequestCopyWith(
|
||||
PaymentItemSplitBillRequest value,
|
||||
$Res Function(PaymentItemSplitBillRequest) then,
|
||||
) =
|
||||
_$PaymentItemSplitBillRequestCopyWithImpl<
|
||||
$Res,
|
||||
PaymentItemSplitBillRequest
|
||||
>;
|
||||
@useResult
|
||||
$Res call({String orderItemId, int quantity});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$PaymentItemSplitBillRequestCopyWithImpl<
|
||||
$Res,
|
||||
$Val extends PaymentItemSplitBillRequest
|
||||
>
|
||||
implements $PaymentItemSplitBillRequestCopyWith<$Res> {
|
||||
_$PaymentItemSplitBillRequestCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of PaymentItemSplitBillRequest
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({Object? orderItemId = null, Object? quantity = null}) {
|
||||
return _then(
|
||||
_value.copyWith(
|
||||
orderItemId: null == orderItemId
|
||||
? _value.orderItemId
|
||||
: orderItemId // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
quantity: null == quantity
|
||||
? _value.quantity
|
||||
: quantity // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
)
|
||||
as $Val,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$PaymentItemSplitBillRequestImplCopyWith<$Res>
|
||||
implements $PaymentItemSplitBillRequestCopyWith<$Res> {
|
||||
factory _$$PaymentItemSplitBillRequestImplCopyWith(
|
||||
_$PaymentItemSplitBillRequestImpl value,
|
||||
$Res Function(_$PaymentItemSplitBillRequestImpl) then,
|
||||
) = __$$PaymentItemSplitBillRequestImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({String orderItemId, int quantity});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$PaymentItemSplitBillRequestImplCopyWithImpl<$Res>
|
||||
extends
|
||||
_$PaymentItemSplitBillRequestCopyWithImpl<
|
||||
$Res,
|
||||
_$PaymentItemSplitBillRequestImpl
|
||||
>
|
||||
implements _$$PaymentItemSplitBillRequestImplCopyWith<$Res> {
|
||||
__$$PaymentItemSplitBillRequestImplCopyWithImpl(
|
||||
_$PaymentItemSplitBillRequestImpl _value,
|
||||
$Res Function(_$PaymentItemSplitBillRequestImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of PaymentItemSplitBillRequest
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({Object? orderItemId = null, Object? quantity = null}) {
|
||||
return _then(
|
||||
_$PaymentItemSplitBillRequestImpl(
|
||||
orderItemId: null == orderItemId
|
||||
? _value.orderItemId
|
||||
: orderItemId // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
quantity: null == quantity
|
||||
? _value.quantity
|
||||
: quantity // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$PaymentItemSplitBillRequestImpl
|
||||
implements _PaymentItemSplitBillRequest {
|
||||
const _$PaymentItemSplitBillRequestImpl({
|
||||
required this.orderItemId,
|
||||
required this.quantity,
|
||||
});
|
||||
|
||||
@override
|
||||
final String orderItemId;
|
||||
@override
|
||||
final int quantity;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'PaymentItemSplitBillRequest(orderItemId: $orderItemId, quantity: $quantity)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$PaymentItemSplitBillRequestImpl &&
|
||||
(identical(other.orderItemId, orderItemId) ||
|
||||
other.orderItemId == orderItemId) &&
|
||||
(identical(other.quantity, quantity) ||
|
||||
other.quantity == quantity));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, orderItemId, quantity);
|
||||
|
||||
/// Create a copy of PaymentItemSplitBillRequest
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$PaymentItemSplitBillRequestImplCopyWith<_$PaymentItemSplitBillRequestImpl>
|
||||
get copyWith =>
|
||||
__$$PaymentItemSplitBillRequestImplCopyWithImpl<
|
||||
_$PaymentItemSplitBillRequestImpl
|
||||
>(this, _$identity);
|
||||
}
|
||||
|
||||
abstract class _PaymentItemSplitBillRequest
|
||||
implements PaymentItemSplitBillRequest {
|
||||
const factory _PaymentItemSplitBillRequest({
|
||||
required final String orderItemId,
|
||||
required final int quantity,
|
||||
}) = _$PaymentItemSplitBillRequestImpl;
|
||||
|
||||
@override
|
||||
String get orderItemId;
|
||||
@override
|
||||
int get quantity;
|
||||
|
||||
/// Create a copy of PaymentItemSplitBillRequest
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$PaymentItemSplitBillRequestImplCopyWith<_$PaymentItemSplitBillRequestImpl>
|
||||
get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$Payment {
|
||||
String get id => throw _privateConstructorUsedError;
|
||||
|
||||
@ -36,4 +36,8 @@ abstract class IOrderRepository {
|
||||
String type = "ITEM", // TYPE: ALL, ITEM
|
||||
required List<OrderItem> orderItems,
|
||||
});
|
||||
|
||||
Future<Either<OrderFailure, Payment>> createSplitBill(
|
||||
PaymentSplitBillRequest request,
|
||||
);
|
||||
}
|
||||
|
||||
@ -236,4 +236,29 @@ class OrderRemoteDataProvider {
|
||||
return DC.error(OrderFailure.serverError(e));
|
||||
}
|
||||
}
|
||||
|
||||
Future<DC<OrderFailure, PaymentDto>> createSplitBill(
|
||||
PaymentSplitBillRequestDto request,
|
||||
) async {
|
||||
try {
|
||||
final response = await _apiClient.post(
|
||||
"${ApiPath.orders}/split-bill",
|
||||
data: request.toRequest(),
|
||||
headers: getAuthorizationHeader(),
|
||||
);
|
||||
|
||||
if (response.data['success'] == false) {
|
||||
return DC.error(OrderFailure.unexpectedError());
|
||||
}
|
||||
|
||||
final payment = PaymentDto.fromJson(
|
||||
response.data['data'] as Map<String, dynamic>,
|
||||
);
|
||||
|
||||
return DC.data(payment);
|
||||
} on ApiFailure catch (e, s) {
|
||||
log('createSplitBillError', name: _logName, error: e, stackTrace: s);
|
||||
return DC.error(OrderFailure.serverError(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -69,3 +69,102 @@ class PaymentItemRequestDto with _$PaymentItemRequestDto {
|
||||
amount: request.amount,
|
||||
);
|
||||
}
|
||||
|
||||
@freezed
|
||||
class PaymentSplitBillRequestDto with _$PaymentSplitBillRequestDto {
|
||||
const PaymentSplitBillRequestDto._();
|
||||
|
||||
const factory PaymentSplitBillRequestDto({
|
||||
@JsonKey(name: "order_id") String? orderId,
|
||||
@JsonKey(name: "payment_method_id") String? paymentMethodId,
|
||||
@JsonKey(name: "customer_id") String? customerId,
|
||||
@JsonKey(name: "customer_name") String? customerName,
|
||||
@JsonKey(name: "type") String? type, // e.g., "AMOUNT" or "ITEM"
|
||||
@JsonKey(name: "amount") int? amount,
|
||||
@JsonKey(name: "items") List<PaymentItemSplitBillRequestDto>? items,
|
||||
}) = _PaymentSplitBillRequestDto;
|
||||
|
||||
factory PaymentSplitBillRequestDto.fromJson(Map<String, dynamic> json) =>
|
||||
_$PaymentSplitBillRequestDtoFromJson(json);
|
||||
|
||||
// Optional mapper ke domain
|
||||
PaymentSplitBillRequest toDomain() => PaymentSplitBillRequest(
|
||||
orderId: orderId ?? '',
|
||||
paymentMethodId: paymentMethodId ?? '',
|
||||
customerId: customerId ?? '',
|
||||
type: type?.toSplitType() ?? SplitType.unknown,
|
||||
amount: amount ?? 0,
|
||||
items: items?.map((e) => e.toDomain()).toList() ?? [],
|
||||
customerName: customerName ?? '',
|
||||
);
|
||||
|
||||
factory PaymentSplitBillRequestDto.fromDomain(
|
||||
PaymentSplitBillRequest request,
|
||||
) => PaymentSplitBillRequestDto(
|
||||
orderId: request.orderId,
|
||||
paymentMethodId: request.paymentMethodId,
|
||||
customerId: request.customerId,
|
||||
type: request.type.toStringType(),
|
||||
amount: request.amount,
|
||||
items: request.items
|
||||
.map((e) => PaymentItemSplitBillRequestDto.fromDomain(e))
|
||||
.toList(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> toRequest() {
|
||||
Map<String, dynamic> data = {
|
||||
'order_id': orderId,
|
||||
'payment_method_id': paymentMethodId,
|
||||
'type': type,
|
||||
};
|
||||
|
||||
if (customerId != null && customerId != '') {
|
||||
data['customer_id'] = customerId;
|
||||
}
|
||||
|
||||
if (customerName != null && customerName != '') {
|
||||
data['customer_name'] = customerName;
|
||||
}
|
||||
|
||||
if (type == 'AMOUNT') {
|
||||
data['amount'] = amount;
|
||||
}
|
||||
|
||||
if (type == 'ITEM') {
|
||||
data['items'] = items?.map((item) => item.toRequest()).toList();
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
@freezed
|
||||
class PaymentItemSplitBillRequestDto with _$PaymentItemSplitBillRequestDto {
|
||||
const PaymentItemSplitBillRequestDto._();
|
||||
|
||||
const factory PaymentItemSplitBillRequestDto({
|
||||
@JsonKey(name: "order_item_id") String? orderItemId,
|
||||
@JsonKey(name: "quantity") int? quantity,
|
||||
}) = _PaymentItemSplitBillRequestDto;
|
||||
|
||||
factory PaymentItemSplitBillRequestDto.fromJson(Map<String, dynamic> json) =>
|
||||
_$PaymentItemSplitBillRequestDtoFromJson(json);
|
||||
|
||||
// Optional mapper ke domain
|
||||
PaymentItemSplitBillRequest toDomain() => PaymentItemSplitBillRequest(
|
||||
orderItemId: orderItemId ?? '',
|
||||
quantity: quantity ?? 0,
|
||||
);
|
||||
|
||||
factory PaymentItemSplitBillRequestDto.fromDomain(
|
||||
PaymentItemSplitBillRequest request,
|
||||
) => PaymentItemSplitBillRequestDto(
|
||||
orderItemId: request.orderItemId,
|
||||
quantity: request.quantity,
|
||||
);
|
||||
|
||||
Map<String, dynamic> toRequest() => {
|
||||
'order_item_id': orderItemId,
|
||||
'quantity': quantity,
|
||||
};
|
||||
}
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
import '../../common/extension/extension.dart';
|
||||
import '../../common/types/split_type.dart';
|
||||
import '../../domain/order/order.dart';
|
||||
|
||||
part 'order_dtos.freezed.dart';
|
||||
|
||||
@ -2851,6 +2851,559 @@ abstract class _PaymentItemRequestDto extends PaymentItemRequestDto {
|
||||
get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
PaymentSplitBillRequestDto _$PaymentSplitBillRequestDtoFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) {
|
||||
return _PaymentSplitBillRequestDto.fromJson(json);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$PaymentSplitBillRequestDto {
|
||||
@JsonKey(name: "order_id")
|
||||
String? get orderId => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: "payment_method_id")
|
||||
String? get paymentMethodId => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: "customer_id")
|
||||
String? get customerId => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: "customer_name")
|
||||
String? get customerName => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: "type")
|
||||
String? get type => throw _privateConstructorUsedError; // e.g., "AMOUNT" or "ITEM"
|
||||
@JsonKey(name: "amount")
|
||||
int? get amount => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: "items")
|
||||
List<PaymentItemSplitBillRequestDto>? get items =>
|
||||
throw _privateConstructorUsedError;
|
||||
|
||||
/// Serializes this PaymentSplitBillRequestDto to a JSON map.
|
||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of PaymentSplitBillRequestDto
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$PaymentSplitBillRequestDtoCopyWith<PaymentSplitBillRequestDto>
|
||||
get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $PaymentSplitBillRequestDtoCopyWith<$Res> {
|
||||
factory $PaymentSplitBillRequestDtoCopyWith(
|
||||
PaymentSplitBillRequestDto value,
|
||||
$Res Function(PaymentSplitBillRequestDto) then,
|
||||
) =
|
||||
_$PaymentSplitBillRequestDtoCopyWithImpl<
|
||||
$Res,
|
||||
PaymentSplitBillRequestDto
|
||||
>;
|
||||
@useResult
|
||||
$Res call({
|
||||
@JsonKey(name: "order_id") String? orderId,
|
||||
@JsonKey(name: "payment_method_id") String? paymentMethodId,
|
||||
@JsonKey(name: "customer_id") String? customerId,
|
||||
@JsonKey(name: "customer_name") String? customerName,
|
||||
@JsonKey(name: "type") String? type,
|
||||
@JsonKey(name: "amount") int? amount,
|
||||
@JsonKey(name: "items") List<PaymentItemSplitBillRequestDto>? items,
|
||||
});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$PaymentSplitBillRequestDtoCopyWithImpl<
|
||||
$Res,
|
||||
$Val extends PaymentSplitBillRequestDto
|
||||
>
|
||||
implements $PaymentSplitBillRequestDtoCopyWith<$Res> {
|
||||
_$PaymentSplitBillRequestDtoCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of PaymentSplitBillRequestDto
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? orderId = freezed,
|
||||
Object? paymentMethodId = freezed,
|
||||
Object? customerId = freezed,
|
||||
Object? customerName = freezed,
|
||||
Object? type = freezed,
|
||||
Object? amount = freezed,
|
||||
Object? items = freezed,
|
||||
}) {
|
||||
return _then(
|
||||
_value.copyWith(
|
||||
orderId: freezed == orderId
|
||||
? _value.orderId
|
||||
: orderId // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
paymentMethodId: freezed == paymentMethodId
|
||||
? _value.paymentMethodId
|
||||
: paymentMethodId // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
customerId: freezed == customerId
|
||||
? _value.customerId
|
||||
: customerId // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
customerName: freezed == customerName
|
||||
? _value.customerName
|
||||
: customerName // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
type: freezed == type
|
||||
? _value.type
|
||||
: type // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
amount: freezed == amount
|
||||
? _value.amount
|
||||
: amount // ignore: cast_nullable_to_non_nullable
|
||||
as int?,
|
||||
items: freezed == items
|
||||
? _value.items
|
||||
: items // ignore: cast_nullable_to_non_nullable
|
||||
as List<PaymentItemSplitBillRequestDto>?,
|
||||
)
|
||||
as $Val,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$PaymentSplitBillRequestDtoImplCopyWith<$Res>
|
||||
implements $PaymentSplitBillRequestDtoCopyWith<$Res> {
|
||||
factory _$$PaymentSplitBillRequestDtoImplCopyWith(
|
||||
_$PaymentSplitBillRequestDtoImpl value,
|
||||
$Res Function(_$PaymentSplitBillRequestDtoImpl) then,
|
||||
) = __$$PaymentSplitBillRequestDtoImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({
|
||||
@JsonKey(name: "order_id") String? orderId,
|
||||
@JsonKey(name: "payment_method_id") String? paymentMethodId,
|
||||
@JsonKey(name: "customer_id") String? customerId,
|
||||
@JsonKey(name: "customer_name") String? customerName,
|
||||
@JsonKey(name: "type") String? type,
|
||||
@JsonKey(name: "amount") int? amount,
|
||||
@JsonKey(name: "items") List<PaymentItemSplitBillRequestDto>? items,
|
||||
});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$PaymentSplitBillRequestDtoImplCopyWithImpl<$Res>
|
||||
extends
|
||||
_$PaymentSplitBillRequestDtoCopyWithImpl<
|
||||
$Res,
|
||||
_$PaymentSplitBillRequestDtoImpl
|
||||
>
|
||||
implements _$$PaymentSplitBillRequestDtoImplCopyWith<$Res> {
|
||||
__$$PaymentSplitBillRequestDtoImplCopyWithImpl(
|
||||
_$PaymentSplitBillRequestDtoImpl _value,
|
||||
$Res Function(_$PaymentSplitBillRequestDtoImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of PaymentSplitBillRequestDto
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? orderId = freezed,
|
||||
Object? paymentMethodId = freezed,
|
||||
Object? customerId = freezed,
|
||||
Object? customerName = freezed,
|
||||
Object? type = freezed,
|
||||
Object? amount = freezed,
|
||||
Object? items = freezed,
|
||||
}) {
|
||||
return _then(
|
||||
_$PaymentSplitBillRequestDtoImpl(
|
||||
orderId: freezed == orderId
|
||||
? _value.orderId
|
||||
: orderId // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
paymentMethodId: freezed == paymentMethodId
|
||||
? _value.paymentMethodId
|
||||
: paymentMethodId // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
customerId: freezed == customerId
|
||||
? _value.customerId
|
||||
: customerId // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
customerName: freezed == customerName
|
||||
? _value.customerName
|
||||
: customerName // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
type: freezed == type
|
||||
? _value.type
|
||||
: type // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
amount: freezed == amount
|
||||
? _value.amount
|
||||
: amount // ignore: cast_nullable_to_non_nullable
|
||||
as int?,
|
||||
items: freezed == items
|
||||
? _value._items
|
||||
: items // ignore: cast_nullable_to_non_nullable
|
||||
as List<PaymentItemSplitBillRequestDto>?,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
class _$PaymentSplitBillRequestDtoImpl extends _PaymentSplitBillRequestDto {
|
||||
const _$PaymentSplitBillRequestDtoImpl({
|
||||
@JsonKey(name: "order_id") this.orderId,
|
||||
@JsonKey(name: "payment_method_id") this.paymentMethodId,
|
||||
@JsonKey(name: "customer_id") this.customerId,
|
||||
@JsonKey(name: "customer_name") this.customerName,
|
||||
@JsonKey(name: "type") this.type,
|
||||
@JsonKey(name: "amount") this.amount,
|
||||
@JsonKey(name: "items") final List<PaymentItemSplitBillRequestDto>? items,
|
||||
}) : _items = items,
|
||||
super._();
|
||||
|
||||
factory _$PaymentSplitBillRequestDtoImpl.fromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => _$$PaymentSplitBillRequestDtoImplFromJson(json);
|
||||
|
||||
@override
|
||||
@JsonKey(name: "order_id")
|
||||
final String? orderId;
|
||||
@override
|
||||
@JsonKey(name: "payment_method_id")
|
||||
final String? paymentMethodId;
|
||||
@override
|
||||
@JsonKey(name: "customer_id")
|
||||
final String? customerId;
|
||||
@override
|
||||
@JsonKey(name: "customer_name")
|
||||
final String? customerName;
|
||||
@override
|
||||
@JsonKey(name: "type")
|
||||
final String? type;
|
||||
// e.g., "AMOUNT" or "ITEM"
|
||||
@override
|
||||
@JsonKey(name: "amount")
|
||||
final int? amount;
|
||||
final List<PaymentItemSplitBillRequestDto>? _items;
|
||||
@override
|
||||
@JsonKey(name: "items")
|
||||
List<PaymentItemSplitBillRequestDto>? get items {
|
||||
final value = _items;
|
||||
if (value == null) return null;
|
||||
if (_items is EqualUnmodifiableListView) return _items;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(value);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'PaymentSplitBillRequestDto(orderId: $orderId, paymentMethodId: $paymentMethodId, customerId: $customerId, customerName: $customerName, type: $type, amount: $amount, items: $items)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$PaymentSplitBillRequestDtoImpl &&
|
||||
(identical(other.orderId, orderId) || other.orderId == orderId) &&
|
||||
(identical(other.paymentMethodId, paymentMethodId) ||
|
||||
other.paymentMethodId == paymentMethodId) &&
|
||||
(identical(other.customerId, customerId) ||
|
||||
other.customerId == customerId) &&
|
||||
(identical(other.customerName, customerName) ||
|
||||
other.customerName == customerName) &&
|
||||
(identical(other.type, type) || other.type == type) &&
|
||||
(identical(other.amount, amount) || other.amount == amount) &&
|
||||
const DeepCollectionEquality().equals(other._items, _items));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(
|
||||
runtimeType,
|
||||
orderId,
|
||||
paymentMethodId,
|
||||
customerId,
|
||||
customerName,
|
||||
type,
|
||||
amount,
|
||||
const DeepCollectionEquality().hash(_items),
|
||||
);
|
||||
|
||||
/// Create a copy of PaymentSplitBillRequestDto
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$PaymentSplitBillRequestDtoImplCopyWith<_$PaymentSplitBillRequestDtoImpl>
|
||||
get copyWith =>
|
||||
__$$PaymentSplitBillRequestDtoImplCopyWithImpl<
|
||||
_$PaymentSplitBillRequestDtoImpl
|
||||
>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$$PaymentSplitBillRequestDtoImplToJson(this);
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _PaymentSplitBillRequestDto extends PaymentSplitBillRequestDto {
|
||||
const factory _PaymentSplitBillRequestDto({
|
||||
@JsonKey(name: "order_id") final String? orderId,
|
||||
@JsonKey(name: "payment_method_id") final String? paymentMethodId,
|
||||
@JsonKey(name: "customer_id") final String? customerId,
|
||||
@JsonKey(name: "customer_name") final String? customerName,
|
||||
@JsonKey(name: "type") final String? type,
|
||||
@JsonKey(name: "amount") final int? amount,
|
||||
@JsonKey(name: "items") final List<PaymentItemSplitBillRequestDto>? items,
|
||||
}) = _$PaymentSplitBillRequestDtoImpl;
|
||||
const _PaymentSplitBillRequestDto._() : super._();
|
||||
|
||||
factory _PaymentSplitBillRequestDto.fromJson(Map<String, dynamic> json) =
|
||||
_$PaymentSplitBillRequestDtoImpl.fromJson;
|
||||
|
||||
@override
|
||||
@JsonKey(name: "order_id")
|
||||
String? get orderId;
|
||||
@override
|
||||
@JsonKey(name: "payment_method_id")
|
||||
String? get paymentMethodId;
|
||||
@override
|
||||
@JsonKey(name: "customer_id")
|
||||
String? get customerId;
|
||||
@override
|
||||
@JsonKey(name: "customer_name")
|
||||
String? get customerName;
|
||||
@override
|
||||
@JsonKey(name: "type")
|
||||
String? get type; // e.g., "AMOUNT" or "ITEM"
|
||||
@override
|
||||
@JsonKey(name: "amount")
|
||||
int? get amount;
|
||||
@override
|
||||
@JsonKey(name: "items")
|
||||
List<PaymentItemSplitBillRequestDto>? get items;
|
||||
|
||||
/// Create a copy of PaymentSplitBillRequestDto
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$PaymentSplitBillRequestDtoImplCopyWith<_$PaymentSplitBillRequestDtoImpl>
|
||||
get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
PaymentItemSplitBillRequestDto _$PaymentItemSplitBillRequestDtoFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) {
|
||||
return _PaymentItemSplitBillRequestDto.fromJson(json);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$PaymentItemSplitBillRequestDto {
|
||||
@JsonKey(name: "order_item_id")
|
||||
String? get orderItemId => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: "quantity")
|
||||
int? get quantity => throw _privateConstructorUsedError;
|
||||
|
||||
/// Serializes this PaymentItemSplitBillRequestDto to a JSON map.
|
||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of PaymentItemSplitBillRequestDto
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$PaymentItemSplitBillRequestDtoCopyWith<PaymentItemSplitBillRequestDto>
|
||||
get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $PaymentItemSplitBillRequestDtoCopyWith<$Res> {
|
||||
factory $PaymentItemSplitBillRequestDtoCopyWith(
|
||||
PaymentItemSplitBillRequestDto value,
|
||||
$Res Function(PaymentItemSplitBillRequestDto) then,
|
||||
) =
|
||||
_$PaymentItemSplitBillRequestDtoCopyWithImpl<
|
||||
$Res,
|
||||
PaymentItemSplitBillRequestDto
|
||||
>;
|
||||
@useResult
|
||||
$Res call({
|
||||
@JsonKey(name: "order_item_id") String? orderItemId,
|
||||
@JsonKey(name: "quantity") int? quantity,
|
||||
});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$PaymentItemSplitBillRequestDtoCopyWithImpl<
|
||||
$Res,
|
||||
$Val extends PaymentItemSplitBillRequestDto
|
||||
>
|
||||
implements $PaymentItemSplitBillRequestDtoCopyWith<$Res> {
|
||||
_$PaymentItemSplitBillRequestDtoCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of PaymentItemSplitBillRequestDto
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({Object? orderItemId = freezed, Object? quantity = freezed}) {
|
||||
return _then(
|
||||
_value.copyWith(
|
||||
orderItemId: freezed == orderItemId
|
||||
? _value.orderItemId
|
||||
: orderItemId // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
quantity: freezed == quantity
|
||||
? _value.quantity
|
||||
: quantity // ignore: cast_nullable_to_non_nullable
|
||||
as int?,
|
||||
)
|
||||
as $Val,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$PaymentItemSplitBillRequestDtoImplCopyWith<$Res>
|
||||
implements $PaymentItemSplitBillRequestDtoCopyWith<$Res> {
|
||||
factory _$$PaymentItemSplitBillRequestDtoImplCopyWith(
|
||||
_$PaymentItemSplitBillRequestDtoImpl value,
|
||||
$Res Function(_$PaymentItemSplitBillRequestDtoImpl) then,
|
||||
) = __$$PaymentItemSplitBillRequestDtoImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({
|
||||
@JsonKey(name: "order_item_id") String? orderItemId,
|
||||
@JsonKey(name: "quantity") int? quantity,
|
||||
});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$PaymentItemSplitBillRequestDtoImplCopyWithImpl<$Res>
|
||||
extends
|
||||
_$PaymentItemSplitBillRequestDtoCopyWithImpl<
|
||||
$Res,
|
||||
_$PaymentItemSplitBillRequestDtoImpl
|
||||
>
|
||||
implements _$$PaymentItemSplitBillRequestDtoImplCopyWith<$Res> {
|
||||
__$$PaymentItemSplitBillRequestDtoImplCopyWithImpl(
|
||||
_$PaymentItemSplitBillRequestDtoImpl _value,
|
||||
$Res Function(_$PaymentItemSplitBillRequestDtoImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of PaymentItemSplitBillRequestDto
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({Object? orderItemId = freezed, Object? quantity = freezed}) {
|
||||
return _then(
|
||||
_$PaymentItemSplitBillRequestDtoImpl(
|
||||
orderItemId: freezed == orderItemId
|
||||
? _value.orderItemId
|
||||
: orderItemId // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
quantity: freezed == quantity
|
||||
? _value.quantity
|
||||
: quantity // ignore: cast_nullable_to_non_nullable
|
||||
as int?,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
class _$PaymentItemSplitBillRequestDtoImpl
|
||||
extends _PaymentItemSplitBillRequestDto {
|
||||
const _$PaymentItemSplitBillRequestDtoImpl({
|
||||
@JsonKey(name: "order_item_id") this.orderItemId,
|
||||
@JsonKey(name: "quantity") this.quantity,
|
||||
}) : super._();
|
||||
|
||||
factory _$PaymentItemSplitBillRequestDtoImpl.fromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => _$$PaymentItemSplitBillRequestDtoImplFromJson(json);
|
||||
|
||||
@override
|
||||
@JsonKey(name: "order_item_id")
|
||||
final String? orderItemId;
|
||||
@override
|
||||
@JsonKey(name: "quantity")
|
||||
final int? quantity;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'PaymentItemSplitBillRequestDto(orderItemId: $orderItemId, quantity: $quantity)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$PaymentItemSplitBillRequestDtoImpl &&
|
||||
(identical(other.orderItemId, orderItemId) ||
|
||||
other.orderItemId == orderItemId) &&
|
||||
(identical(other.quantity, quantity) ||
|
||||
other.quantity == quantity));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, orderItemId, quantity);
|
||||
|
||||
/// Create a copy of PaymentItemSplitBillRequestDto
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$PaymentItemSplitBillRequestDtoImplCopyWith<
|
||||
_$PaymentItemSplitBillRequestDtoImpl
|
||||
>
|
||||
get copyWith =>
|
||||
__$$PaymentItemSplitBillRequestDtoImplCopyWithImpl<
|
||||
_$PaymentItemSplitBillRequestDtoImpl
|
||||
>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$$PaymentItemSplitBillRequestDtoImplToJson(this);
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _PaymentItemSplitBillRequestDto
|
||||
extends PaymentItemSplitBillRequestDto {
|
||||
const factory _PaymentItemSplitBillRequestDto({
|
||||
@JsonKey(name: "order_item_id") final String? orderItemId,
|
||||
@JsonKey(name: "quantity") final int? quantity,
|
||||
}) = _$PaymentItemSplitBillRequestDtoImpl;
|
||||
const _PaymentItemSplitBillRequestDto._() : super._();
|
||||
|
||||
factory _PaymentItemSplitBillRequestDto.fromJson(Map<String, dynamic> json) =
|
||||
_$PaymentItemSplitBillRequestDtoImpl.fromJson;
|
||||
|
||||
@override
|
||||
@JsonKey(name: "order_item_id")
|
||||
String? get orderItemId;
|
||||
@override
|
||||
@JsonKey(name: "quantity")
|
||||
int? get quantity;
|
||||
|
||||
/// Create a copy of PaymentItemSplitBillRequestDto
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$PaymentItemSplitBillRequestDtoImplCopyWith<
|
||||
_$PaymentItemSplitBillRequestDtoImpl
|
||||
>
|
||||
get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
PaymentDto _$PaymentDtoFromJson(Map<String, dynamic> json) {
|
||||
return _PaymentOrderDto.fromJson(json);
|
||||
}
|
||||
|
||||
@ -220,6 +220,49 @@ Map<String, dynamic> _$$PaymentItemRequestDtoImplToJson(
|
||||
'amount': instance.amount,
|
||||
};
|
||||
|
||||
_$PaymentSplitBillRequestDtoImpl _$$PaymentSplitBillRequestDtoImplFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => _$PaymentSplitBillRequestDtoImpl(
|
||||
orderId: json['order_id'] as String?,
|
||||
paymentMethodId: json['payment_method_id'] as String?,
|
||||
customerId: json['customer_id'] as String?,
|
||||
customerName: json['customer_name'] as String?,
|
||||
type: json['type'] as String?,
|
||||
amount: (json['amount'] as num?)?.toInt(),
|
||||
items: (json['items'] as List<dynamic>?)
|
||||
?.map(
|
||||
(e) =>
|
||||
PaymentItemSplitBillRequestDto.fromJson(e as Map<String, dynamic>),
|
||||
)
|
||||
.toList(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$PaymentSplitBillRequestDtoImplToJson(
|
||||
_$PaymentSplitBillRequestDtoImpl instance,
|
||||
) => <String, dynamic>{
|
||||
'order_id': instance.orderId,
|
||||
'payment_method_id': instance.paymentMethodId,
|
||||
'customer_id': instance.customerId,
|
||||
'customer_name': instance.customerName,
|
||||
'type': instance.type,
|
||||
'amount': instance.amount,
|
||||
'items': instance.items,
|
||||
};
|
||||
|
||||
_$PaymentItemSplitBillRequestDtoImpl
|
||||
_$$PaymentItemSplitBillRequestDtoImplFromJson(Map<String, dynamic> json) =>
|
||||
_$PaymentItemSplitBillRequestDtoImpl(
|
||||
orderItemId: json['order_item_id'] as String?,
|
||||
quantity: (json['quantity'] as num?)?.toInt(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$PaymentItemSplitBillRequestDtoImplToJson(
|
||||
_$PaymentItemSplitBillRequestDtoImpl instance,
|
||||
) => <String, dynamic>{
|
||||
'order_item_id': instance.orderItemId,
|
||||
'quantity': instance.quantity,
|
||||
};
|
||||
|
||||
_$PaymentOrderDtoImpl _$$PaymentOrderDtoImplFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => _$PaymentOrderDtoImpl(
|
||||
|
||||
@ -177,4 +177,25 @@ class OrderRepository implements IOrderRepository {
|
||||
return left(const OrderFailure.unexpectedError());
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Either<OrderFailure, Payment>> createSplitBill(
|
||||
PaymentSplitBillRequest request,
|
||||
) async {
|
||||
try {
|
||||
final result = await _dataProvider.createSplitBill(
|
||||
PaymentSplitBillRequestDto.fromDomain(request),
|
||||
);
|
||||
|
||||
if (result.hasError) {
|
||||
return left(result.error!);
|
||||
}
|
||||
|
||||
final payment = result.data!.toDomain();
|
||||
return right(payment);
|
||||
} catch (e) {
|
||||
log('createSplitBillError', name: _logName, error: e);
|
||||
return left(const OrderFailure.unexpectedError());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,6 +30,8 @@ import 'package:apskel_pos_flutter_v2/application/payment_method/payment_method_
|
||||
as _i952;
|
||||
import 'package:apskel_pos_flutter_v2/application/product/product_loader/product_loader_bloc.dart'
|
||||
as _i13;
|
||||
import 'package:apskel_pos_flutter_v2/application/split_bill/split_bill_form/split_bill_form_bloc.dart'
|
||||
as _i334;
|
||||
import 'package:apskel_pos_flutter_v2/application/sync/sync_bloc.dart' as _i741;
|
||||
import 'package:apskel_pos_flutter_v2/application/table/table_form/table_form_bloc.dart'
|
||||
as _i248;
|
||||
@ -126,6 +128,7 @@ extension GetItInjectableX on _i174.GetIt {
|
||||
preResolve: true,
|
||||
);
|
||||
gh.factory<_i13.CheckoutFormBloc>(() => _i13.CheckoutFormBloc());
|
||||
gh.factory<_i334.SplitBillFormBloc>(() => _i334.SplitBillFormBloc());
|
||||
gh.singleton<_i487.DatabaseHelper>(() => databaseDi.databaseHelper);
|
||||
gh.lazySingleton<_i361.Dio>(() => dioDi.dio);
|
||||
gh.lazySingleton<_i800.AppRouter>(() => autoRouteDi.appRouter);
|
||||
|
||||
@ -96,7 +96,9 @@ class OrderRightPanel extends StatelessWidget {
|
||||
SpaceWidth(8),
|
||||
AppElevatedButton.outlined(
|
||||
onPressed: () {
|
||||
// context.push(SplitBillPage(order: orderDetail!));
|
||||
context.router.push(
|
||||
SplitBillRoute(order: state.selectedOrder!),
|
||||
);
|
||||
},
|
||||
label: 'Split Bill',
|
||||
icon: Icon(Icons.calculate_outlined),
|
||||
|
||||
@ -5,6 +5,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import '../../../application/payment/payment_form/payment_form_bloc.dart';
|
||||
import '../../../application/payment_method/payment_method_loader/payment_method_loader_bloc.dart';
|
||||
import '../../../common/theme/theme.dart';
|
||||
import '../../../common/types/split_type.dart';
|
||||
import '../../../domain/order/order.dart';
|
||||
import '../../../injection.dart';
|
||||
import '../../components/spaces/space.dart';
|
||||
@ -16,25 +17,61 @@ import 'widgets/payment_right_panel.dart';
|
||||
@RoutePage()
|
||||
class PaymentPage extends StatelessWidget implements AutoRouteWrapper {
|
||||
final Order order;
|
||||
const PaymentPage({super.key, required this.order});
|
||||
final bool isSplit;
|
||||
final SplitType splitType;
|
||||
final String? customerId;
|
||||
final String? customerName;
|
||||
const PaymentPage({
|
||||
super.key,
|
||||
required this.order,
|
||||
this.isSplit = false,
|
||||
this.splitType = SplitType.unknown,
|
||||
this.customerId,
|
||||
this.customerName,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocListener<PaymentFormBloc, PaymentFormState>(
|
||||
listenWhen: (p, c) => p.failureOrPayment != c.failureOrPayment,
|
||||
listener: (context, state) {
|
||||
state.failureOrPayment.fold(
|
||||
() {},
|
||||
(either) => either.fold(
|
||||
(f) => AppFlushbar.showOrderFailureToast(context, f),
|
||||
(data) {
|
||||
if (context.mounted) {
|
||||
context.router.replace(PaymentSuccessRoute(orderId: order.id));
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
return MultiBlocListener(
|
||||
listeners: [
|
||||
BlocListener<PaymentFormBloc, PaymentFormState>(
|
||||
listenWhen: (p, c) => p.failureOrPayment != c.failureOrPayment,
|
||||
listener: (context, state) {
|
||||
state.failureOrPayment.fold(
|
||||
() {},
|
||||
(either) => either.fold(
|
||||
(f) => AppFlushbar.showOrderFailureToast(context, f),
|
||||
(data) {
|
||||
if (context.mounted) {
|
||||
context.router.replace(
|
||||
PaymentSuccessRoute(orderId: order.id),
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
BlocListener<PaymentFormBloc, PaymentFormState>(
|
||||
listenWhen: (p, c) =>
|
||||
p.failureOrPaymentSplitBill != c.failureOrPaymentSplitBill,
|
||||
listener: (context, state) {
|
||||
state.failureOrPaymentSplitBill.fold(
|
||||
() {},
|
||||
(either) => either.fold(
|
||||
(f) => AppFlushbar.showOrderFailureToast(context, f),
|
||||
(data) {
|
||||
if (context.mounted) {
|
||||
context.router.replace(
|
||||
PaymentSuccessRoute(orderId: order.id),
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
child: Scaffold(
|
||||
backgroundColor: AppColor.background,
|
||||
appBar: AppBar(
|
||||
@ -48,6 +85,24 @@ class PaymentPage extends StatelessWidget implements AutoRouteWrapper {
|
||||
onPressed: () => context.router.maybePop(),
|
||||
icon: Icon(Icons.arrow_back, color: AppColor.primary),
|
||||
),
|
||||
actions: [
|
||||
if (isSplit)
|
||||
Container(
|
||||
padding: EdgeInsets.all(4),
|
||||
margin: EdgeInsets.only(right: 8),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: AppColor.primary),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Text(
|
||||
"Split Bill: ${splitType.toStringType()}",
|
||||
style: AppStyle.sm.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
color: AppColor.primary,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
body: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
@ -68,7 +123,13 @@ class PaymentPage extends StatelessWidget implements AutoRouteWrapper {
|
||||
const SizedBox(width: 24),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: PaymentRightPanel(state: state),
|
||||
child: PaymentRightPanel(
|
||||
state: state,
|
||||
isSplit: isSplit,
|
||||
splitType: splitType,
|
||||
customerId: customerId,
|
||||
customerName: customerName,
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
@ -77,7 +138,13 @@ class PaymentPage extends StatelessWidget implements AutoRouteWrapper {
|
||||
children: [
|
||||
PaymentLeftPanel(state: state),
|
||||
const SpaceHeight(24),
|
||||
PaymentRightPanel(state: state),
|
||||
PaymentRightPanel(
|
||||
state: state,
|
||||
isSplit: isSplit,
|
||||
splitType: splitType,
|
||||
customerId: customerId,
|
||||
customerName: customerName,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@ -5,6 +5,7 @@ import '../../../../application/payment/payment_form/payment_form_bloc.dart';
|
||||
import '../../../../application/payment_method/payment_method_loader/payment_method_loader_bloc.dart';
|
||||
import '../../../../common/extension/extension.dart';
|
||||
import '../../../../common/theme/theme.dart';
|
||||
import '../../../../common/types/split_type.dart';
|
||||
import '../../../components/button/button.dart';
|
||||
import '../../../components/card/payment_card.dart';
|
||||
import '../../../components/error/payment_method_error_state_widget.dart';
|
||||
@ -15,7 +16,18 @@ import '../../../components/toast/flushbar.dart';
|
||||
|
||||
class PaymentRightPanel extends StatefulWidget {
|
||||
final PaymentFormState state;
|
||||
const PaymentRightPanel({super.key, required this.state});
|
||||
final bool isSplit;
|
||||
final SplitType splitType;
|
||||
final String? customerId;
|
||||
final String? customerName;
|
||||
const PaymentRightPanel({
|
||||
super.key,
|
||||
required this.state,
|
||||
required this.isSplit,
|
||||
this.customerId,
|
||||
required this.splitType,
|
||||
this.customerName,
|
||||
});
|
||||
|
||||
@override
|
||||
State<PaymentRightPanel> createState() => _PaymentRightPanelState();
|
||||
@ -211,9 +223,18 @@ class _PaymentRightPanelState extends State<PaymentRightPanel> {
|
||||
}
|
||||
|
||||
if (!widget.state.isSubmitting) {
|
||||
context.read<PaymentFormBloc>().add(
|
||||
PaymentFormEvent.submitted(),
|
||||
);
|
||||
if (widget.isSplit) {
|
||||
context.read<PaymentFormBloc>().add(
|
||||
PaymentFormEvent.submittedSplitBill(
|
||||
customerId: widget.customerId,
|
||||
splitType: widget.splitType,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
context.read<PaymentFormBloc>().add(
|
||||
PaymentFormEvent.submitted(),
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
label: 'Bayar',
|
||||
|
||||
42
lib/presentation/pages/split_bill/split_bill_page.dart
Normal file
42
lib/presentation/pages/split_bill/split_bill_page.dart
Normal file
@ -0,0 +1,42 @@
|
||||
import 'package:auto_route/auto_route.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
import '../../../application/split_bill/split_bill_form/split_bill_form_bloc.dart';
|
||||
import '../../../common/theme/theme.dart';
|
||||
import '../../../domain/order/order.dart';
|
||||
import '../../../injection.dart';
|
||||
import 'widgets/split_bill_left_panel.dart';
|
||||
import 'widgets/split_bill_right_panel.dart';
|
||||
|
||||
@RoutePage()
|
||||
class SplitBillPage extends StatelessWidget implements AutoRouteWrapper {
|
||||
final Order order;
|
||||
const SplitBillPage({super.key, required this.order});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: AppColor.background,
|
||||
body: SafeArea(
|
||||
child: BlocBuilder<SplitBillFormBloc, SplitBillFormState>(
|
||||
builder: (context, state) {
|
||||
return Row(
|
||||
children: [
|
||||
Expanded(flex: 2, child: SplitBillLeftPanel(state: state)),
|
||||
Expanded(flex: 4, child: SplitBillRightPanel(state: state)),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget wrappedRoute(BuildContext context) => BlocProvider(
|
||||
create: (_) =>
|
||||
getIt<SplitBillFormBloc>()..add(SplitBillFormEvent.setOrder(order)),
|
||||
child: this,
|
||||
);
|
||||
}
|
||||
@ -0,0 +1,229 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
import '../../../../application/split_bill/split_bill_form/split_bill_form_bloc.dart';
|
||||
import '../../../../common/extension/extension.dart';
|
||||
import '../../../../common/theme/theme.dart';
|
||||
import '../../../../domain/order/order.dart';
|
||||
import '../../../components/border/dashed_border.dart';
|
||||
import '../../../components/page/page_title.dart';
|
||||
import '../../../components/spaces/space.dart';
|
||||
|
||||
class SplitBillLeftPanel extends StatelessWidget {
|
||||
final SplitBillFormState state;
|
||||
const SplitBillLeftPanel({super.key, required this.state});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(color: AppColor.white),
|
||||
child: Column(
|
||||
children: [
|
||||
PageTitle(
|
||||
title: 'Ringkasan Pesanan',
|
||||
subtitle: state.order.orderNumber,
|
||||
),
|
||||
SpaceHeight(16),
|
||||
Expanded(
|
||||
child: ListView.builder(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16),
|
||||
itemCount: state.pendingItems.length,
|
||||
itemBuilder: (context, index) {
|
||||
return _buildOrderItem(state.pendingItems[index]);
|
||||
},
|
||||
),
|
||||
),
|
||||
DashedDivider(color: AppColor.border),
|
||||
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
children: [
|
||||
if (state.order.subtotal != state.order.totalAmount) ...[
|
||||
_buildSummaryItem(
|
||||
title: 'Subtotal',
|
||||
value: state.order.subtotal.currencyFormatRpV2,
|
||||
),
|
||||
if ((state.order.taxAmount) > 0)
|
||||
_buildSummaryItem(
|
||||
title: 'Pajax',
|
||||
value: state.order.taxAmount.currencyFormatRpV2,
|
||||
),
|
||||
if ((state.order.discountAmount) > 0)
|
||||
_buildSummaryItem(
|
||||
title: 'Diskon',
|
||||
value: state.order.discountAmount.currencyFormatRpV2,
|
||||
),
|
||||
SpaceHeight(8),
|
||||
],
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'Total terbayar',
|
||||
style: AppStyle.md.copyWith(
|
||||
color: AppColor.textPrimary,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
state.order.totalPaid.currencyFormatRpV2,
|
||||
style: AppStyle.md.copyWith(
|
||||
color: AppColor.textPrimary,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SpaceHeight(4),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'Sisa Tagihan',
|
||||
style: AppStyle.md.copyWith(
|
||||
color: AppColor.error,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
state.order.remainingAmount.currencyFormatRpV2,
|
||||
style: AppStyle.md.copyWith(
|
||||
color: AppColor.error,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SpaceHeight(6),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'Total Pembayaran',
|
||||
style: AppStyle.lg.copyWith(
|
||||
color: AppColor.primary,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
state.order.totalAmount.currencyFormatRpV2,
|
||||
style: AppStyle.lg.copyWith(
|
||||
color: AppColor.primary,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Row _buildSummaryItem({required String title, required String value}) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(title, style: AppStyle.md.copyWith(color: AppColor.textSecondary)),
|
||||
Text(value, style: AppStyle.md.copyWith(color: AppColor.textSecondary)),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildOrderItem(OrderItem item) {
|
||||
return Container(
|
||||
padding: EdgeInsets.symmetric(vertical: 12),
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
item.productName,
|
||||
style: AppStyle.lg.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
color: AppColor.textPrimary,
|
||||
),
|
||||
),
|
||||
if (item.productVariantName.isNotEmpty)
|
||||
Text(
|
||||
item.productVariantName,
|
||||
style: AppStyle.md.copyWith(
|
||||
color: AppColor.textSecondary,
|
||||
fontStyle: FontStyle.italic,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'Qty: ${item.quantity} x Rp ${item.unitPrice.currencyFormatRpV2} ',
|
||||
style: AppStyle.md.copyWith(
|
||||
color: AppColor.textSecondary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Text(
|
||||
item.totalPrice.currencyFormatRpV2,
|
||||
style: AppStyle.lg.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
color: AppColor.textPrimary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
if ((item.paidQuantity) > 1) ...[
|
||||
SpaceHeight(6),
|
||||
Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 10,
|
||||
vertical: 4,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.primary.withOpacity(0.2),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(color: AppColor.primary),
|
||||
),
|
||||
child: RichText(
|
||||
text: TextSpan(
|
||||
children: [
|
||||
TextSpan(
|
||||
text: '${item.paidQuantity} ',
|
||||
style: AppStyle.sm.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
color: AppColor.primary,
|
||||
),
|
||||
),
|
||||
TextSpan(
|
||||
text: 'dari ',
|
||||
style: AppStyle.sm.copyWith(color: AppColor.primary),
|
||||
),
|
||||
TextSpan(
|
||||
text: '${item.quantity} ',
|
||||
style: AppStyle.sm.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
color: AppColor.primary,
|
||||
),
|
||||
),
|
||||
TextSpan(
|
||||
text: 'kuantiti telah dibayar.',
|
||||
style: AppStyle.sm.copyWith(color: AppColor.primary),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,559 @@
|
||||
import 'package:auto_route/auto_route.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
import '../../../../application/split_bill/split_bill_form/split_bill_form_bloc.dart';
|
||||
import '../../../../common/extension/extension.dart';
|
||||
import '../../../../common/theme/theme.dart';
|
||||
import '../../../../common/types/split_type.dart';
|
||||
import '../../../../domain/order/order.dart';
|
||||
import '../../../components/button/button.dart';
|
||||
import '../../../components/field/field.dart';
|
||||
import '../../../components/spaces/space.dart';
|
||||
import '../../../components/toast/flushbar.dart';
|
||||
import '../../../router/app_router.gr.dart';
|
||||
|
||||
class SplitBillRightPanel extends StatefulWidget {
|
||||
final SplitBillFormState state;
|
||||
const SplitBillRightPanel({super.key, required this.state});
|
||||
|
||||
@override
|
||||
State<SplitBillRightPanel> createState() => _SplitBillRightPanelState();
|
||||
}
|
||||
|
||||
class _SplitBillRightPanelState extends State<SplitBillRightPanel> {
|
||||
final TextEditingController _customerController = TextEditingController();
|
||||
final TextEditingController _amountController = TextEditingController();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_customerController.addListener(() {
|
||||
context.read<SplitBillFormBloc>().add(
|
||||
SplitBillFormEvent.customerNameChanged(_customerController.text),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
_customerController.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: SingleChildScrollView(
|
||||
padding: EdgeInsets.all(16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'Split Bill',
|
||||
style: AppStyle.h5.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: AppColor.textPrimary,
|
||||
),
|
||||
),
|
||||
SpaceHeight(16),
|
||||
_buildCustomer(context),
|
||||
SpaceHeight(16),
|
||||
_buildRowButtonSplit(),
|
||||
SpaceHeight(16),
|
||||
Container(
|
||||
child: widget.state.splitType.isItem
|
||||
? _buildPerProductSplit()
|
||||
: _buildPerAmountSplit(),
|
||||
),
|
||||
SpaceHeight(16),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
_buildBottom(),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildBottom() {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(color: AppColor.white),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: AppElevatedButton.outlined(
|
||||
onPressed: () => context.router.maybePop(),
|
||||
label: 'Batal',
|
||||
),
|
||||
),
|
||||
SpaceWidth(16),
|
||||
Expanded(
|
||||
child: AppElevatedButton.filled(
|
||||
onPressed: () => _confirmSplit(),
|
||||
label: 'Konfirmasi Split',
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildPerAmountSplit() {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'Masukkan Jumlah yang Akan Dibayar',
|
||||
style: AppStyle.xl.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: AppColor.textPrimary,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 16),
|
||||
Column(
|
||||
children: [
|
||||
Container(
|
||||
padding: EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.white,
|
||||
border: Border.all(color: AppColor.border),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'Split Bill',
|
||||
style: AppStyle.lg.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: AppColor.primary,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 16),
|
||||
Text(
|
||||
'Jumlah yang akan dibayar:',
|
||||
style: AppStyle.md.copyWith(color: AppColor.textSecondary),
|
||||
),
|
||||
SizedBox(height: 8),
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: AppColor.border),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: TextField(
|
||||
controller: _amountController,
|
||||
keyboardType: TextInputType.number,
|
||||
style: AppStyle.lg.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
color: AppColor.textPrimary,
|
||||
),
|
||||
onChanged: (value) {
|
||||
context.read<SplitBillFormBloc>().add(
|
||||
SplitBillFormEvent.amountChanged(
|
||||
int.tryParse(value) ?? 0,
|
||||
),
|
||||
);
|
||||
// setState(() {
|
||||
// splitAmount = int.tryParse(value) ?? 0;
|
||||
// });
|
||||
},
|
||||
decoration: InputDecoration(
|
||||
hintText: '0',
|
||||
prefixText: 'Rp ',
|
||||
prefixStyle: AppStyle.lg.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
color: AppColor.textPrimary,
|
||||
),
|
||||
border: InputBorder.none,
|
||||
contentPadding: EdgeInsets.all(16),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 16),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'Total yang dibayar:',
|
||||
style: AppStyle.lg.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
color: AppColor.textPrimary,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
widget.state.totalAmount.currencyFormatRpV2,
|
||||
style: AppStyle.lg.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
color: AppColor.primary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 8),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'Sisa bill:',
|
||||
style: AppStyle.md.copyWith(
|
||||
color: AppColor.textSecondary,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
(widget.state.order.remainingAmount -
|
||||
widget.state.totalAmount)
|
||||
.currencyFormatRpV2,
|
||||
style: AppStyle.md.copyWith(
|
||||
color: AppColor.textSecondary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildPerProductSplit() {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'Pilih Produk untuk Split',
|
||||
style: AppStyle.xl.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: AppColor.textPrimary,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 16),
|
||||
Container(
|
||||
padding: EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.white,
|
||||
border: Border.all(color: AppColor.border),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'Split Bill',
|
||||
style: AppStyle.lg.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: AppColor.primary,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 16),
|
||||
ListView.builder(
|
||||
itemCount: widget.state.pendingItems.length,
|
||||
shrinkWrap: true,
|
||||
physics: NeverScrollableScrollPhysics(),
|
||||
itemBuilder: (context, index) {
|
||||
return _buildProductSplitItem(
|
||||
widget.state.pendingItems[index],
|
||||
);
|
||||
},
|
||||
),
|
||||
Container(
|
||||
width: double.infinity,
|
||||
height: 1,
|
||||
color: AppColor.border,
|
||||
margin: EdgeInsets.symmetric(vertical: 12),
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'Total Split:',
|
||||
style: AppStyle.lg.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
color: AppColor.textPrimary,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
widget.state.totalAmount.currencyFormatRpV2,
|
||||
style: AppStyle.lg.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
color: AppColor.primary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildProductSplitItem(OrderItem item) {
|
||||
int selectedQty = widget.state.selectedProducts[item.id] ?? 0;
|
||||
int maxQty = (item.quantity) - (item.paidQuantity);
|
||||
|
||||
return Container(
|
||||
margin: EdgeInsets.only(bottom: 12),
|
||||
padding: EdgeInsets.all(12),
|
||||
decoration: BoxDecoration(
|
||||
color: selectedQty > 0
|
||||
? AppColor.primary.withOpacity(0.1)
|
||||
: Colors.transparent,
|
||||
border: Border.all(
|
||||
color: selectedQty > 0 ? AppColor.primary : AppColor.border,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
item.productName,
|
||||
style: AppStyle.md.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
color: AppColor.textPrimary,
|
||||
),
|
||||
),
|
||||
if (item.productVariantName.isNotEmpty)
|
||||
Text(
|
||||
item.productVariantName,
|
||||
style: AppStyle.sm.copyWith(
|
||||
color: AppColor.textSecondary,
|
||||
fontStyle: FontStyle.italic,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'${item.unitPrice.currencyFormatRpV2} per item',
|
||||
style: AppStyle.sm.copyWith(color: AppColor.textSecondary),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
if (selectedQty > 0) {
|
||||
setState(() {
|
||||
context.read<SplitBillFormBloc>().add(
|
||||
SplitBillFormEvent.itemQuantityChanged(
|
||||
itemId: item.id,
|
||||
quantity: selectedQty - 1,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
width: 32,
|
||||
height: 32,
|
||||
decoration: BoxDecoration(
|
||||
color: selectedQty > 0 ? AppColor.primary : AppColor.border,
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: Icon(
|
||||
Icons.remove,
|
||||
size: 16,
|
||||
color: selectedQty > 0
|
||||
? Colors.white
|
||||
: AppColor.textSecondary,
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
width: 40,
|
||||
height: 32,
|
||||
margin: EdgeInsets.symmetric(horizontal: 8),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: AppColor.border),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: Center(
|
||||
child: Text(
|
||||
'$selectedQty',
|
||||
style: AppStyle.md.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: AppColor.textPrimary,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
context.read<SplitBillFormBloc>().add(
|
||||
SplitBillFormEvent.itemQuantityChanged(
|
||||
itemId: item.id,
|
||||
quantity: selectedQty + 1,
|
||||
),
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
width: 32,
|
||||
height: 32,
|
||||
decoration: BoxDecoration(
|
||||
color: selectedQty < maxQty
|
||||
? AppColor.primary
|
||||
: AppColor.border,
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: Icon(
|
||||
Icons.add,
|
||||
size: 16,
|
||||
color: selectedQty < maxQty
|
||||
? Colors.white
|
||||
: AppColor.textSecondary,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildRowButtonSplit() {
|
||||
switch (widget.state.order.splitType) {
|
||||
case 'AMOUNT':
|
||||
return _buildSplitTypeButton('Per Jumlah', SplitType.amount);
|
||||
case 'ITEM':
|
||||
return _buildSplitTypeButton('Per Produk', SplitType.item);
|
||||
default:
|
||||
return Row(
|
||||
children: [
|
||||
_buildSplitTypeButton('Per Produk', SplitType.item),
|
||||
SizedBox(width: 16),
|
||||
_buildSplitTypeButton('Per Jumlah', SplitType.amount),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Widget _buildSplitTypeButton(String title, SplitType type) {
|
||||
bool isSelected = widget.state.splitType == type;
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
_amountController.clear();
|
||||
context.read<SplitBillFormBloc>().add(
|
||||
SplitBillFormEvent.splitTypeChanged(type),
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 24, vertical: 12),
|
||||
decoration: BoxDecoration(
|
||||
color: isSelected ? AppColor.primary : Colors.transparent,
|
||||
border: Border.all(
|
||||
color: isSelected ? AppColor.primary : AppColor.border,
|
||||
width: 2,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Text(
|
||||
title,
|
||||
style: AppStyle.lg.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
color: isSelected ? AppColor.white : AppColor.textPrimary,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildCustomer(BuildContext context) {
|
||||
return Container(
|
||||
padding: EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.white,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: CustomerAutocomplete(
|
||||
controller: _customerController,
|
||||
selectedCustomer: widget.state.customer,
|
||||
onSelected: (customer) {
|
||||
context.read<SplitBillFormBloc>().add(
|
||||
SplitBillFormEvent.customerChanged(customer!),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _confirmSplit() {
|
||||
if (widget.state.customerName == '' || widget.state.customer == null) {
|
||||
AppFlushbar.showError(context, 'Nama Pelanggan harus diisi');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (widget.state.splitType.isItem) {
|
||||
int splitTotal = widget.state.totalAmount;
|
||||
if (splitTotal > 0) {
|
||||
List<OrderItem> splitItems = [];
|
||||
widget.state.selectedProducts.forEach((itemId, quantity) {
|
||||
OrderItem? originalItem = widget.state.pendingItems.firstWhere(
|
||||
(item) => item.id == itemId,
|
||||
orElse: () => OrderItem.empty(),
|
||||
);
|
||||
// ignore: unnecessary_null_comparison
|
||||
if (originalItem != null && originalItem.id != null) {
|
||||
splitItems.add(
|
||||
originalItem.copyWith(
|
||||
quantity: quantity,
|
||||
totalPrice: (originalItem.unitPrice) * quantity,
|
||||
),
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
context.router.push(
|
||||
PaymentRoute(
|
||||
isSplit: true,
|
||||
splitType: widget.state.splitType,
|
||||
customerId: widget.state.customer?.id,
|
||||
order: widget.state.order.copyWith(
|
||||
orderItems: splitItems,
|
||||
subtotal: splitTotal,
|
||||
totalAmount: splitTotal,
|
||||
),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
AppFlushbar.showError(context, "Pilih minimal satu produk untuk split");
|
||||
}
|
||||
} else {
|
||||
int totalAmount =
|
||||
(widget.state.order.totalAmount) - (widget.state.order.totalPaid);
|
||||
|
||||
if (widget.state.totalAmount > 0 &&
|
||||
widget.state.totalAmount <= totalAmount) {
|
||||
context.router.push(
|
||||
PaymentRoute(
|
||||
isSplit: true,
|
||||
splitType: widget.state.splitType,
|
||||
customerId: widget.state.customer?.id,
|
||||
order: widget.state.order.copyWith(
|
||||
subtotal: widget.state.totalAmount,
|
||||
totalAmount: widget.state.totalAmount,
|
||||
),
|
||||
),
|
||||
);
|
||||
} else if (widget.state.totalAmount > totalAmount) {
|
||||
AppFlushbar.showError(
|
||||
context,
|
||||
"Jumlah split tidak boleh melebihi total bill",
|
||||
);
|
||||
} else {
|
||||
AppFlushbar.showError(context, "Total bayar harus lebih dari 0");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -41,5 +41,8 @@ class AppRouter extends RootStackRouter {
|
||||
// Void
|
||||
AutoRoute(page: VoidRoute.page),
|
||||
AutoRoute(page: VoidSuccessRoute.page),
|
||||
|
||||
// Split Bill
|
||||
AutoRoute(page: SplitBillRoute.page),
|
||||
];
|
||||
}
|
||||
|
||||
@ -9,7 +9,8 @@
|
||||
// coverage:ignore-file
|
||||
|
||||
// ignore_for_file: no_leading_underscores_for_library_prefixes
|
||||
import 'package:apskel_pos_flutter_v2/domain/order/order.dart' as _i20;
|
||||
import 'package:apskel_pos_flutter_v2/common/types/split_type.dart' as _i22;
|
||||
import 'package:apskel_pos_flutter_v2/domain/order/order.dart' as _i21;
|
||||
import 'package:apskel_pos_flutter_v2/presentation/pages/auth/login/login_page.dart'
|
||||
as _i4;
|
||||
import 'package:apskel_pos_flutter_v2/presentation/pages/checkout/checkout_page.dart'
|
||||
@ -25,101 +26,103 @@ import 'package:apskel_pos_flutter_v2/presentation/pages/main/pages/report/repor
|
||||
import 'package:apskel_pos_flutter_v2/presentation/pages/main/pages/setting/setting_page.dart'
|
||||
as _i10;
|
||||
import 'package:apskel_pos_flutter_v2/presentation/pages/main/pages/table/table_page.dart'
|
||||
as _i15;
|
||||
as _i16;
|
||||
import 'package:apskel_pos_flutter_v2/presentation/pages/order/order_page.dart'
|
||||
as _i6;
|
||||
import 'package:apskel_pos_flutter_v2/presentation/pages/order/pages/success_add_item_order/success_add_item_order_page.dart'
|
||||
as _i12;
|
||||
import 'package:apskel_pos_flutter_v2/presentation/pages/order/pages/success_order/success_order_page.dart'
|
||||
as _i13;
|
||||
import 'package:apskel_pos_flutter_v2/presentation/pages/order/pages/success_order/success_order_page.dart'
|
||||
as _i14;
|
||||
import 'package:apskel_pos_flutter_v2/presentation/pages/payment/pages/payment_success/payment_success_page.dart'
|
||||
as _i8;
|
||||
import 'package:apskel_pos_flutter_v2/presentation/pages/payment/payment_page.dart'
|
||||
as _i7;
|
||||
import 'package:apskel_pos_flutter_v2/presentation/pages/splash/splash_page.dart'
|
||||
as _i11;
|
||||
import 'package:apskel_pos_flutter_v2/presentation/pages/split_bill/split_bill_page.dart'
|
||||
as _i12;
|
||||
import 'package:apskel_pos_flutter_v2/presentation/pages/sync/sync_page.dart'
|
||||
as _i14;
|
||||
as _i15;
|
||||
import 'package:apskel_pos_flutter_v2/presentation/pages/void/pages/void_success/void_success_page.dart'
|
||||
as _i17;
|
||||
as _i18;
|
||||
import 'package:apskel_pos_flutter_v2/presentation/pages/void/void_page.dart'
|
||||
as _i16;
|
||||
import 'package:auto_route/auto_route.dart' as _i18;
|
||||
import 'package:flutter/material.dart' as _i19;
|
||||
as _i17;
|
||||
import 'package:auto_route/auto_route.dart' as _i19;
|
||||
import 'package:flutter/material.dart' as _i20;
|
||||
|
||||
/// generated route for
|
||||
/// [_i1.CheckoutPage]
|
||||
class CheckoutRoute extends _i18.PageRouteInfo<void> {
|
||||
const CheckoutRoute({List<_i18.PageRouteInfo>? children})
|
||||
class CheckoutRoute extends _i19.PageRouteInfo<void> {
|
||||
const CheckoutRoute({List<_i19.PageRouteInfo>? children})
|
||||
: super(CheckoutRoute.name, initialChildren: children);
|
||||
|
||||
static const String name = 'CheckoutRoute';
|
||||
|
||||
static _i18.PageInfo page = _i18.PageInfo(
|
||||
static _i19.PageInfo page = _i19.PageInfo(
|
||||
name,
|
||||
builder: (data) {
|
||||
return _i18.WrappedRoute(child: const _i1.CheckoutPage());
|
||||
return _i19.WrappedRoute(child: const _i1.CheckoutPage());
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/// generated route for
|
||||
/// [_i2.CustomerPage]
|
||||
class CustomerRoute extends _i18.PageRouteInfo<void> {
|
||||
const CustomerRoute({List<_i18.PageRouteInfo>? children})
|
||||
class CustomerRoute extends _i19.PageRouteInfo<void> {
|
||||
const CustomerRoute({List<_i19.PageRouteInfo>? children})
|
||||
: super(CustomerRoute.name, initialChildren: children);
|
||||
|
||||
static const String name = 'CustomerRoute';
|
||||
|
||||
static _i18.PageInfo page = _i18.PageInfo(
|
||||
static _i19.PageInfo page = _i19.PageInfo(
|
||||
name,
|
||||
builder: (data) {
|
||||
return _i18.WrappedRoute(child: const _i2.CustomerPage());
|
||||
return _i19.WrappedRoute(child: const _i2.CustomerPage());
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/// generated route for
|
||||
/// [_i3.HomePage]
|
||||
class HomeRoute extends _i18.PageRouteInfo<void> {
|
||||
const HomeRoute({List<_i18.PageRouteInfo>? children})
|
||||
class HomeRoute extends _i19.PageRouteInfo<void> {
|
||||
const HomeRoute({List<_i19.PageRouteInfo>? children})
|
||||
: super(HomeRoute.name, initialChildren: children);
|
||||
|
||||
static const String name = 'HomeRoute';
|
||||
|
||||
static _i18.PageInfo page = _i18.PageInfo(
|
||||
static _i19.PageInfo page = _i19.PageInfo(
|
||||
name,
|
||||
builder: (data) {
|
||||
return _i18.WrappedRoute(child: const _i3.HomePage());
|
||||
return _i19.WrappedRoute(child: const _i3.HomePage());
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/// generated route for
|
||||
/// [_i4.LoginPage]
|
||||
class LoginRoute extends _i18.PageRouteInfo<void> {
|
||||
const LoginRoute({List<_i18.PageRouteInfo>? children})
|
||||
class LoginRoute extends _i19.PageRouteInfo<void> {
|
||||
const LoginRoute({List<_i19.PageRouteInfo>? children})
|
||||
: super(LoginRoute.name, initialChildren: children);
|
||||
|
||||
static const String name = 'LoginRoute';
|
||||
|
||||
static _i18.PageInfo page = _i18.PageInfo(
|
||||
static _i19.PageInfo page = _i19.PageInfo(
|
||||
name,
|
||||
builder: (data) {
|
||||
return _i18.WrappedRoute(child: const _i4.LoginPage());
|
||||
return _i19.WrappedRoute(child: const _i4.LoginPage());
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/// generated route for
|
||||
/// [_i5.MainPage]
|
||||
class MainRoute extends _i18.PageRouteInfo<void> {
|
||||
const MainRoute({List<_i18.PageRouteInfo>? children})
|
||||
class MainRoute extends _i19.PageRouteInfo<void> {
|
||||
const MainRoute({List<_i19.PageRouteInfo>? children})
|
||||
: super(MainRoute.name, initialChildren: children);
|
||||
|
||||
static const String name = 'MainRoute';
|
||||
|
||||
static _i18.PageInfo page = _i18.PageInfo(
|
||||
static _i19.PageInfo page = _i19.PageInfo(
|
||||
name,
|
||||
builder: (data) {
|
||||
return const _i5.MainPage();
|
||||
@ -129,11 +132,11 @@ class MainRoute extends _i18.PageRouteInfo<void> {
|
||||
|
||||
/// generated route for
|
||||
/// [_i6.OrderPage]
|
||||
class OrderRoute extends _i18.PageRouteInfo<OrderRouteArgs> {
|
||||
class OrderRoute extends _i19.PageRouteInfo<OrderRouteArgs> {
|
||||
OrderRoute({
|
||||
_i19.Key? key,
|
||||
_i20.Key? key,
|
||||
required String status,
|
||||
List<_i18.PageRouteInfo>? children,
|
||||
List<_i19.PageRouteInfo>? children,
|
||||
}) : super(
|
||||
OrderRoute.name,
|
||||
args: OrderRouteArgs(key: key, status: status),
|
||||
@ -142,11 +145,11 @@ class OrderRoute extends _i18.PageRouteInfo<OrderRouteArgs> {
|
||||
|
||||
static const String name = 'OrderRoute';
|
||||
|
||||
static _i18.PageInfo page = _i18.PageInfo(
|
||||
static _i19.PageInfo page = _i19.PageInfo(
|
||||
name,
|
||||
builder: (data) {
|
||||
final args = data.argsAs<OrderRouteArgs>();
|
||||
return _i18.WrappedRoute(
|
||||
return _i19.WrappedRoute(
|
||||
child: _i6.OrderPage(key: args.key, status: args.status),
|
||||
);
|
||||
},
|
||||
@ -156,7 +159,7 @@ class OrderRoute extends _i18.PageRouteInfo<OrderRouteArgs> {
|
||||
class OrderRouteArgs {
|
||||
const OrderRouteArgs({this.key, required this.status});
|
||||
|
||||
final _i19.Key? key;
|
||||
final _i20.Key? key;
|
||||
|
||||
final String status;
|
||||
|
||||
@ -168,50 +171,83 @@ class OrderRouteArgs {
|
||||
|
||||
/// generated route for
|
||||
/// [_i7.PaymentPage]
|
||||
class PaymentRoute extends _i18.PageRouteInfo<PaymentRouteArgs> {
|
||||
class PaymentRoute extends _i19.PageRouteInfo<PaymentRouteArgs> {
|
||||
PaymentRoute({
|
||||
_i19.Key? key,
|
||||
required _i20.Order order,
|
||||
List<_i18.PageRouteInfo>? children,
|
||||
_i20.Key? key,
|
||||
required _i21.Order order,
|
||||
bool isSplit = false,
|
||||
_i22.SplitType splitType = _i22.SplitType.unknown,
|
||||
String? customerId,
|
||||
String? customerName,
|
||||
List<_i19.PageRouteInfo>? children,
|
||||
}) : super(
|
||||
PaymentRoute.name,
|
||||
args: PaymentRouteArgs(key: key, order: order),
|
||||
args: PaymentRouteArgs(
|
||||
key: key,
|
||||
order: order,
|
||||
isSplit: isSplit,
|
||||
splitType: splitType,
|
||||
customerId: customerId,
|
||||
customerName: customerName,
|
||||
),
|
||||
initialChildren: children,
|
||||
);
|
||||
|
||||
static const String name = 'PaymentRoute';
|
||||
|
||||
static _i18.PageInfo page = _i18.PageInfo(
|
||||
static _i19.PageInfo page = _i19.PageInfo(
|
||||
name,
|
||||
builder: (data) {
|
||||
final args = data.argsAs<PaymentRouteArgs>();
|
||||
return _i18.WrappedRoute(
|
||||
child: _i7.PaymentPage(key: args.key, order: args.order),
|
||||
return _i19.WrappedRoute(
|
||||
child: _i7.PaymentPage(
|
||||
key: args.key,
|
||||
order: args.order,
|
||||
isSplit: args.isSplit,
|
||||
splitType: args.splitType,
|
||||
customerId: args.customerId,
|
||||
customerName: args.customerName,
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
class PaymentRouteArgs {
|
||||
const PaymentRouteArgs({this.key, required this.order});
|
||||
const PaymentRouteArgs({
|
||||
this.key,
|
||||
required this.order,
|
||||
this.isSplit = false,
|
||||
this.splitType = _i22.SplitType.unknown,
|
||||
this.customerId,
|
||||
this.customerName,
|
||||
});
|
||||
|
||||
final _i19.Key? key;
|
||||
final _i20.Key? key;
|
||||
|
||||
final _i20.Order order;
|
||||
final _i21.Order order;
|
||||
|
||||
final bool isSplit;
|
||||
|
||||
final _i22.SplitType splitType;
|
||||
|
||||
final String? customerId;
|
||||
|
||||
final String? customerName;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'PaymentRouteArgs{key: $key, order: $order}';
|
||||
return 'PaymentRouteArgs{key: $key, order: $order, isSplit: $isSplit, splitType: $splitType, customerId: $customerId, customerName: $customerName}';
|
||||
}
|
||||
}
|
||||
|
||||
/// generated route for
|
||||
/// [_i8.PaymentSuccessPage]
|
||||
class PaymentSuccessRoute extends _i18.PageRouteInfo<PaymentSuccessRouteArgs> {
|
||||
class PaymentSuccessRoute extends _i19.PageRouteInfo<PaymentSuccessRouteArgs> {
|
||||
PaymentSuccessRoute({
|
||||
_i19.Key? key,
|
||||
_i20.Key? key,
|
||||
required String orderId,
|
||||
List<_i18.PageRouteInfo>? children,
|
||||
List<_i19.PageRouteInfo>? children,
|
||||
}) : super(
|
||||
PaymentSuccessRoute.name,
|
||||
args: PaymentSuccessRouteArgs(key: key, orderId: orderId),
|
||||
@ -220,11 +256,11 @@ class PaymentSuccessRoute extends _i18.PageRouteInfo<PaymentSuccessRouteArgs> {
|
||||
|
||||
static const String name = 'PaymentSuccessRoute';
|
||||
|
||||
static _i18.PageInfo page = _i18.PageInfo(
|
||||
static _i19.PageInfo page = _i19.PageInfo(
|
||||
name,
|
||||
builder: (data) {
|
||||
final args = data.argsAs<PaymentSuccessRouteArgs>();
|
||||
return _i18.WrappedRoute(
|
||||
return _i19.WrappedRoute(
|
||||
child: _i8.PaymentSuccessPage(key: args.key, orderId: args.orderId),
|
||||
);
|
||||
},
|
||||
@ -234,7 +270,7 @@ class PaymentSuccessRoute extends _i18.PageRouteInfo<PaymentSuccessRouteArgs> {
|
||||
class PaymentSuccessRouteArgs {
|
||||
const PaymentSuccessRouteArgs({this.key, required this.orderId});
|
||||
|
||||
final _i19.Key? key;
|
||||
final _i20.Key? key;
|
||||
|
||||
final String orderId;
|
||||
|
||||
@ -246,13 +282,13 @@ class PaymentSuccessRouteArgs {
|
||||
|
||||
/// generated route for
|
||||
/// [_i9.ReportPage]
|
||||
class ReportRoute extends _i18.PageRouteInfo<void> {
|
||||
const ReportRoute({List<_i18.PageRouteInfo>? children})
|
||||
class ReportRoute extends _i19.PageRouteInfo<void> {
|
||||
const ReportRoute({List<_i19.PageRouteInfo>? children})
|
||||
: super(ReportRoute.name, initialChildren: children);
|
||||
|
||||
static const String name = 'ReportRoute';
|
||||
|
||||
static _i18.PageInfo page = _i18.PageInfo(
|
||||
static _i19.PageInfo page = _i19.PageInfo(
|
||||
name,
|
||||
builder: (data) {
|
||||
return const _i9.ReportPage();
|
||||
@ -262,13 +298,13 @@ class ReportRoute extends _i18.PageRouteInfo<void> {
|
||||
|
||||
/// generated route for
|
||||
/// [_i10.SettingPage]
|
||||
class SettingRoute extends _i18.PageRouteInfo<void> {
|
||||
const SettingRoute({List<_i18.PageRouteInfo>? children})
|
||||
class SettingRoute extends _i19.PageRouteInfo<void> {
|
||||
const SettingRoute({List<_i19.PageRouteInfo>? children})
|
||||
: super(SettingRoute.name, initialChildren: children);
|
||||
|
||||
static const String name = 'SettingRoute';
|
||||
|
||||
static _i18.PageInfo page = _i18.PageInfo(
|
||||
static _i19.PageInfo page = _i19.PageInfo(
|
||||
name,
|
||||
builder: (data) {
|
||||
return const _i10.SettingPage();
|
||||
@ -278,13 +314,13 @@ class SettingRoute extends _i18.PageRouteInfo<void> {
|
||||
|
||||
/// generated route for
|
||||
/// [_i11.SplashPage]
|
||||
class SplashRoute extends _i18.PageRouteInfo<void> {
|
||||
const SplashRoute({List<_i18.PageRouteInfo>? children})
|
||||
class SplashRoute extends _i19.PageRouteInfo<void> {
|
||||
const SplashRoute({List<_i19.PageRouteInfo>? children})
|
||||
: super(SplashRoute.name, initialChildren: children);
|
||||
|
||||
static const String name = 'SplashRoute';
|
||||
|
||||
static _i18.PageInfo page = _i18.PageInfo(
|
||||
static _i19.PageInfo page = _i19.PageInfo(
|
||||
name,
|
||||
builder: (data) {
|
||||
return const _i11.SplashPage();
|
||||
@ -293,28 +329,67 @@ class SplashRoute extends _i18.PageRouteInfo<void> {
|
||||
}
|
||||
|
||||
/// generated route for
|
||||
/// [_i12.SuccessAddItemOrderPage]
|
||||
class SuccessAddItemOrderRoute extends _i18.PageRouteInfo<void> {
|
||||
const SuccessAddItemOrderRoute({List<_i18.PageRouteInfo>? children})
|
||||
/// [_i12.SplitBillPage]
|
||||
class SplitBillRoute extends _i19.PageRouteInfo<SplitBillRouteArgs> {
|
||||
SplitBillRoute({
|
||||
_i20.Key? key,
|
||||
required _i21.Order order,
|
||||
List<_i19.PageRouteInfo>? children,
|
||||
}) : super(
|
||||
SplitBillRoute.name,
|
||||
args: SplitBillRouteArgs(key: key, order: order),
|
||||
initialChildren: children,
|
||||
);
|
||||
|
||||
static const String name = 'SplitBillRoute';
|
||||
|
||||
static _i19.PageInfo page = _i19.PageInfo(
|
||||
name,
|
||||
builder: (data) {
|
||||
final args = data.argsAs<SplitBillRouteArgs>();
|
||||
return _i19.WrappedRoute(
|
||||
child: _i12.SplitBillPage(key: args.key, order: args.order),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
class SplitBillRouteArgs {
|
||||
const SplitBillRouteArgs({this.key, required this.order});
|
||||
|
||||
final _i20.Key? key;
|
||||
|
||||
final _i21.Order order;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'SplitBillRouteArgs{key: $key, order: $order}';
|
||||
}
|
||||
}
|
||||
|
||||
/// generated route for
|
||||
/// [_i13.SuccessAddItemOrderPage]
|
||||
class SuccessAddItemOrderRoute extends _i19.PageRouteInfo<void> {
|
||||
const SuccessAddItemOrderRoute({List<_i19.PageRouteInfo>? children})
|
||||
: super(SuccessAddItemOrderRoute.name, initialChildren: children);
|
||||
|
||||
static const String name = 'SuccessAddItemOrderRoute';
|
||||
|
||||
static _i18.PageInfo page = _i18.PageInfo(
|
||||
static _i19.PageInfo page = _i19.PageInfo(
|
||||
name,
|
||||
builder: (data) {
|
||||
return const _i12.SuccessAddItemOrderPage();
|
||||
return const _i13.SuccessAddItemOrderPage();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/// generated route for
|
||||
/// [_i13.SuccessOrderPage]
|
||||
class SuccessOrderRoute extends _i18.PageRouteInfo<SuccessOrderRouteArgs> {
|
||||
/// [_i14.SuccessOrderPage]
|
||||
class SuccessOrderRoute extends _i19.PageRouteInfo<SuccessOrderRouteArgs> {
|
||||
SuccessOrderRoute({
|
||||
_i19.Key? key,
|
||||
required _i20.Order order,
|
||||
List<_i18.PageRouteInfo>? children,
|
||||
_i20.Key? key,
|
||||
required _i21.Order order,
|
||||
List<_i19.PageRouteInfo>? children,
|
||||
}) : super(
|
||||
SuccessOrderRoute.name,
|
||||
args: SuccessOrderRouteArgs(key: key, order: order),
|
||||
@ -323,12 +398,12 @@ class SuccessOrderRoute extends _i18.PageRouteInfo<SuccessOrderRouteArgs> {
|
||||
|
||||
static const String name = 'SuccessOrderRoute';
|
||||
|
||||
static _i18.PageInfo page = _i18.PageInfo(
|
||||
static _i19.PageInfo page = _i19.PageInfo(
|
||||
name,
|
||||
builder: (data) {
|
||||
final args = data.argsAs<SuccessOrderRouteArgs>();
|
||||
return _i18.WrappedRoute(
|
||||
child: _i13.SuccessOrderPage(key: args.key, order: args.order),
|
||||
return _i19.WrappedRoute(
|
||||
child: _i14.SuccessOrderPage(key: args.key, order: args.order),
|
||||
);
|
||||
},
|
||||
);
|
||||
@ -337,9 +412,9 @@ class SuccessOrderRoute extends _i18.PageRouteInfo<SuccessOrderRouteArgs> {
|
||||
class SuccessOrderRouteArgs {
|
||||
const SuccessOrderRouteArgs({this.key, required this.order});
|
||||
|
||||
final _i19.Key? key;
|
||||
final _i20.Key? key;
|
||||
|
||||
final _i20.Order order;
|
||||
final _i21.Order order;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
@ -348,44 +423,44 @@ class SuccessOrderRouteArgs {
|
||||
}
|
||||
|
||||
/// generated route for
|
||||
/// [_i14.SyncPage]
|
||||
class SyncRoute extends _i18.PageRouteInfo<void> {
|
||||
const SyncRoute({List<_i18.PageRouteInfo>? children})
|
||||
/// [_i15.SyncPage]
|
||||
class SyncRoute extends _i19.PageRouteInfo<void> {
|
||||
const SyncRoute({List<_i19.PageRouteInfo>? children})
|
||||
: super(SyncRoute.name, initialChildren: children);
|
||||
|
||||
static const String name = 'SyncRoute';
|
||||
|
||||
static _i18.PageInfo page = _i18.PageInfo(
|
||||
static _i19.PageInfo page = _i19.PageInfo(
|
||||
name,
|
||||
builder: (data) {
|
||||
return _i18.WrappedRoute(child: const _i14.SyncPage());
|
||||
return _i19.WrappedRoute(child: const _i15.SyncPage());
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/// generated route for
|
||||
/// [_i15.TablePage]
|
||||
class TableRoute extends _i18.PageRouteInfo<void> {
|
||||
const TableRoute({List<_i18.PageRouteInfo>? children})
|
||||
/// [_i16.TablePage]
|
||||
class TableRoute extends _i19.PageRouteInfo<void> {
|
||||
const TableRoute({List<_i19.PageRouteInfo>? children})
|
||||
: super(TableRoute.name, initialChildren: children);
|
||||
|
||||
static const String name = 'TableRoute';
|
||||
|
||||
static _i18.PageInfo page = _i18.PageInfo(
|
||||
static _i19.PageInfo page = _i19.PageInfo(
|
||||
name,
|
||||
builder: (data) {
|
||||
return _i18.WrappedRoute(child: const _i15.TablePage());
|
||||
return _i19.WrappedRoute(child: const _i16.TablePage());
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/// generated route for
|
||||
/// [_i16.VoidPage]
|
||||
class VoidRoute extends _i18.PageRouteInfo<VoidRouteArgs> {
|
||||
/// [_i17.VoidPage]
|
||||
class VoidRoute extends _i19.PageRouteInfo<VoidRouteArgs> {
|
||||
VoidRoute({
|
||||
_i19.Key? key,
|
||||
required _i20.Order order,
|
||||
List<_i18.PageRouteInfo>? children,
|
||||
_i20.Key? key,
|
||||
required _i21.Order order,
|
||||
List<_i19.PageRouteInfo>? children,
|
||||
}) : super(
|
||||
VoidRoute.name,
|
||||
args: VoidRouteArgs(key: key, order: order),
|
||||
@ -394,12 +469,12 @@ class VoidRoute extends _i18.PageRouteInfo<VoidRouteArgs> {
|
||||
|
||||
static const String name = 'VoidRoute';
|
||||
|
||||
static _i18.PageInfo page = _i18.PageInfo(
|
||||
static _i19.PageInfo page = _i19.PageInfo(
|
||||
name,
|
||||
builder: (data) {
|
||||
final args = data.argsAs<VoidRouteArgs>();
|
||||
return _i18.WrappedRoute(
|
||||
child: _i16.VoidPage(key: args.key, order: args.order),
|
||||
return _i19.WrappedRoute(
|
||||
child: _i17.VoidPage(key: args.key, order: args.order),
|
||||
);
|
||||
},
|
||||
);
|
||||
@ -408,9 +483,9 @@ class VoidRoute extends _i18.PageRouteInfo<VoidRouteArgs> {
|
||||
class VoidRouteArgs {
|
||||
const VoidRouteArgs({this.key, required this.order});
|
||||
|
||||
final _i19.Key? key;
|
||||
final _i20.Key? key;
|
||||
|
||||
final _i20.Order order;
|
||||
final _i21.Order order;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
@ -419,17 +494,17 @@ class VoidRouteArgs {
|
||||
}
|
||||
|
||||
/// generated route for
|
||||
/// [_i17.VoidSuccessPage]
|
||||
class VoidSuccessRoute extends _i18.PageRouteInfo<void> {
|
||||
const VoidSuccessRoute({List<_i18.PageRouteInfo>? children})
|
||||
/// [_i18.VoidSuccessPage]
|
||||
class VoidSuccessRoute extends _i19.PageRouteInfo<void> {
|
||||
const VoidSuccessRoute({List<_i19.PageRouteInfo>? children})
|
||||
: super(VoidSuccessRoute.name, initialChildren: children);
|
||||
|
||||
static const String name = 'VoidSuccessRoute';
|
||||
|
||||
static _i18.PageInfo page = _i18.PageInfo(
|
||||
static _i19.PageInfo page = _i19.PageInfo(
|
||||
name,
|
||||
builder: (data) {
|
||||
return const _i17.VoidSuccessPage();
|
||||
return const _i18.VoidSuccessPage();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user