create order

This commit is contained in:
efrilm
2025-10-28 00:08:12 +07:00
parent 34555dd789
commit 37f0008ec8
21 changed files with 2028 additions and 108 deletions
@@ -1,17 +1,26 @@
import 'package:bloc/bloc.dart';
import 'package:dartz/dartz.dart' hide Order;
import 'package:flutter/foundation.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:injectable/injectable.dart';
import 'package:injectable/injectable.dart' hide Order;
import '../../../common/types/order_type.dart';
import '../../../domain/customer/customer.dart';
import '../../../domain/order/order.dart';
import '../../../domain/outlet/outlet.dart';
import '../../../domain/payment_method/payment_method.dart';
import '../../../domain/product/product.dart';
import '../../../domain/table/table.dart';
part 'order_form_event.dart';
part 'order_form_state.dart';
part 'order_form_bloc.freezed.dart';
@injectable
class OrderFormBloc extends Bloc<OrderFormEvent, OrderFormState> {
OrderFormBloc() : super(OrderFormState.initial()) {
final IOrderRepository _repository;
final IOutletRepository _outletRepository;
OrderFormBloc(this._repository, this._outletRepository)
: super(OrderFormState.initial()) {
on<OrderFormEvent>(_onOrderFormBloc);
}
@@ -29,6 +38,43 @@ class OrderFormBloc extends Bloc<OrderFormEvent, OrderFormState> {
customerChanged: (e) async {
emit(state.copyWith(customer: e.customer));
},
createOrderWithPayment: (e) async {
Either<OrderFailure, Order> failureOrOrder;
emit(state.copyWith(isCreating: true, failureOrCreateOrder: none()));
final outlet = await _outletRepository.currentOutlet();
final request = OrderRequest(
outletId: outlet.id,
customerId: state.customer?.id ?? '',
tableNumber: e.table?.tableName ?? '',
tableId: e.table?.id ?? '',
orderType: e.orderType.name,
notes: '',
customerName: state.customerName ?? "",
orderItems: e.items
.map(
(item) => OrderItemRequest(
productId: item.product.id,
productVariantId: item.variant?.id ?? "",
quantity: item.quantity,
unitPrice: item.product.price.toInt(),
notes: item.notes,
),
)
.toList(),
);
failureOrOrder = await _repository.createOrder(request: request);
emit(
state.copyWith(
isCreating: false,
failureOrCreateOrder: optionOf(failureOrOrder),
),
);
},
);
}
}
@@ -22,37 +22,59 @@ mixin _$OrderFormEvent {
required TResult Function(String customerName) customerNameChanged,
required TResult Function(PaymentMethod payment) paymentMethodChanged,
required TResult Function(Customer? customer) customerChanged,
required TResult Function(
List<ProductQuantity> items,
OrderType orderType,
Table? table,
)
createOrderWithPayment,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(String customerName)? customerNameChanged,
TResult? Function(PaymentMethod payment)? paymentMethodChanged,
TResult? Function(Customer? customer)? customerChanged,
TResult? Function(
List<ProductQuantity> items,
OrderType orderType,
Table? table,
)?
createOrderWithPayment,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(String customerName)? customerNameChanged,
TResult Function(PaymentMethod payment)? paymentMethodChanged,
TResult Function(Customer? customer)? customerChanged,
TResult Function(
List<ProductQuantity> items,
OrderType orderType,
Table? table,
)?
createOrderWithPayment,
required TResult orElse(),
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_CustomerNameChanged value) customerNameChanged,
required TResult Function(_PaymentMethodChanged value) paymentMethodChanged,
required TResult Function(_CustomeChanged value) customerChanged,
required TResult Function(_CustomerChanged value) customerChanged,
required TResult Function(_CreateOrderWithPayment value)
createOrderWithPayment,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_CustomerNameChanged value)? customerNameChanged,
TResult? Function(_PaymentMethodChanged value)? paymentMethodChanged,
TResult? Function(_CustomeChanged value)? customerChanged,
TResult? Function(_CustomerChanged value)? customerChanged,
TResult? Function(_CreateOrderWithPayment value)? createOrderWithPayment,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_CustomerNameChanged value)? customerNameChanged,
TResult Function(_PaymentMethodChanged value)? paymentMethodChanged,
TResult Function(_CustomeChanged value)? customerChanged,
TResult Function(_CustomerChanged value)? customerChanged,
TResult Function(_CreateOrderWithPayment value)? createOrderWithPayment,
required TResult orElse(),
}) => throw _privateConstructorUsedError;
}
@@ -166,6 +188,12 @@ class _$CustomerNameChangedImpl
required TResult Function(String customerName) customerNameChanged,
required TResult Function(PaymentMethod payment) paymentMethodChanged,
required TResult Function(Customer? customer) customerChanged,
required TResult Function(
List<ProductQuantity> items,
OrderType orderType,
Table? table,
)
createOrderWithPayment,
}) {
return customerNameChanged(customerName);
}
@@ -176,6 +204,12 @@ class _$CustomerNameChangedImpl
TResult? Function(String customerName)? customerNameChanged,
TResult? Function(PaymentMethod payment)? paymentMethodChanged,
TResult? Function(Customer? customer)? customerChanged,
TResult? Function(
List<ProductQuantity> items,
OrderType orderType,
Table? table,
)?
createOrderWithPayment,
}) {
return customerNameChanged?.call(customerName);
}
@@ -186,6 +220,12 @@ class _$CustomerNameChangedImpl
TResult Function(String customerName)? customerNameChanged,
TResult Function(PaymentMethod payment)? paymentMethodChanged,
TResult Function(Customer? customer)? customerChanged,
TResult Function(
List<ProductQuantity> items,
OrderType orderType,
Table? table,
)?
createOrderWithPayment,
required TResult orElse(),
}) {
if (customerNameChanged != null) {
@@ -199,7 +239,9 @@ class _$CustomerNameChangedImpl
TResult map<TResult extends Object?>({
required TResult Function(_CustomerNameChanged value) customerNameChanged,
required TResult Function(_PaymentMethodChanged value) paymentMethodChanged,
required TResult Function(_CustomeChanged value) customerChanged,
required TResult Function(_CustomerChanged value) customerChanged,
required TResult Function(_CreateOrderWithPayment value)
createOrderWithPayment,
}) {
return customerNameChanged(this);
}
@@ -209,7 +251,8 @@ class _$CustomerNameChangedImpl
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_CustomerNameChanged value)? customerNameChanged,
TResult? Function(_PaymentMethodChanged value)? paymentMethodChanged,
TResult? Function(_CustomeChanged value)? customerChanged,
TResult? Function(_CustomerChanged value)? customerChanged,
TResult? Function(_CreateOrderWithPayment value)? createOrderWithPayment,
}) {
return customerNameChanged?.call(this);
}
@@ -219,7 +262,8 @@ class _$CustomerNameChangedImpl
TResult maybeMap<TResult extends Object?>({
TResult Function(_CustomerNameChanged value)? customerNameChanged,
TResult Function(_PaymentMethodChanged value)? paymentMethodChanged,
TResult Function(_CustomeChanged value)? customerChanged,
TResult Function(_CustomerChanged value)? customerChanged,
TResult Function(_CreateOrderWithPayment value)? createOrderWithPayment,
required TResult orElse(),
}) {
if (customerNameChanged != null) {
@@ -341,6 +385,12 @@ class _$PaymentMethodChangedImpl
required TResult Function(String customerName) customerNameChanged,
required TResult Function(PaymentMethod payment) paymentMethodChanged,
required TResult Function(Customer? customer) customerChanged,
required TResult Function(
List<ProductQuantity> items,
OrderType orderType,
Table? table,
)
createOrderWithPayment,
}) {
return paymentMethodChanged(payment);
}
@@ -351,6 +401,12 @@ class _$PaymentMethodChangedImpl
TResult? Function(String customerName)? customerNameChanged,
TResult? Function(PaymentMethod payment)? paymentMethodChanged,
TResult? Function(Customer? customer)? customerChanged,
TResult? Function(
List<ProductQuantity> items,
OrderType orderType,
Table? table,
)?
createOrderWithPayment,
}) {
return paymentMethodChanged?.call(payment);
}
@@ -361,6 +417,12 @@ class _$PaymentMethodChangedImpl
TResult Function(String customerName)? customerNameChanged,
TResult Function(PaymentMethod payment)? paymentMethodChanged,
TResult Function(Customer? customer)? customerChanged,
TResult Function(
List<ProductQuantity> items,
OrderType orderType,
Table? table,
)?
createOrderWithPayment,
required TResult orElse(),
}) {
if (paymentMethodChanged != null) {
@@ -374,7 +436,9 @@ class _$PaymentMethodChangedImpl
TResult map<TResult extends Object?>({
required TResult Function(_CustomerNameChanged value) customerNameChanged,
required TResult Function(_PaymentMethodChanged value) paymentMethodChanged,
required TResult Function(_CustomeChanged value) customerChanged,
required TResult Function(_CustomerChanged value) customerChanged,
required TResult Function(_CreateOrderWithPayment value)
createOrderWithPayment,
}) {
return paymentMethodChanged(this);
}
@@ -384,7 +448,8 @@ class _$PaymentMethodChangedImpl
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_CustomerNameChanged value)? customerNameChanged,
TResult? Function(_PaymentMethodChanged value)? paymentMethodChanged,
TResult? Function(_CustomeChanged value)? customerChanged,
TResult? Function(_CustomerChanged value)? customerChanged,
TResult? Function(_CreateOrderWithPayment value)? createOrderWithPayment,
}) {
return paymentMethodChanged?.call(this);
}
@@ -394,7 +459,8 @@ class _$PaymentMethodChangedImpl
TResult maybeMap<TResult extends Object?>({
TResult Function(_CustomerNameChanged value)? customerNameChanged,
TResult Function(_PaymentMethodChanged value)? paymentMethodChanged,
TResult Function(_CustomeChanged value)? customerChanged,
TResult Function(_CustomerChanged value)? customerChanged,
TResult Function(_CreateOrderWithPayment value)? createOrderWithPayment,
required TResult orElse(),
}) {
if (paymentMethodChanged != null) {
@@ -418,11 +484,11 @@ abstract class _PaymentMethodChanged implements OrderFormEvent {
}
/// @nodoc
abstract class _$$CustomeChangedImplCopyWith<$Res> {
factory _$$CustomeChangedImplCopyWith(
_$CustomeChangedImpl value,
$Res Function(_$CustomeChangedImpl) then,
) = __$$CustomeChangedImplCopyWithImpl<$Res>;
abstract class _$$CustomerChangedImplCopyWith<$Res> {
factory _$$CustomerChangedImplCopyWith(
_$CustomerChangedImpl value,
$Res Function(_$CustomerChangedImpl) then,
) = __$$CustomerChangedImplCopyWithImpl<$Res>;
@useResult
$Res call({Customer? customer});
@@ -430,12 +496,12 @@ abstract class _$$CustomeChangedImplCopyWith<$Res> {
}
/// @nodoc
class __$$CustomeChangedImplCopyWithImpl<$Res>
extends _$OrderFormEventCopyWithImpl<$Res, _$CustomeChangedImpl>
implements _$$CustomeChangedImplCopyWith<$Res> {
__$$CustomeChangedImplCopyWithImpl(
_$CustomeChangedImpl _value,
$Res Function(_$CustomeChangedImpl) _then,
class __$$CustomerChangedImplCopyWithImpl<$Res>
extends _$OrderFormEventCopyWithImpl<$Res, _$CustomerChangedImpl>
implements _$$CustomerChangedImplCopyWith<$Res> {
__$$CustomerChangedImplCopyWithImpl(
_$CustomerChangedImpl _value,
$Res Function(_$CustomerChangedImpl) _then,
) : super(_value, _then);
/// Create a copy of OrderFormEvent
@@ -444,7 +510,7 @@ class __$$CustomeChangedImplCopyWithImpl<$Res>
@override
$Res call({Object? customer = freezed}) {
return _then(
_$CustomeChangedImpl(
_$CustomerChangedImpl(
freezed == customer
? _value.customer
: customer // ignore: cast_nullable_to_non_nullable
@@ -470,10 +536,10 @@ class __$$CustomeChangedImplCopyWithImpl<$Res>
/// @nodoc
class _$CustomeChangedImpl
class _$CustomerChangedImpl
with DiagnosticableTreeMixin
implements _CustomeChanged {
const _$CustomeChangedImpl(this.customer);
implements _CustomerChanged {
const _$CustomerChangedImpl(this.customer);
@override
final Customer? customer;
@@ -495,7 +561,7 @@ class _$CustomeChangedImpl
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$CustomeChangedImpl &&
other is _$CustomerChangedImpl &&
(identical(other.customer, customer) ||
other.customer == customer));
}
@@ -508,8 +574,8 @@ class _$CustomeChangedImpl
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$CustomeChangedImplCopyWith<_$CustomeChangedImpl> get copyWith =>
__$$CustomeChangedImplCopyWithImpl<_$CustomeChangedImpl>(
_$$CustomerChangedImplCopyWith<_$CustomerChangedImpl> get copyWith =>
__$$CustomerChangedImplCopyWithImpl<_$CustomerChangedImpl>(
this,
_$identity,
);
@@ -520,6 +586,12 @@ class _$CustomeChangedImpl
required TResult Function(String customerName) customerNameChanged,
required TResult Function(PaymentMethod payment) paymentMethodChanged,
required TResult Function(Customer? customer) customerChanged,
required TResult Function(
List<ProductQuantity> items,
OrderType orderType,
Table? table,
)
createOrderWithPayment,
}) {
return customerChanged(customer);
}
@@ -530,6 +602,12 @@ class _$CustomeChangedImpl
TResult? Function(String customerName)? customerNameChanged,
TResult? Function(PaymentMethod payment)? paymentMethodChanged,
TResult? Function(Customer? customer)? customerChanged,
TResult? Function(
List<ProductQuantity> items,
OrderType orderType,
Table? table,
)?
createOrderWithPayment,
}) {
return customerChanged?.call(customer);
}
@@ -540,6 +618,12 @@ class _$CustomeChangedImpl
TResult Function(String customerName)? customerNameChanged,
TResult Function(PaymentMethod payment)? paymentMethodChanged,
TResult Function(Customer? customer)? customerChanged,
TResult Function(
List<ProductQuantity> items,
OrderType orderType,
Table? table,
)?
createOrderWithPayment,
required TResult orElse(),
}) {
if (customerChanged != null) {
@@ -553,7 +637,9 @@ class _$CustomeChangedImpl
TResult map<TResult extends Object?>({
required TResult Function(_CustomerNameChanged value) customerNameChanged,
required TResult Function(_PaymentMethodChanged value) paymentMethodChanged,
required TResult Function(_CustomeChanged value) customerChanged,
required TResult Function(_CustomerChanged value) customerChanged,
required TResult Function(_CreateOrderWithPayment value)
createOrderWithPayment,
}) {
return customerChanged(this);
}
@@ -563,7 +649,8 @@ class _$CustomeChangedImpl
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_CustomerNameChanged value)? customerNameChanged,
TResult? Function(_PaymentMethodChanged value)? paymentMethodChanged,
TResult? Function(_CustomeChanged value)? customerChanged,
TResult? Function(_CustomerChanged value)? customerChanged,
TResult? Function(_CreateOrderWithPayment value)? createOrderWithPayment,
}) {
return customerChanged?.call(this);
}
@@ -573,7 +660,8 @@ class _$CustomeChangedImpl
TResult maybeMap<TResult extends Object?>({
TResult Function(_CustomerNameChanged value)? customerNameChanged,
TResult Function(_PaymentMethodChanged value)? paymentMethodChanged,
TResult Function(_CustomeChanged value)? customerChanged,
TResult Function(_CustomerChanged value)? customerChanged,
TResult Function(_CreateOrderWithPayment value)? createOrderWithPayment,
required TResult orElse(),
}) {
if (customerChanged != null) {
@@ -583,24 +671,271 @@ class _$CustomeChangedImpl
}
}
abstract class _CustomeChanged implements OrderFormEvent {
const factory _CustomeChanged(final Customer? customer) =
_$CustomeChangedImpl;
abstract class _CustomerChanged implements OrderFormEvent {
const factory _CustomerChanged(final Customer? customer) =
_$CustomerChangedImpl;
Customer? get customer;
/// Create a copy of OrderFormEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
_$$CustomeChangedImplCopyWith<_$CustomeChangedImpl> get copyWith =>
_$$CustomerChangedImplCopyWith<_$CustomerChangedImpl> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class _$$CreateOrderWithPaymentImplCopyWith<$Res> {
factory _$$CreateOrderWithPaymentImplCopyWith(
_$CreateOrderWithPaymentImpl value,
$Res Function(_$CreateOrderWithPaymentImpl) then,
) = __$$CreateOrderWithPaymentImplCopyWithImpl<$Res>;
@useResult
$Res call({List<ProductQuantity> items, OrderType orderType, Table? table});
$TableCopyWith<$Res>? get table;
}
/// @nodoc
class __$$CreateOrderWithPaymentImplCopyWithImpl<$Res>
extends _$OrderFormEventCopyWithImpl<$Res, _$CreateOrderWithPaymentImpl>
implements _$$CreateOrderWithPaymentImplCopyWith<$Res> {
__$$CreateOrderWithPaymentImplCopyWithImpl(
_$CreateOrderWithPaymentImpl _value,
$Res Function(_$CreateOrderWithPaymentImpl) _then,
) : super(_value, _then);
/// Create a copy of OrderFormEvent
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? items = null,
Object? orderType = null,
Object? table = freezed,
}) {
return _then(
_$CreateOrderWithPaymentImpl(
items: null == items
? _value._items
: items // ignore: cast_nullable_to_non_nullable
as List<ProductQuantity>,
orderType: null == orderType
? _value.orderType
: orderType // ignore: cast_nullable_to_non_nullable
as OrderType,
table: freezed == table
? _value.table
: table // ignore: cast_nullable_to_non_nullable
as Table?,
),
);
}
/// Create a copy of OrderFormEvent
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$TableCopyWith<$Res>? get table {
if (_value.table == null) {
return null;
}
return $TableCopyWith<$Res>(_value.table!, (value) {
return _then(_value.copyWith(table: value));
});
}
}
/// @nodoc
class _$CreateOrderWithPaymentImpl
with DiagnosticableTreeMixin
implements _CreateOrderWithPayment {
const _$CreateOrderWithPaymentImpl({
required final List<ProductQuantity> items,
required this.orderType,
this.table,
}) : _items = items;
final List<ProductQuantity> _items;
@override
List<ProductQuantity> get items {
if (_items is EqualUnmodifiableListView) return _items;
// ignore: implicit_dynamic_type
return EqualUnmodifiableListView(_items);
}
@override
final OrderType orderType;
@override
final Table? table;
@override
String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) {
return 'OrderFormEvent.createOrderWithPayment(items: $items, orderType: $orderType, table: $table)';
}
@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
properties
..add(
DiagnosticsProperty('type', 'OrderFormEvent.createOrderWithPayment'),
)
..add(DiagnosticsProperty('items', items))
..add(DiagnosticsProperty('orderType', orderType))
..add(DiagnosticsProperty('table', table));
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$CreateOrderWithPaymentImpl &&
const DeepCollectionEquality().equals(other._items, _items) &&
(identical(other.orderType, orderType) ||
other.orderType == orderType) &&
(identical(other.table, table) || other.table == table));
}
@override
int get hashCode => Object.hash(
runtimeType,
const DeepCollectionEquality().hash(_items),
orderType,
table,
);
/// Create a copy of OrderFormEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$CreateOrderWithPaymentImplCopyWith<_$CreateOrderWithPaymentImpl>
get copyWith =>
__$$CreateOrderWithPaymentImplCopyWithImpl<_$CreateOrderWithPaymentImpl>(
this,
_$identity,
);
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(String customerName) customerNameChanged,
required TResult Function(PaymentMethod payment) paymentMethodChanged,
required TResult Function(Customer? customer) customerChanged,
required TResult Function(
List<ProductQuantity> items,
OrderType orderType,
Table? table,
)
createOrderWithPayment,
}) {
return createOrderWithPayment(items, orderType, table);
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(String customerName)? customerNameChanged,
TResult? Function(PaymentMethod payment)? paymentMethodChanged,
TResult? Function(Customer? customer)? customerChanged,
TResult? Function(
List<ProductQuantity> items,
OrderType orderType,
Table? table,
)?
createOrderWithPayment,
}) {
return createOrderWithPayment?.call(items, orderType, table);
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(String customerName)? customerNameChanged,
TResult Function(PaymentMethod payment)? paymentMethodChanged,
TResult Function(Customer? customer)? customerChanged,
TResult Function(
List<ProductQuantity> items,
OrderType orderType,
Table? table,
)?
createOrderWithPayment,
required TResult orElse(),
}) {
if (createOrderWithPayment != null) {
return createOrderWithPayment(items, orderType, table);
}
return orElse();
}
@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_CustomerNameChanged value) customerNameChanged,
required TResult Function(_PaymentMethodChanged value) paymentMethodChanged,
required TResult Function(_CustomerChanged value) customerChanged,
required TResult Function(_CreateOrderWithPayment value)
createOrderWithPayment,
}) {
return createOrderWithPayment(this);
}
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_CustomerNameChanged value)? customerNameChanged,
TResult? Function(_PaymentMethodChanged value)? paymentMethodChanged,
TResult? Function(_CustomerChanged value)? customerChanged,
TResult? Function(_CreateOrderWithPayment value)? createOrderWithPayment,
}) {
return createOrderWithPayment?.call(this);
}
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_CustomerNameChanged value)? customerNameChanged,
TResult Function(_PaymentMethodChanged value)? paymentMethodChanged,
TResult Function(_CustomerChanged value)? customerChanged,
TResult Function(_CreateOrderWithPayment value)? createOrderWithPayment,
required TResult orElse(),
}) {
if (createOrderWithPayment != null) {
return createOrderWithPayment(this);
}
return orElse();
}
}
abstract class _CreateOrderWithPayment implements OrderFormEvent {
const factory _CreateOrderWithPayment({
required final List<ProductQuantity> items,
required final OrderType orderType,
final Table? table,
}) = _$CreateOrderWithPaymentImpl;
List<ProductQuantity> get items;
OrderType get orderType;
Table? get table;
/// Create a copy of OrderFormEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
_$$CreateOrderWithPaymentImplCopyWith<_$CreateOrderWithPaymentImpl>
get copyWith => throw _privateConstructorUsedError;
}
/// @nodoc
mixin _$OrderFormState {
PaymentMethod? get paymentMethod => throw _privateConstructorUsedError;
String? get customerName => throw _privateConstructorUsedError;
Customer? get customer => throw _privateConstructorUsedError;
Option<Either<OrderFailure, Order>> get failureOrCreateOrder =>
throw _privateConstructorUsedError;
bool get isCreating => throw _privateConstructorUsedError;
/// Create a copy of OrderFormState
/// with the given fields replaced by the non-null parameter values.
@@ -620,6 +955,8 @@ abstract class $OrderFormStateCopyWith<$Res> {
PaymentMethod? paymentMethod,
String? customerName,
Customer? customer,
Option<Either<OrderFailure, Order>> failureOrCreateOrder,
bool isCreating,
});
$PaymentMethodCopyWith<$Res>? get paymentMethod;
@@ -644,6 +981,8 @@ class _$OrderFormStateCopyWithImpl<$Res, $Val extends OrderFormState>
Object? paymentMethod = freezed,
Object? customerName = freezed,
Object? customer = freezed,
Object? failureOrCreateOrder = null,
Object? isCreating = null,
}) {
return _then(
_value.copyWith(
@@ -659,6 +998,14 @@ class _$OrderFormStateCopyWithImpl<$Res, $Val extends OrderFormState>
? _value.customer
: customer // ignore: cast_nullable_to_non_nullable
as Customer?,
failureOrCreateOrder: null == failureOrCreateOrder
? _value.failureOrCreateOrder
: failureOrCreateOrder // ignore: cast_nullable_to_non_nullable
as Option<Either<OrderFailure, Order>>,
isCreating: null == isCreating
? _value.isCreating
: isCreating // ignore: cast_nullable_to_non_nullable
as bool,
)
as $Val,
);
@@ -706,6 +1053,8 @@ abstract class _$$OrderFormStateImplCopyWith<$Res>
PaymentMethod? paymentMethod,
String? customerName,
Customer? customer,
Option<Either<OrderFailure, Order>> failureOrCreateOrder,
bool isCreating,
});
@override
@@ -731,6 +1080,8 @@ class __$$OrderFormStateImplCopyWithImpl<$Res>
Object? paymentMethod = freezed,
Object? customerName = freezed,
Object? customer = freezed,
Object? failureOrCreateOrder = null,
Object? isCreating = null,
}) {
return _then(
_$OrderFormStateImpl(
@@ -746,6 +1097,14 @@ class __$$OrderFormStateImplCopyWithImpl<$Res>
? _value.customer
: customer // ignore: cast_nullable_to_non_nullable
as Customer?,
failureOrCreateOrder: null == failureOrCreateOrder
? _value.failureOrCreateOrder
: failureOrCreateOrder // ignore: cast_nullable_to_non_nullable
as Option<Either<OrderFailure, Order>>,
isCreating: null == isCreating
? _value.isCreating
: isCreating // ignore: cast_nullable_to_non_nullable
as bool,
),
);
}
@@ -756,7 +1115,13 @@ class __$$OrderFormStateImplCopyWithImpl<$Res>
class _$OrderFormStateImpl
with DiagnosticableTreeMixin
implements _OrderFormState {
_$OrderFormStateImpl({this.paymentMethod, this.customerName, this.customer});
_$OrderFormStateImpl({
this.paymentMethod,
this.customerName,
this.customer,
required this.failureOrCreateOrder,
this.isCreating = false,
});
@override
final PaymentMethod? paymentMethod;
@@ -764,10 +1129,15 @@ class _$OrderFormStateImpl
final String? customerName;
@override
final Customer? customer;
@override
final Option<Either<OrderFailure, Order>> failureOrCreateOrder;
@override
@JsonKey()
final bool isCreating;
@override
String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) {
return 'OrderFormState(paymentMethod: $paymentMethod, customerName: $customerName, customer: $customer)';
return 'OrderFormState(paymentMethod: $paymentMethod, customerName: $customerName, customer: $customer, failureOrCreateOrder: $failureOrCreateOrder, isCreating: $isCreating)';
}
@override
@@ -777,7 +1147,9 @@ class _$OrderFormStateImpl
..add(DiagnosticsProperty('type', 'OrderFormState'))
..add(DiagnosticsProperty('paymentMethod', paymentMethod))
..add(DiagnosticsProperty('customerName', customerName))
..add(DiagnosticsProperty('customer', customer));
..add(DiagnosticsProperty('customer', customer))
..add(DiagnosticsProperty('failureOrCreateOrder', failureOrCreateOrder))
..add(DiagnosticsProperty('isCreating', isCreating));
}
@override
@@ -790,12 +1162,22 @@ class _$OrderFormStateImpl
(identical(other.customerName, customerName) ||
other.customerName == customerName) &&
(identical(other.customer, customer) ||
other.customer == customer));
other.customer == customer) &&
(identical(other.failureOrCreateOrder, failureOrCreateOrder) ||
other.failureOrCreateOrder == failureOrCreateOrder) &&
(identical(other.isCreating, isCreating) ||
other.isCreating == isCreating));
}
@override
int get hashCode =>
Object.hash(runtimeType, paymentMethod, customerName, customer);
int get hashCode => Object.hash(
runtimeType,
paymentMethod,
customerName,
customer,
failureOrCreateOrder,
isCreating,
);
/// Create a copy of OrderFormState
/// with the given fields replaced by the non-null parameter values.
@@ -814,6 +1196,8 @@ abstract class _OrderFormState implements OrderFormState {
final PaymentMethod? paymentMethod,
final String? customerName,
final Customer? customer,
required final Option<Either<OrderFailure, Order>> failureOrCreateOrder,
final bool isCreating,
}) = _$OrderFormStateImpl;
@override
@@ -822,6 +1206,10 @@ abstract class _OrderFormState implements OrderFormState {
String? get customerName;
@override
Customer? get customer;
@override
Option<Either<OrderFailure, Order>> get failureOrCreateOrder;
@override
bool get isCreating;
/// Create a copy of OrderFormState
/// with the given fields replaced by the non-null parameter values.
@@ -7,5 +7,10 @@ class OrderFormEvent with _$OrderFormEvent {
const factory OrderFormEvent.paymentMethodChanged(PaymentMethod payment) =
_PaymentMethodChanged;
const factory OrderFormEvent.customerChanged(Customer? customer) =
_CustomeChanged;
_CustomerChanged;
const factory OrderFormEvent.createOrderWithPayment({
required List<ProductQuantity> items,
required OrderType orderType,
Table? table,
}) = _CreateOrderWithPayment;
}
@@ -6,7 +6,10 @@ class OrderFormState with _$OrderFormState {
PaymentMethod? paymentMethod,
String? customerName,
Customer? customer,
required Option<Either<OrderFailure, Order>> failureOrCreateOrder,
@Default(false) bool isCreating,
}) = _OrderFormState;
factory OrderFormState.initial() => OrderFormState();
factory OrderFormState.initial() =>
OrderFormState(failureOrCreateOrder: none());
}