feat: add item to order
This commit is contained in:
parent
571ba9802e
commit
6fb1a7d0c4
@ -355,4 +355,44 @@ class OrderRemoteDatasource {
|
|||||||
return const Left('Terjadi kesalahan tak terduga');
|
return const Left('Terjadi kesalahan tak terduga');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<Either<String, OrderDetailResponseModel>> addToOrder({
|
||||||
|
required String orderId,
|
||||||
|
required List<OrderItemRequest> orderItems,
|
||||||
|
}) async {
|
||||||
|
final authData = await AuthLocalDataSource().getAuthData();
|
||||||
|
final url = '${Variables.baseUrl}/api/v1/orders/$orderId/add-items';
|
||||||
|
|
||||||
|
try {
|
||||||
|
final response = await dio.post(
|
||||||
|
url,
|
||||||
|
data: {
|
||||||
|
"order_items": orderItems.map((item) => item.toMap()).toList(),
|
||||||
|
'notes': '',
|
||||||
|
},
|
||||||
|
options: Options(
|
||||||
|
headers: {
|
||||||
|
'Authorization': 'Bearer ${authData.token}',
|
||||||
|
'Accept': 'application/json',
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
if (response.statusCode == 200) {
|
||||||
|
final data = OrderDetailResponseModel.fromMap(response.data);
|
||||||
|
return Right(data);
|
||||||
|
} else {
|
||||||
|
return const Left('Gagal menambahkan pesanan pesanan');
|
||||||
|
}
|
||||||
|
} on DioException catch (e) {
|
||||||
|
final errorMessage = e.response?.data['message'] ?? 'Kesalahan jaringan';
|
||||||
|
log("💥 Dio error: ${e.message}");
|
||||||
|
log("💥 Dio response: ${e.response?.data}");
|
||||||
|
return Left(errorMessage);
|
||||||
|
} catch (e) {
|
||||||
|
log("💥 Unexpected error: $e");
|
||||||
|
return const Left('Terjadi kesalahan tak terduga');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -106,6 +106,32 @@ class OrderFormBloc extends Bloc<OrderFormEvent, OrderFormState> {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
on<_AddToOrder>(
|
||||||
|
(event, emit) async {
|
||||||
|
emit(const _Loading());
|
||||||
|
|
||||||
|
try {
|
||||||
|
final result = await _orderRemoteDatasource.addToOrder(
|
||||||
|
orderId: event.orderId,
|
||||||
|
orderItems: event.items
|
||||||
|
.map((item) => OrderItemRequest(
|
||||||
|
productId: item.product.id,
|
||||||
|
quantity: item.quantity,
|
||||||
|
unitPrice: item.product.price,
|
||||||
|
notes: item.notes))
|
||||||
|
.toList(),
|
||||||
|
);
|
||||||
|
|
||||||
|
result.fold(
|
||||||
|
(error) => emit(_Error(error)),
|
||||||
|
(success) => emit(_Success(success.data!)),
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
log("Error in AddOrderItemsBloc: $e");
|
||||||
|
emit(_Error("Failed to add order items: $e"));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
on<_ToggleItem>((event, emit) {
|
on<_ToggleItem>((event, emit) {
|
||||||
state.maybeWhen(
|
state.maybeWhen(
|
||||||
loaded: (order, selectedItems, _) {
|
loaded: (order, selectedItems, _) {
|
||||||
|
|||||||
@ -25,6 +25,8 @@ mixin _$OrderFormEvent {
|
|||||||
required TResult Function(List<ProductQuantity> items, String customerName,
|
required TResult Function(List<ProductQuantity> items, String customerName,
|
||||||
OrderType orderType, TableModel table, PaymentMethod paymentMethod)
|
OrderType orderType, TableModel table, PaymentMethod paymentMethod)
|
||||||
createWithPayment,
|
createWithPayment,
|
||||||
|
required TResult Function(List<ProductQuantity> items, String orderId)
|
||||||
|
addToOrder,
|
||||||
required TResult Function(OrderItem item) toggleItem,
|
required TResult Function(OrderItem item) toggleItem,
|
||||||
required TResult Function(bool selectAll) toggleSelectAll,
|
required TResult Function(bool selectAll) toggleSelectAll,
|
||||||
required TResult Function() refund,
|
required TResult Function() refund,
|
||||||
@ -39,6 +41,7 @@ mixin _$OrderFormEvent {
|
|||||||
TResult? Function(List<ProductQuantity> items, String customerName,
|
TResult? Function(List<ProductQuantity> items, String customerName,
|
||||||
OrderType orderType, TableModel table, PaymentMethod paymentMethod)?
|
OrderType orderType, TableModel table, PaymentMethod paymentMethod)?
|
||||||
createWithPayment,
|
createWithPayment,
|
||||||
|
TResult? Function(List<ProductQuantity> items, String orderId)? addToOrder,
|
||||||
TResult? Function(OrderItem item)? toggleItem,
|
TResult? Function(OrderItem item)? toggleItem,
|
||||||
TResult? Function(bool selectAll)? toggleSelectAll,
|
TResult? Function(bool selectAll)? toggleSelectAll,
|
||||||
TResult? Function()? refund,
|
TResult? Function()? refund,
|
||||||
@ -53,6 +56,7 @@ mixin _$OrderFormEvent {
|
|||||||
TResult Function(List<ProductQuantity> items, String customerName,
|
TResult Function(List<ProductQuantity> items, String customerName,
|
||||||
OrderType orderType, TableModel table, PaymentMethod paymentMethod)?
|
OrderType orderType, TableModel table, PaymentMethod paymentMethod)?
|
||||||
createWithPayment,
|
createWithPayment,
|
||||||
|
TResult Function(List<ProductQuantity> items, String orderId)? addToOrder,
|
||||||
TResult Function(OrderItem item)? toggleItem,
|
TResult Function(OrderItem item)? toggleItem,
|
||||||
TResult Function(bool selectAll)? toggleSelectAll,
|
TResult Function(bool selectAll)? toggleSelectAll,
|
||||||
TResult Function()? refund,
|
TResult Function()? refund,
|
||||||
@ -64,6 +68,7 @@ mixin _$OrderFormEvent {
|
|||||||
required TResult Function(_Started value) started,
|
required TResult Function(_Started value) started,
|
||||||
required TResult Function(_Create value) create,
|
required TResult Function(_Create value) create,
|
||||||
required TResult Function(_CreateWithPaymentMethod value) createWithPayment,
|
required TResult Function(_CreateWithPaymentMethod value) createWithPayment,
|
||||||
|
required TResult Function(_AddToOrder value) addToOrder,
|
||||||
required TResult Function(_ToggleItem value) toggleItem,
|
required TResult Function(_ToggleItem value) toggleItem,
|
||||||
required TResult Function(_ToggleSelectAll value) toggleSelectAll,
|
required TResult Function(_ToggleSelectAll value) toggleSelectAll,
|
||||||
required TResult Function(_Refund value) refund,
|
required TResult Function(_Refund value) refund,
|
||||||
@ -74,6 +79,7 @@ mixin _$OrderFormEvent {
|
|||||||
TResult? Function(_Started value)? started,
|
TResult? Function(_Started value)? started,
|
||||||
TResult? Function(_Create value)? create,
|
TResult? Function(_Create value)? create,
|
||||||
TResult? Function(_CreateWithPaymentMethod value)? createWithPayment,
|
TResult? Function(_CreateWithPaymentMethod value)? createWithPayment,
|
||||||
|
TResult? Function(_AddToOrder value)? addToOrder,
|
||||||
TResult? Function(_ToggleItem value)? toggleItem,
|
TResult? Function(_ToggleItem value)? toggleItem,
|
||||||
TResult? Function(_ToggleSelectAll value)? toggleSelectAll,
|
TResult? Function(_ToggleSelectAll value)? toggleSelectAll,
|
||||||
TResult? Function(_Refund value)? refund,
|
TResult? Function(_Refund value)? refund,
|
||||||
@ -84,6 +90,7 @@ mixin _$OrderFormEvent {
|
|||||||
TResult Function(_Started value)? started,
|
TResult Function(_Started value)? started,
|
||||||
TResult Function(_Create value)? create,
|
TResult Function(_Create value)? create,
|
||||||
TResult Function(_CreateWithPaymentMethod value)? createWithPayment,
|
TResult Function(_CreateWithPaymentMethod value)? createWithPayment,
|
||||||
|
TResult Function(_AddToOrder value)? addToOrder,
|
||||||
TResult Function(_ToggleItem value)? toggleItem,
|
TResult Function(_ToggleItem value)? toggleItem,
|
||||||
TResult Function(_ToggleSelectAll value)? toggleSelectAll,
|
TResult Function(_ToggleSelectAll value)? toggleSelectAll,
|
||||||
TResult Function(_Refund value)? refund,
|
TResult Function(_Refund value)? refund,
|
||||||
@ -188,6 +195,8 @@ class _$StartedImpl implements _Started {
|
|||||||
required TResult Function(List<ProductQuantity> items, String customerName,
|
required TResult Function(List<ProductQuantity> items, String customerName,
|
||||||
OrderType orderType, TableModel table, PaymentMethod paymentMethod)
|
OrderType orderType, TableModel table, PaymentMethod paymentMethod)
|
||||||
createWithPayment,
|
createWithPayment,
|
||||||
|
required TResult Function(List<ProductQuantity> items, String orderId)
|
||||||
|
addToOrder,
|
||||||
required TResult Function(OrderItem item) toggleItem,
|
required TResult Function(OrderItem item) toggleItem,
|
||||||
required TResult Function(bool selectAll) toggleSelectAll,
|
required TResult Function(bool selectAll) toggleSelectAll,
|
||||||
required TResult Function() refund,
|
required TResult Function() refund,
|
||||||
@ -205,6 +214,7 @@ class _$StartedImpl implements _Started {
|
|||||||
TResult? Function(List<ProductQuantity> items, String customerName,
|
TResult? Function(List<ProductQuantity> items, String customerName,
|
||||||
OrderType orderType, TableModel table, PaymentMethod paymentMethod)?
|
OrderType orderType, TableModel table, PaymentMethod paymentMethod)?
|
||||||
createWithPayment,
|
createWithPayment,
|
||||||
|
TResult? Function(List<ProductQuantity> items, String orderId)? addToOrder,
|
||||||
TResult? Function(OrderItem item)? toggleItem,
|
TResult? Function(OrderItem item)? toggleItem,
|
||||||
TResult? Function(bool selectAll)? toggleSelectAll,
|
TResult? Function(bool selectAll)? toggleSelectAll,
|
||||||
TResult? Function()? refund,
|
TResult? Function()? refund,
|
||||||
@ -222,6 +232,7 @@ class _$StartedImpl implements _Started {
|
|||||||
TResult Function(List<ProductQuantity> items, String customerName,
|
TResult Function(List<ProductQuantity> items, String customerName,
|
||||||
OrderType orderType, TableModel table, PaymentMethod paymentMethod)?
|
OrderType orderType, TableModel table, PaymentMethod paymentMethod)?
|
||||||
createWithPayment,
|
createWithPayment,
|
||||||
|
TResult Function(List<ProductQuantity> items, String orderId)? addToOrder,
|
||||||
TResult Function(OrderItem item)? toggleItem,
|
TResult Function(OrderItem item)? toggleItem,
|
||||||
TResult Function(bool selectAll)? toggleSelectAll,
|
TResult Function(bool selectAll)? toggleSelectAll,
|
||||||
TResult Function()? refund,
|
TResult Function()? refund,
|
||||||
@ -239,6 +250,7 @@ class _$StartedImpl implements _Started {
|
|||||||
required TResult Function(_Started value) started,
|
required TResult Function(_Started value) started,
|
||||||
required TResult Function(_Create value) create,
|
required TResult Function(_Create value) create,
|
||||||
required TResult Function(_CreateWithPaymentMethod value) createWithPayment,
|
required TResult Function(_CreateWithPaymentMethod value) createWithPayment,
|
||||||
|
required TResult Function(_AddToOrder value) addToOrder,
|
||||||
required TResult Function(_ToggleItem value) toggleItem,
|
required TResult Function(_ToggleItem value) toggleItem,
|
||||||
required TResult Function(_ToggleSelectAll value) toggleSelectAll,
|
required TResult Function(_ToggleSelectAll value) toggleSelectAll,
|
||||||
required TResult Function(_Refund value) refund,
|
required TResult Function(_Refund value) refund,
|
||||||
@ -252,6 +264,7 @@ class _$StartedImpl implements _Started {
|
|||||||
TResult? Function(_Started value)? started,
|
TResult? Function(_Started value)? started,
|
||||||
TResult? Function(_Create value)? create,
|
TResult? Function(_Create value)? create,
|
||||||
TResult? Function(_CreateWithPaymentMethod value)? createWithPayment,
|
TResult? Function(_CreateWithPaymentMethod value)? createWithPayment,
|
||||||
|
TResult? Function(_AddToOrder value)? addToOrder,
|
||||||
TResult? Function(_ToggleItem value)? toggleItem,
|
TResult? Function(_ToggleItem value)? toggleItem,
|
||||||
TResult? Function(_ToggleSelectAll value)? toggleSelectAll,
|
TResult? Function(_ToggleSelectAll value)? toggleSelectAll,
|
||||||
TResult? Function(_Refund value)? refund,
|
TResult? Function(_Refund value)? refund,
|
||||||
@ -265,6 +278,7 @@ class _$StartedImpl implements _Started {
|
|||||||
TResult Function(_Started value)? started,
|
TResult Function(_Started value)? started,
|
||||||
TResult Function(_Create value)? create,
|
TResult Function(_Create value)? create,
|
||||||
TResult Function(_CreateWithPaymentMethod value)? createWithPayment,
|
TResult Function(_CreateWithPaymentMethod value)? createWithPayment,
|
||||||
|
TResult Function(_AddToOrder value)? addToOrder,
|
||||||
TResult Function(_ToggleItem value)? toggleItem,
|
TResult Function(_ToggleItem value)? toggleItem,
|
||||||
TResult Function(_ToggleSelectAll value)? toggleSelectAll,
|
TResult Function(_ToggleSelectAll value)? toggleSelectAll,
|
||||||
TResult Function(_Refund value)? refund,
|
TResult Function(_Refund value)? refund,
|
||||||
@ -318,7 +332,7 @@ class __$$CreateImplCopyWithImpl<$Res>
|
|||||||
Object? items = null,
|
Object? items = null,
|
||||||
Object? customerName = null,
|
Object? customerName = null,
|
||||||
Object? orderType = null,
|
Object? orderType = null,
|
||||||
Object? table = freezed,
|
Object? table = null,
|
||||||
}) {
|
}) {
|
||||||
return _then(_$CreateImpl(
|
return _then(_$CreateImpl(
|
||||||
items: null == items
|
items: null == items
|
||||||
@ -333,7 +347,7 @@ class __$$CreateImplCopyWithImpl<$Res>
|
|||||||
? _value.orderType
|
? _value.orderType
|
||||||
: orderType // ignore: cast_nullable_to_non_nullable
|
: orderType // ignore: cast_nullable_to_non_nullable
|
||||||
as OrderType,
|
as OrderType,
|
||||||
table: freezed == table
|
table: null == table
|
||||||
? _value.table
|
? _value.table
|
||||||
: table // ignore: cast_nullable_to_non_nullable
|
: table // ignore: cast_nullable_to_non_nullable
|
||||||
as TableModel,
|
as TableModel,
|
||||||
@ -381,7 +395,7 @@ class _$CreateImpl implements _Create {
|
|||||||
other.customerName == customerName) &&
|
other.customerName == customerName) &&
|
||||||
(identical(other.orderType, orderType) ||
|
(identical(other.orderType, orderType) ||
|
||||||
other.orderType == orderType) &&
|
other.orderType == orderType) &&
|
||||||
const DeepCollectionEquality().equals(other.table, table));
|
(identical(other.table, table) || other.table == table));
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -390,7 +404,7 @@ class _$CreateImpl implements _Create {
|
|||||||
const DeepCollectionEquality().hash(_items),
|
const DeepCollectionEquality().hash(_items),
|
||||||
customerName,
|
customerName,
|
||||||
orderType,
|
orderType,
|
||||||
const DeepCollectionEquality().hash(table));
|
table);
|
||||||
|
|
||||||
/// Create a copy of OrderFormEvent
|
/// Create a copy of OrderFormEvent
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@ -410,6 +424,8 @@ class _$CreateImpl implements _Create {
|
|||||||
required TResult Function(List<ProductQuantity> items, String customerName,
|
required TResult Function(List<ProductQuantity> items, String customerName,
|
||||||
OrderType orderType, TableModel table, PaymentMethod paymentMethod)
|
OrderType orderType, TableModel table, PaymentMethod paymentMethod)
|
||||||
createWithPayment,
|
createWithPayment,
|
||||||
|
required TResult Function(List<ProductQuantity> items, String orderId)
|
||||||
|
addToOrder,
|
||||||
required TResult Function(OrderItem item) toggleItem,
|
required TResult Function(OrderItem item) toggleItem,
|
||||||
required TResult Function(bool selectAll) toggleSelectAll,
|
required TResult Function(bool selectAll) toggleSelectAll,
|
||||||
required TResult Function() refund,
|
required TResult Function() refund,
|
||||||
@ -427,6 +443,7 @@ class _$CreateImpl implements _Create {
|
|||||||
TResult? Function(List<ProductQuantity> items, String customerName,
|
TResult? Function(List<ProductQuantity> items, String customerName,
|
||||||
OrderType orderType, TableModel table, PaymentMethod paymentMethod)?
|
OrderType orderType, TableModel table, PaymentMethod paymentMethod)?
|
||||||
createWithPayment,
|
createWithPayment,
|
||||||
|
TResult? Function(List<ProductQuantity> items, String orderId)? addToOrder,
|
||||||
TResult? Function(OrderItem item)? toggleItem,
|
TResult? Function(OrderItem item)? toggleItem,
|
||||||
TResult? Function(bool selectAll)? toggleSelectAll,
|
TResult? Function(bool selectAll)? toggleSelectAll,
|
||||||
TResult? Function()? refund,
|
TResult? Function()? refund,
|
||||||
@ -444,6 +461,7 @@ class _$CreateImpl implements _Create {
|
|||||||
TResult Function(List<ProductQuantity> items, String customerName,
|
TResult Function(List<ProductQuantity> items, String customerName,
|
||||||
OrderType orderType, TableModel table, PaymentMethod paymentMethod)?
|
OrderType orderType, TableModel table, PaymentMethod paymentMethod)?
|
||||||
createWithPayment,
|
createWithPayment,
|
||||||
|
TResult Function(List<ProductQuantity> items, String orderId)? addToOrder,
|
||||||
TResult Function(OrderItem item)? toggleItem,
|
TResult Function(OrderItem item)? toggleItem,
|
||||||
TResult Function(bool selectAll)? toggleSelectAll,
|
TResult Function(bool selectAll)? toggleSelectAll,
|
||||||
TResult Function()? refund,
|
TResult Function()? refund,
|
||||||
@ -461,6 +479,7 @@ class _$CreateImpl implements _Create {
|
|||||||
required TResult Function(_Started value) started,
|
required TResult Function(_Started value) started,
|
||||||
required TResult Function(_Create value) create,
|
required TResult Function(_Create value) create,
|
||||||
required TResult Function(_CreateWithPaymentMethod value) createWithPayment,
|
required TResult Function(_CreateWithPaymentMethod value) createWithPayment,
|
||||||
|
required TResult Function(_AddToOrder value) addToOrder,
|
||||||
required TResult Function(_ToggleItem value) toggleItem,
|
required TResult Function(_ToggleItem value) toggleItem,
|
||||||
required TResult Function(_ToggleSelectAll value) toggleSelectAll,
|
required TResult Function(_ToggleSelectAll value) toggleSelectAll,
|
||||||
required TResult Function(_Refund value) refund,
|
required TResult Function(_Refund value) refund,
|
||||||
@ -474,6 +493,7 @@ class _$CreateImpl implements _Create {
|
|||||||
TResult? Function(_Started value)? started,
|
TResult? Function(_Started value)? started,
|
||||||
TResult? Function(_Create value)? create,
|
TResult? Function(_Create value)? create,
|
||||||
TResult? Function(_CreateWithPaymentMethod value)? createWithPayment,
|
TResult? Function(_CreateWithPaymentMethod value)? createWithPayment,
|
||||||
|
TResult? Function(_AddToOrder value)? addToOrder,
|
||||||
TResult? Function(_ToggleItem value)? toggleItem,
|
TResult? Function(_ToggleItem value)? toggleItem,
|
||||||
TResult? Function(_ToggleSelectAll value)? toggleSelectAll,
|
TResult? Function(_ToggleSelectAll value)? toggleSelectAll,
|
||||||
TResult? Function(_Refund value)? refund,
|
TResult? Function(_Refund value)? refund,
|
||||||
@ -487,6 +507,7 @@ class _$CreateImpl implements _Create {
|
|||||||
TResult Function(_Started value)? started,
|
TResult Function(_Started value)? started,
|
||||||
TResult Function(_Create value)? create,
|
TResult Function(_Create value)? create,
|
||||||
TResult Function(_CreateWithPaymentMethod value)? createWithPayment,
|
TResult Function(_CreateWithPaymentMethod value)? createWithPayment,
|
||||||
|
TResult Function(_AddToOrder value)? addToOrder,
|
||||||
TResult Function(_ToggleItem value)? toggleItem,
|
TResult Function(_ToggleItem value)? toggleItem,
|
||||||
TResult Function(_ToggleSelectAll value)? toggleSelectAll,
|
TResult Function(_ToggleSelectAll value)? toggleSelectAll,
|
||||||
TResult Function(_Refund value)? refund,
|
TResult Function(_Refund value)? refund,
|
||||||
@ -550,7 +571,7 @@ class __$$CreateWithPaymentMethodImplCopyWithImpl<$Res>
|
|||||||
Object? items = null,
|
Object? items = null,
|
||||||
Object? customerName = null,
|
Object? customerName = null,
|
||||||
Object? orderType = null,
|
Object? orderType = null,
|
||||||
Object? table = freezed,
|
Object? table = null,
|
||||||
Object? paymentMethod = null,
|
Object? paymentMethod = null,
|
||||||
}) {
|
}) {
|
||||||
return _then(_$CreateWithPaymentMethodImpl(
|
return _then(_$CreateWithPaymentMethodImpl(
|
||||||
@ -566,7 +587,7 @@ class __$$CreateWithPaymentMethodImplCopyWithImpl<$Res>
|
|||||||
? _value.orderType
|
? _value.orderType
|
||||||
: orderType // ignore: cast_nullable_to_non_nullable
|
: orderType // ignore: cast_nullable_to_non_nullable
|
||||||
as OrderType,
|
as OrderType,
|
||||||
table: freezed == table
|
table: null == table
|
||||||
? _value.table
|
? _value.table
|
||||||
: table // ignore: cast_nullable_to_non_nullable
|
: table // ignore: cast_nullable_to_non_nullable
|
||||||
as TableModel,
|
as TableModel,
|
||||||
@ -621,7 +642,7 @@ class _$CreateWithPaymentMethodImpl implements _CreateWithPaymentMethod {
|
|||||||
other.customerName == customerName) &&
|
other.customerName == customerName) &&
|
||||||
(identical(other.orderType, orderType) ||
|
(identical(other.orderType, orderType) ||
|
||||||
other.orderType == orderType) &&
|
other.orderType == orderType) &&
|
||||||
const DeepCollectionEquality().equals(other.table, table) &&
|
(identical(other.table, table) || other.table == table) &&
|
||||||
(identical(other.paymentMethod, paymentMethod) ||
|
(identical(other.paymentMethod, paymentMethod) ||
|
||||||
other.paymentMethod == paymentMethod));
|
other.paymentMethod == paymentMethod));
|
||||||
}
|
}
|
||||||
@ -632,7 +653,7 @@ class _$CreateWithPaymentMethodImpl implements _CreateWithPaymentMethod {
|
|||||||
const DeepCollectionEquality().hash(_items),
|
const DeepCollectionEquality().hash(_items),
|
||||||
customerName,
|
customerName,
|
||||||
orderType,
|
orderType,
|
||||||
const DeepCollectionEquality().hash(table),
|
table,
|
||||||
paymentMethod);
|
paymentMethod);
|
||||||
|
|
||||||
/// Create a copy of OrderFormEvent
|
/// Create a copy of OrderFormEvent
|
||||||
@ -654,6 +675,8 @@ class _$CreateWithPaymentMethodImpl implements _CreateWithPaymentMethod {
|
|||||||
required TResult Function(List<ProductQuantity> items, String customerName,
|
required TResult Function(List<ProductQuantity> items, String customerName,
|
||||||
OrderType orderType, TableModel table, PaymentMethod paymentMethod)
|
OrderType orderType, TableModel table, PaymentMethod paymentMethod)
|
||||||
createWithPayment,
|
createWithPayment,
|
||||||
|
required TResult Function(List<ProductQuantity> items, String orderId)
|
||||||
|
addToOrder,
|
||||||
required TResult Function(OrderItem item) toggleItem,
|
required TResult Function(OrderItem item) toggleItem,
|
||||||
required TResult Function(bool selectAll) toggleSelectAll,
|
required TResult Function(bool selectAll) toggleSelectAll,
|
||||||
required TResult Function() refund,
|
required TResult Function() refund,
|
||||||
@ -672,6 +695,7 @@ class _$CreateWithPaymentMethodImpl implements _CreateWithPaymentMethod {
|
|||||||
TResult? Function(List<ProductQuantity> items, String customerName,
|
TResult? Function(List<ProductQuantity> items, String customerName,
|
||||||
OrderType orderType, TableModel table, PaymentMethod paymentMethod)?
|
OrderType orderType, TableModel table, PaymentMethod paymentMethod)?
|
||||||
createWithPayment,
|
createWithPayment,
|
||||||
|
TResult? Function(List<ProductQuantity> items, String orderId)? addToOrder,
|
||||||
TResult? Function(OrderItem item)? toggleItem,
|
TResult? Function(OrderItem item)? toggleItem,
|
||||||
TResult? Function(bool selectAll)? toggleSelectAll,
|
TResult? Function(bool selectAll)? toggleSelectAll,
|
||||||
TResult? Function()? refund,
|
TResult? Function()? refund,
|
||||||
@ -690,6 +714,7 @@ class _$CreateWithPaymentMethodImpl implements _CreateWithPaymentMethod {
|
|||||||
TResult Function(List<ProductQuantity> items, String customerName,
|
TResult Function(List<ProductQuantity> items, String customerName,
|
||||||
OrderType orderType, TableModel table, PaymentMethod paymentMethod)?
|
OrderType orderType, TableModel table, PaymentMethod paymentMethod)?
|
||||||
createWithPayment,
|
createWithPayment,
|
||||||
|
TResult Function(List<ProductQuantity> items, String orderId)? addToOrder,
|
||||||
TResult Function(OrderItem item)? toggleItem,
|
TResult Function(OrderItem item)? toggleItem,
|
||||||
TResult Function(bool selectAll)? toggleSelectAll,
|
TResult Function(bool selectAll)? toggleSelectAll,
|
||||||
TResult Function()? refund,
|
TResult Function()? refund,
|
||||||
@ -708,6 +733,7 @@ class _$CreateWithPaymentMethodImpl implements _CreateWithPaymentMethod {
|
|||||||
required TResult Function(_Started value) started,
|
required TResult Function(_Started value) started,
|
||||||
required TResult Function(_Create value) create,
|
required TResult Function(_Create value) create,
|
||||||
required TResult Function(_CreateWithPaymentMethod value) createWithPayment,
|
required TResult Function(_CreateWithPaymentMethod value) createWithPayment,
|
||||||
|
required TResult Function(_AddToOrder value) addToOrder,
|
||||||
required TResult Function(_ToggleItem value) toggleItem,
|
required TResult Function(_ToggleItem value) toggleItem,
|
||||||
required TResult Function(_ToggleSelectAll value) toggleSelectAll,
|
required TResult Function(_ToggleSelectAll value) toggleSelectAll,
|
||||||
required TResult Function(_Refund value) refund,
|
required TResult Function(_Refund value) refund,
|
||||||
@ -721,6 +747,7 @@ class _$CreateWithPaymentMethodImpl implements _CreateWithPaymentMethod {
|
|||||||
TResult? Function(_Started value)? started,
|
TResult? Function(_Started value)? started,
|
||||||
TResult? Function(_Create value)? create,
|
TResult? Function(_Create value)? create,
|
||||||
TResult? Function(_CreateWithPaymentMethod value)? createWithPayment,
|
TResult? Function(_CreateWithPaymentMethod value)? createWithPayment,
|
||||||
|
TResult? Function(_AddToOrder value)? addToOrder,
|
||||||
TResult? Function(_ToggleItem value)? toggleItem,
|
TResult? Function(_ToggleItem value)? toggleItem,
|
||||||
TResult? Function(_ToggleSelectAll value)? toggleSelectAll,
|
TResult? Function(_ToggleSelectAll value)? toggleSelectAll,
|
||||||
TResult? Function(_Refund value)? refund,
|
TResult? Function(_Refund value)? refund,
|
||||||
@ -734,6 +761,7 @@ class _$CreateWithPaymentMethodImpl implements _CreateWithPaymentMethod {
|
|||||||
TResult Function(_Started value)? started,
|
TResult Function(_Started value)? started,
|
||||||
TResult Function(_Create value)? create,
|
TResult Function(_Create value)? create,
|
||||||
TResult Function(_CreateWithPaymentMethod value)? createWithPayment,
|
TResult Function(_CreateWithPaymentMethod value)? createWithPayment,
|
||||||
|
TResult Function(_AddToOrder value)? addToOrder,
|
||||||
TResult Function(_ToggleItem value)? toggleItem,
|
TResult Function(_ToggleItem value)? toggleItem,
|
||||||
TResult Function(_ToggleSelectAll value)? toggleSelectAll,
|
TResult Function(_ToggleSelectAll value)? toggleSelectAll,
|
||||||
TResult Function(_Refund value)? refund,
|
TResult Function(_Refund value)? refund,
|
||||||
@ -768,6 +796,209 @@ abstract class _CreateWithPaymentMethod implements OrderFormEvent {
|
|||||||
get copyWith => throw _privateConstructorUsedError;
|
get copyWith => throw _privateConstructorUsedError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
abstract class _$$AddToOrderImplCopyWith<$Res> {
|
||||||
|
factory _$$AddToOrderImplCopyWith(
|
||||||
|
_$AddToOrderImpl value, $Res Function(_$AddToOrderImpl) then) =
|
||||||
|
__$$AddToOrderImplCopyWithImpl<$Res>;
|
||||||
|
@useResult
|
||||||
|
$Res call({List<ProductQuantity> items, String orderId});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
class __$$AddToOrderImplCopyWithImpl<$Res>
|
||||||
|
extends _$OrderFormEventCopyWithImpl<$Res, _$AddToOrderImpl>
|
||||||
|
implements _$$AddToOrderImplCopyWith<$Res> {
|
||||||
|
__$$AddToOrderImplCopyWithImpl(
|
||||||
|
_$AddToOrderImpl _value, $Res Function(_$AddToOrderImpl) _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? orderId = null,
|
||||||
|
}) {
|
||||||
|
return _then(_$AddToOrderImpl(
|
||||||
|
items: null == items
|
||||||
|
? _value._items
|
||||||
|
: items // ignore: cast_nullable_to_non_nullable
|
||||||
|
as List<ProductQuantity>,
|
||||||
|
orderId: null == orderId
|
||||||
|
? _value.orderId
|
||||||
|
: orderId // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
|
||||||
|
class _$AddToOrderImpl implements _AddToOrder {
|
||||||
|
const _$AddToOrderImpl(
|
||||||
|
{required final List<ProductQuantity> items, required this.orderId})
|
||||||
|
: _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 String orderId;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'OrderFormEvent.addToOrder(items: $items, orderId: $orderId)';
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) {
|
||||||
|
return identical(this, other) ||
|
||||||
|
(other.runtimeType == runtimeType &&
|
||||||
|
other is _$AddToOrderImpl &&
|
||||||
|
const DeepCollectionEquality().equals(other._items, _items) &&
|
||||||
|
(identical(other.orderId, orderId) || other.orderId == orderId));
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode => Object.hash(
|
||||||
|
runtimeType, const DeepCollectionEquality().hash(_items), orderId);
|
||||||
|
|
||||||
|
/// 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')
|
||||||
|
_$$AddToOrderImplCopyWith<_$AddToOrderImpl> get copyWith =>
|
||||||
|
__$$AddToOrderImplCopyWithImpl<_$AddToOrderImpl>(this, _$identity);
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult when<TResult extends Object?>({
|
||||||
|
required TResult Function(Order order) started,
|
||||||
|
required TResult Function(List<ProductQuantity> items, String customerName,
|
||||||
|
OrderType orderType, TableModel table)
|
||||||
|
create,
|
||||||
|
required TResult Function(List<ProductQuantity> items, String customerName,
|
||||||
|
OrderType orderType, TableModel table, PaymentMethod paymentMethod)
|
||||||
|
createWithPayment,
|
||||||
|
required TResult Function(List<ProductQuantity> items, String orderId)
|
||||||
|
addToOrder,
|
||||||
|
required TResult Function(OrderItem item) toggleItem,
|
||||||
|
required TResult Function(bool selectAll) toggleSelectAll,
|
||||||
|
required TResult Function() refund,
|
||||||
|
}) {
|
||||||
|
return addToOrder(items, orderId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult? whenOrNull<TResult extends Object?>({
|
||||||
|
TResult? Function(Order order)? started,
|
||||||
|
TResult? Function(List<ProductQuantity> items, String customerName,
|
||||||
|
OrderType orderType, TableModel table)?
|
||||||
|
create,
|
||||||
|
TResult? Function(List<ProductQuantity> items, String customerName,
|
||||||
|
OrderType orderType, TableModel table, PaymentMethod paymentMethod)?
|
||||||
|
createWithPayment,
|
||||||
|
TResult? Function(List<ProductQuantity> items, String orderId)? addToOrder,
|
||||||
|
TResult? Function(OrderItem item)? toggleItem,
|
||||||
|
TResult? Function(bool selectAll)? toggleSelectAll,
|
||||||
|
TResult? Function()? refund,
|
||||||
|
}) {
|
||||||
|
return addToOrder?.call(items, orderId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult maybeWhen<TResult extends Object?>({
|
||||||
|
TResult Function(Order order)? started,
|
||||||
|
TResult Function(List<ProductQuantity> items, String customerName,
|
||||||
|
OrderType orderType, TableModel table)?
|
||||||
|
create,
|
||||||
|
TResult Function(List<ProductQuantity> items, String customerName,
|
||||||
|
OrderType orderType, TableModel table, PaymentMethod paymentMethod)?
|
||||||
|
createWithPayment,
|
||||||
|
TResult Function(List<ProductQuantity> items, String orderId)? addToOrder,
|
||||||
|
TResult Function(OrderItem item)? toggleItem,
|
||||||
|
TResult Function(bool selectAll)? toggleSelectAll,
|
||||||
|
TResult Function()? refund,
|
||||||
|
required TResult orElse(),
|
||||||
|
}) {
|
||||||
|
if (addToOrder != null) {
|
||||||
|
return addToOrder(items, orderId);
|
||||||
|
}
|
||||||
|
return orElse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult map<TResult extends Object?>({
|
||||||
|
required TResult Function(_Started value) started,
|
||||||
|
required TResult Function(_Create value) create,
|
||||||
|
required TResult Function(_CreateWithPaymentMethod value) createWithPayment,
|
||||||
|
required TResult Function(_AddToOrder value) addToOrder,
|
||||||
|
required TResult Function(_ToggleItem value) toggleItem,
|
||||||
|
required TResult Function(_ToggleSelectAll value) toggleSelectAll,
|
||||||
|
required TResult Function(_Refund value) refund,
|
||||||
|
}) {
|
||||||
|
return addToOrder(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult? mapOrNull<TResult extends Object?>({
|
||||||
|
TResult? Function(_Started value)? started,
|
||||||
|
TResult? Function(_Create value)? create,
|
||||||
|
TResult? Function(_CreateWithPaymentMethod value)? createWithPayment,
|
||||||
|
TResult? Function(_AddToOrder value)? addToOrder,
|
||||||
|
TResult? Function(_ToggleItem value)? toggleItem,
|
||||||
|
TResult? Function(_ToggleSelectAll value)? toggleSelectAll,
|
||||||
|
TResult? Function(_Refund value)? refund,
|
||||||
|
}) {
|
||||||
|
return addToOrder?.call(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult maybeMap<TResult extends Object?>({
|
||||||
|
TResult Function(_Started value)? started,
|
||||||
|
TResult Function(_Create value)? create,
|
||||||
|
TResult Function(_CreateWithPaymentMethod value)? createWithPayment,
|
||||||
|
TResult Function(_AddToOrder value)? addToOrder,
|
||||||
|
TResult Function(_ToggleItem value)? toggleItem,
|
||||||
|
TResult Function(_ToggleSelectAll value)? toggleSelectAll,
|
||||||
|
TResult Function(_Refund value)? refund,
|
||||||
|
required TResult orElse(),
|
||||||
|
}) {
|
||||||
|
if (addToOrder != null) {
|
||||||
|
return addToOrder(this);
|
||||||
|
}
|
||||||
|
return orElse();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class _AddToOrder implements OrderFormEvent {
|
||||||
|
const factory _AddToOrder(
|
||||||
|
{required final List<ProductQuantity> items,
|
||||||
|
required final String orderId}) = _$AddToOrderImpl;
|
||||||
|
|
||||||
|
List<ProductQuantity> get items;
|
||||||
|
String get orderId;
|
||||||
|
|
||||||
|
/// Create a copy of OrderFormEvent
|
||||||
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
|
_$$AddToOrderImplCopyWith<_$AddToOrderImpl> get copyWith =>
|
||||||
|
throw _privateConstructorUsedError;
|
||||||
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
abstract class _$$ToggleItemImplCopyWith<$Res> {
|
abstract class _$$ToggleItemImplCopyWith<$Res> {
|
||||||
factory _$$ToggleItemImplCopyWith(
|
factory _$$ToggleItemImplCopyWith(
|
||||||
@ -843,6 +1074,8 @@ class _$ToggleItemImpl implements _ToggleItem {
|
|||||||
required TResult Function(List<ProductQuantity> items, String customerName,
|
required TResult Function(List<ProductQuantity> items, String customerName,
|
||||||
OrderType orderType, TableModel table, PaymentMethod paymentMethod)
|
OrderType orderType, TableModel table, PaymentMethod paymentMethod)
|
||||||
createWithPayment,
|
createWithPayment,
|
||||||
|
required TResult Function(List<ProductQuantity> items, String orderId)
|
||||||
|
addToOrder,
|
||||||
required TResult Function(OrderItem item) toggleItem,
|
required TResult Function(OrderItem item) toggleItem,
|
||||||
required TResult Function(bool selectAll) toggleSelectAll,
|
required TResult Function(bool selectAll) toggleSelectAll,
|
||||||
required TResult Function() refund,
|
required TResult Function() refund,
|
||||||
@ -860,6 +1093,7 @@ class _$ToggleItemImpl implements _ToggleItem {
|
|||||||
TResult? Function(List<ProductQuantity> items, String customerName,
|
TResult? Function(List<ProductQuantity> items, String customerName,
|
||||||
OrderType orderType, TableModel table, PaymentMethod paymentMethod)?
|
OrderType orderType, TableModel table, PaymentMethod paymentMethod)?
|
||||||
createWithPayment,
|
createWithPayment,
|
||||||
|
TResult? Function(List<ProductQuantity> items, String orderId)? addToOrder,
|
||||||
TResult? Function(OrderItem item)? toggleItem,
|
TResult? Function(OrderItem item)? toggleItem,
|
||||||
TResult? Function(bool selectAll)? toggleSelectAll,
|
TResult? Function(bool selectAll)? toggleSelectAll,
|
||||||
TResult? Function()? refund,
|
TResult? Function()? refund,
|
||||||
@ -877,6 +1111,7 @@ class _$ToggleItemImpl implements _ToggleItem {
|
|||||||
TResult Function(List<ProductQuantity> items, String customerName,
|
TResult Function(List<ProductQuantity> items, String customerName,
|
||||||
OrderType orderType, TableModel table, PaymentMethod paymentMethod)?
|
OrderType orderType, TableModel table, PaymentMethod paymentMethod)?
|
||||||
createWithPayment,
|
createWithPayment,
|
||||||
|
TResult Function(List<ProductQuantity> items, String orderId)? addToOrder,
|
||||||
TResult Function(OrderItem item)? toggleItem,
|
TResult Function(OrderItem item)? toggleItem,
|
||||||
TResult Function(bool selectAll)? toggleSelectAll,
|
TResult Function(bool selectAll)? toggleSelectAll,
|
||||||
TResult Function()? refund,
|
TResult Function()? refund,
|
||||||
@ -894,6 +1129,7 @@ class _$ToggleItemImpl implements _ToggleItem {
|
|||||||
required TResult Function(_Started value) started,
|
required TResult Function(_Started value) started,
|
||||||
required TResult Function(_Create value) create,
|
required TResult Function(_Create value) create,
|
||||||
required TResult Function(_CreateWithPaymentMethod value) createWithPayment,
|
required TResult Function(_CreateWithPaymentMethod value) createWithPayment,
|
||||||
|
required TResult Function(_AddToOrder value) addToOrder,
|
||||||
required TResult Function(_ToggleItem value) toggleItem,
|
required TResult Function(_ToggleItem value) toggleItem,
|
||||||
required TResult Function(_ToggleSelectAll value) toggleSelectAll,
|
required TResult Function(_ToggleSelectAll value) toggleSelectAll,
|
||||||
required TResult Function(_Refund value) refund,
|
required TResult Function(_Refund value) refund,
|
||||||
@ -907,6 +1143,7 @@ class _$ToggleItemImpl implements _ToggleItem {
|
|||||||
TResult? Function(_Started value)? started,
|
TResult? Function(_Started value)? started,
|
||||||
TResult? Function(_Create value)? create,
|
TResult? Function(_Create value)? create,
|
||||||
TResult? Function(_CreateWithPaymentMethod value)? createWithPayment,
|
TResult? Function(_CreateWithPaymentMethod value)? createWithPayment,
|
||||||
|
TResult? Function(_AddToOrder value)? addToOrder,
|
||||||
TResult? Function(_ToggleItem value)? toggleItem,
|
TResult? Function(_ToggleItem value)? toggleItem,
|
||||||
TResult? Function(_ToggleSelectAll value)? toggleSelectAll,
|
TResult? Function(_ToggleSelectAll value)? toggleSelectAll,
|
||||||
TResult? Function(_Refund value)? refund,
|
TResult? Function(_Refund value)? refund,
|
||||||
@ -920,6 +1157,7 @@ class _$ToggleItemImpl implements _ToggleItem {
|
|||||||
TResult Function(_Started value)? started,
|
TResult Function(_Started value)? started,
|
||||||
TResult Function(_Create value)? create,
|
TResult Function(_Create value)? create,
|
||||||
TResult Function(_CreateWithPaymentMethod value)? createWithPayment,
|
TResult Function(_CreateWithPaymentMethod value)? createWithPayment,
|
||||||
|
TResult Function(_AddToOrder value)? addToOrder,
|
||||||
TResult Function(_ToggleItem value)? toggleItem,
|
TResult Function(_ToggleItem value)? toggleItem,
|
||||||
TResult Function(_ToggleSelectAll value)? toggleSelectAll,
|
TResult Function(_ToggleSelectAll value)? toggleSelectAll,
|
||||||
TResult Function(_Refund value)? refund,
|
TResult Function(_Refund value)? refund,
|
||||||
@ -1021,6 +1259,8 @@ class _$ToggleSelectAllImpl implements _ToggleSelectAll {
|
|||||||
required TResult Function(List<ProductQuantity> items, String customerName,
|
required TResult Function(List<ProductQuantity> items, String customerName,
|
||||||
OrderType orderType, TableModel table, PaymentMethod paymentMethod)
|
OrderType orderType, TableModel table, PaymentMethod paymentMethod)
|
||||||
createWithPayment,
|
createWithPayment,
|
||||||
|
required TResult Function(List<ProductQuantity> items, String orderId)
|
||||||
|
addToOrder,
|
||||||
required TResult Function(OrderItem item) toggleItem,
|
required TResult Function(OrderItem item) toggleItem,
|
||||||
required TResult Function(bool selectAll) toggleSelectAll,
|
required TResult Function(bool selectAll) toggleSelectAll,
|
||||||
required TResult Function() refund,
|
required TResult Function() refund,
|
||||||
@ -1038,6 +1278,7 @@ class _$ToggleSelectAllImpl implements _ToggleSelectAll {
|
|||||||
TResult? Function(List<ProductQuantity> items, String customerName,
|
TResult? Function(List<ProductQuantity> items, String customerName,
|
||||||
OrderType orderType, TableModel table, PaymentMethod paymentMethod)?
|
OrderType orderType, TableModel table, PaymentMethod paymentMethod)?
|
||||||
createWithPayment,
|
createWithPayment,
|
||||||
|
TResult? Function(List<ProductQuantity> items, String orderId)? addToOrder,
|
||||||
TResult? Function(OrderItem item)? toggleItem,
|
TResult? Function(OrderItem item)? toggleItem,
|
||||||
TResult? Function(bool selectAll)? toggleSelectAll,
|
TResult? Function(bool selectAll)? toggleSelectAll,
|
||||||
TResult? Function()? refund,
|
TResult? Function()? refund,
|
||||||
@ -1055,6 +1296,7 @@ class _$ToggleSelectAllImpl implements _ToggleSelectAll {
|
|||||||
TResult Function(List<ProductQuantity> items, String customerName,
|
TResult Function(List<ProductQuantity> items, String customerName,
|
||||||
OrderType orderType, TableModel table, PaymentMethod paymentMethod)?
|
OrderType orderType, TableModel table, PaymentMethod paymentMethod)?
|
||||||
createWithPayment,
|
createWithPayment,
|
||||||
|
TResult Function(List<ProductQuantity> items, String orderId)? addToOrder,
|
||||||
TResult Function(OrderItem item)? toggleItem,
|
TResult Function(OrderItem item)? toggleItem,
|
||||||
TResult Function(bool selectAll)? toggleSelectAll,
|
TResult Function(bool selectAll)? toggleSelectAll,
|
||||||
TResult Function()? refund,
|
TResult Function()? refund,
|
||||||
@ -1072,6 +1314,7 @@ class _$ToggleSelectAllImpl implements _ToggleSelectAll {
|
|||||||
required TResult Function(_Started value) started,
|
required TResult Function(_Started value) started,
|
||||||
required TResult Function(_Create value) create,
|
required TResult Function(_Create value) create,
|
||||||
required TResult Function(_CreateWithPaymentMethod value) createWithPayment,
|
required TResult Function(_CreateWithPaymentMethod value) createWithPayment,
|
||||||
|
required TResult Function(_AddToOrder value) addToOrder,
|
||||||
required TResult Function(_ToggleItem value) toggleItem,
|
required TResult Function(_ToggleItem value) toggleItem,
|
||||||
required TResult Function(_ToggleSelectAll value) toggleSelectAll,
|
required TResult Function(_ToggleSelectAll value) toggleSelectAll,
|
||||||
required TResult Function(_Refund value) refund,
|
required TResult Function(_Refund value) refund,
|
||||||
@ -1085,6 +1328,7 @@ class _$ToggleSelectAllImpl implements _ToggleSelectAll {
|
|||||||
TResult? Function(_Started value)? started,
|
TResult? Function(_Started value)? started,
|
||||||
TResult? Function(_Create value)? create,
|
TResult? Function(_Create value)? create,
|
||||||
TResult? Function(_CreateWithPaymentMethod value)? createWithPayment,
|
TResult? Function(_CreateWithPaymentMethod value)? createWithPayment,
|
||||||
|
TResult? Function(_AddToOrder value)? addToOrder,
|
||||||
TResult? Function(_ToggleItem value)? toggleItem,
|
TResult? Function(_ToggleItem value)? toggleItem,
|
||||||
TResult? Function(_ToggleSelectAll value)? toggleSelectAll,
|
TResult? Function(_ToggleSelectAll value)? toggleSelectAll,
|
||||||
TResult? Function(_Refund value)? refund,
|
TResult? Function(_Refund value)? refund,
|
||||||
@ -1098,6 +1342,7 @@ class _$ToggleSelectAllImpl implements _ToggleSelectAll {
|
|||||||
TResult Function(_Started value)? started,
|
TResult Function(_Started value)? started,
|
||||||
TResult Function(_Create value)? create,
|
TResult Function(_Create value)? create,
|
||||||
TResult Function(_CreateWithPaymentMethod value)? createWithPayment,
|
TResult Function(_CreateWithPaymentMethod value)? createWithPayment,
|
||||||
|
TResult Function(_AddToOrder value)? addToOrder,
|
||||||
TResult Function(_ToggleItem value)? toggleItem,
|
TResult Function(_ToggleItem value)? toggleItem,
|
||||||
TResult Function(_ToggleSelectAll value)? toggleSelectAll,
|
TResult Function(_ToggleSelectAll value)? toggleSelectAll,
|
||||||
TResult Function(_Refund value)? refund,
|
TResult Function(_Refund value)? refund,
|
||||||
@ -1170,6 +1415,8 @@ class _$RefundImpl implements _Refund {
|
|||||||
required TResult Function(List<ProductQuantity> items, String customerName,
|
required TResult Function(List<ProductQuantity> items, String customerName,
|
||||||
OrderType orderType, TableModel table, PaymentMethod paymentMethod)
|
OrderType orderType, TableModel table, PaymentMethod paymentMethod)
|
||||||
createWithPayment,
|
createWithPayment,
|
||||||
|
required TResult Function(List<ProductQuantity> items, String orderId)
|
||||||
|
addToOrder,
|
||||||
required TResult Function(OrderItem item) toggleItem,
|
required TResult Function(OrderItem item) toggleItem,
|
||||||
required TResult Function(bool selectAll) toggleSelectAll,
|
required TResult Function(bool selectAll) toggleSelectAll,
|
||||||
required TResult Function() refund,
|
required TResult Function() refund,
|
||||||
@ -1187,6 +1434,7 @@ class _$RefundImpl implements _Refund {
|
|||||||
TResult? Function(List<ProductQuantity> items, String customerName,
|
TResult? Function(List<ProductQuantity> items, String customerName,
|
||||||
OrderType orderType, TableModel table, PaymentMethod paymentMethod)?
|
OrderType orderType, TableModel table, PaymentMethod paymentMethod)?
|
||||||
createWithPayment,
|
createWithPayment,
|
||||||
|
TResult? Function(List<ProductQuantity> items, String orderId)? addToOrder,
|
||||||
TResult? Function(OrderItem item)? toggleItem,
|
TResult? Function(OrderItem item)? toggleItem,
|
||||||
TResult? Function(bool selectAll)? toggleSelectAll,
|
TResult? Function(bool selectAll)? toggleSelectAll,
|
||||||
TResult? Function()? refund,
|
TResult? Function()? refund,
|
||||||
@ -1204,6 +1452,7 @@ class _$RefundImpl implements _Refund {
|
|||||||
TResult Function(List<ProductQuantity> items, String customerName,
|
TResult Function(List<ProductQuantity> items, String customerName,
|
||||||
OrderType orderType, TableModel table, PaymentMethod paymentMethod)?
|
OrderType orderType, TableModel table, PaymentMethod paymentMethod)?
|
||||||
createWithPayment,
|
createWithPayment,
|
||||||
|
TResult Function(List<ProductQuantity> items, String orderId)? addToOrder,
|
||||||
TResult Function(OrderItem item)? toggleItem,
|
TResult Function(OrderItem item)? toggleItem,
|
||||||
TResult Function(bool selectAll)? toggleSelectAll,
|
TResult Function(bool selectAll)? toggleSelectAll,
|
||||||
TResult Function()? refund,
|
TResult Function()? refund,
|
||||||
@ -1221,6 +1470,7 @@ class _$RefundImpl implements _Refund {
|
|||||||
required TResult Function(_Started value) started,
|
required TResult Function(_Started value) started,
|
||||||
required TResult Function(_Create value) create,
|
required TResult Function(_Create value) create,
|
||||||
required TResult Function(_CreateWithPaymentMethod value) createWithPayment,
|
required TResult Function(_CreateWithPaymentMethod value) createWithPayment,
|
||||||
|
required TResult Function(_AddToOrder value) addToOrder,
|
||||||
required TResult Function(_ToggleItem value) toggleItem,
|
required TResult Function(_ToggleItem value) toggleItem,
|
||||||
required TResult Function(_ToggleSelectAll value) toggleSelectAll,
|
required TResult Function(_ToggleSelectAll value) toggleSelectAll,
|
||||||
required TResult Function(_Refund value) refund,
|
required TResult Function(_Refund value) refund,
|
||||||
@ -1234,6 +1484,7 @@ class _$RefundImpl implements _Refund {
|
|||||||
TResult? Function(_Started value)? started,
|
TResult? Function(_Started value)? started,
|
||||||
TResult? Function(_Create value)? create,
|
TResult? Function(_Create value)? create,
|
||||||
TResult? Function(_CreateWithPaymentMethod value)? createWithPayment,
|
TResult? Function(_CreateWithPaymentMethod value)? createWithPayment,
|
||||||
|
TResult? Function(_AddToOrder value)? addToOrder,
|
||||||
TResult? Function(_ToggleItem value)? toggleItem,
|
TResult? Function(_ToggleItem value)? toggleItem,
|
||||||
TResult? Function(_ToggleSelectAll value)? toggleSelectAll,
|
TResult? Function(_ToggleSelectAll value)? toggleSelectAll,
|
||||||
TResult? Function(_Refund value)? refund,
|
TResult? Function(_Refund value)? refund,
|
||||||
@ -1247,6 +1498,7 @@ class _$RefundImpl implements _Refund {
|
|||||||
TResult Function(_Started value)? started,
|
TResult Function(_Started value)? started,
|
||||||
TResult Function(_Create value)? create,
|
TResult Function(_Create value)? create,
|
||||||
TResult Function(_CreateWithPaymentMethod value)? createWithPayment,
|
TResult Function(_CreateWithPaymentMethod value)? createWithPayment,
|
||||||
|
TResult Function(_AddToOrder value)? addToOrder,
|
||||||
TResult Function(_ToggleItem value)? toggleItem,
|
TResult Function(_ToggleItem value)? toggleItem,
|
||||||
TResult Function(_ToggleSelectAll value)? toggleSelectAll,
|
TResult Function(_ToggleSelectAll value)? toggleSelectAll,
|
||||||
TResult Function(_Refund value)? refund,
|
TResult Function(_Refund value)? refund,
|
||||||
|
|||||||
@ -16,6 +16,10 @@ class OrderFormEvent with _$OrderFormEvent {
|
|||||||
required TableModel table,
|
required TableModel table,
|
||||||
required PaymentMethod paymentMethod,
|
required PaymentMethod paymentMethod,
|
||||||
}) = _CreateWithPaymentMethod;
|
}) = _CreateWithPaymentMethod;
|
||||||
|
const factory OrderFormEvent.addToOrder({
|
||||||
|
required List<ProductQuantity> items,
|
||||||
|
required String orderId,
|
||||||
|
}) = _AddToOrder;
|
||||||
const factory OrderFormEvent.toggleItem(OrderItem item) = _ToggleItem;
|
const factory OrderFormEvent.toggleItem(OrderItem item) = _ToggleItem;
|
||||||
const factory OrderFormEvent.toggleSelectAll(bool selectAll) =
|
const factory OrderFormEvent.toggleSelectAll(bool selectAll) =
|
||||||
_ToggleSelectAll;
|
_ToggleSelectAll;
|
||||||
|
|||||||
@ -1,28 +1,41 @@
|
|||||||
import 'package:enaklo_pos/core/components/buttons.dart';
|
import 'package:enaklo_pos/core/components/buttons.dart';
|
||||||
import 'package:enaklo_pos/core/components/custom_modal_dialog.dart';
|
import 'package:enaklo_pos/core/components/custom_modal_dialog.dart';
|
||||||
|
import 'package:enaklo_pos/core/components/flushbar.dart';
|
||||||
import 'package:enaklo_pos/core/components/spaces.dart';
|
import 'package:enaklo_pos/core/components/spaces.dart';
|
||||||
import 'package:enaklo_pos/core/constants/colors.dart';
|
import 'package:enaklo_pos/core/constants/colors.dart';
|
||||||
import 'package:enaklo_pos/core/extensions/build_context_ext.dart';
|
import 'package:enaklo_pos/core/extensions/build_context_ext.dart';
|
||||||
import 'package:enaklo_pos/data/models/response/table_model.dart';
|
import 'package:enaklo_pos/data/models/response/order_response_model.dart';
|
||||||
import 'package:enaklo_pos/presentation/home/bloc/get_table_status/get_table_status_bloc.dart';
|
import 'package:enaklo_pos/presentation/home/bloc/order_form/order_form_bloc.dart';
|
||||||
|
import 'package:enaklo_pos/presentation/home/models/product_quantity.dart';
|
||||||
|
import 'package:enaklo_pos/presentation/sales/blocs/order_loader/order_loader_bloc.dart';
|
||||||
|
import 'package:enaklo_pos/presentation/success/pages/success_save_order_page.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
|
||||||
class PaymentAddOrderDialog extends StatefulWidget {
|
class PaymentAddOrderDialog extends StatefulWidget {
|
||||||
const PaymentAddOrderDialog({super.key});
|
final List<ProductQuantity> items;
|
||||||
|
const PaymentAddOrderDialog({super.key, required this.items});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<PaymentAddOrderDialog> createState() => _PaymentAddOrderDialogState();
|
State<PaymentAddOrderDialog> createState() => _PaymentAddOrderDialogState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _PaymentAddOrderDialogState extends State<PaymentAddOrderDialog> {
|
class _PaymentAddOrderDialogState extends State<PaymentAddOrderDialog> {
|
||||||
TableModel? selectTable;
|
Order? selectOrder;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
context
|
||||||
|
.read<OrderLoaderBloc>()
|
||||||
|
.add(OrderLoaderEvent.getByStatus('pending'));
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return CustomModalDialog(
|
return CustomModalDialog(
|
||||||
title: 'Tambah Pesanan',
|
title: 'Bayar Nanti',
|
||||||
subtitle: 'Silahkan tambahkan pesanan',
|
subtitle: 'Simpan pesanan dan bayar nanti',
|
||||||
contentPadding:
|
contentPadding:
|
||||||
const EdgeInsets.symmetric(horizontal: 16.0, vertical: 24.0),
|
const EdgeInsets.symmetric(horizontal: 16.0, vertical: 24.0),
|
||||||
minWidth: context.deviceWidth * 0.4,
|
minWidth: context.deviceWidth * 0.4,
|
||||||
@ -34,28 +47,44 @@ class _PaymentAddOrderDialogState extends State<PaymentAddOrderDialog> {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
const Text(
|
const Text(
|
||||||
'Pilih Meja yang Sudah Ada Pesanan',
|
'Pilih Meja yang sudah dipesan',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: AppColors.black,
|
color: AppColors.black,
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w600,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SpaceHeight(12.0),
|
const SpaceHeight(6.0),
|
||||||
BlocBuilder<GetTableStatusBloc, GetTableStatusState>(
|
BlocBuilder<OrderLoaderBloc, OrderLoaderState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
return state.maybeWhen(
|
return state.maybeWhen(
|
||||||
orElse: () => const CircularProgressIndicator(),
|
orElse: () =>
|
||||||
success: (tables) {
|
Center(child: const CircularProgressIndicator()),
|
||||||
print(
|
loading: () =>
|
||||||
"🔘 Add to Order - Tables fetched: ${tables.length} tables");
|
Center(child: const CircularProgressIndicator()),
|
||||||
print(
|
loaded: (orders, totalOrder) {
|
||||||
"🔘 Add to Order - Table statuses: ${tables.map((t) => '${t.tableName}: ${t.status}').join(', ')}");
|
final availableOrders = orders;
|
||||||
// No need to filter since we're fetching occupied tables directly
|
|
||||||
final occupiedTables = tables;
|
|
||||||
|
|
||||||
if (selectTable == null && occupiedTables.isNotEmpty) {
|
if (selectOrder == null && availableOrders.isNotEmpty) {
|
||||||
selectTable = occupiedTables.first;
|
selectOrder = availableOrders.first;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (availableOrders.isEmpty) {
|
||||||
|
return Container(
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.orange[50],
|
||||||
|
borderRadius: BorderRadius.circular(16),
|
||||||
|
border: Border.all(
|
||||||
|
color: Colors.orange,
|
||||||
|
width: 1,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: const Text(
|
||||||
|
'Tidak ada meja yang tersedia. Silakan pilih opsi lain.',
|
||||||
|
style: TextStyle(color: Colors.orange),
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Container(
|
return Container(
|
||||||
@ -69,20 +98,24 @@ class _PaymentAddOrderDialogState extends State<PaymentAddOrderDialog> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: DropdownButtonHideUnderline(
|
child: DropdownButtonHideUnderline(
|
||||||
child: DropdownButton<TableModel>(
|
child: DropdownButton<Order>(
|
||||||
isExpanded: true,
|
isExpanded: true,
|
||||||
value: selectTable,
|
value: availableOrders.firstWhere(
|
||||||
onChanged: (TableModel? newValue) {
|
(t) => t.id == selectOrder?.id,
|
||||||
|
orElse: () => availableOrders.first,
|
||||||
|
),
|
||||||
|
onChanged: (Order? newValue) {
|
||||||
setState(() {
|
setState(() {
|
||||||
selectTable = newValue;
|
selectOrder = newValue;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
items: occupiedTables
|
items: availableOrders
|
||||||
.map<DropdownMenuItem<TableModel>>(
|
.map<DropdownMenuItem<Order>>(
|
||||||
(TableModel value) =>
|
(Order value) => DropdownMenuItem<Order>(
|
||||||
DropdownMenuItem<TableModel>(
|
|
||||||
value: value,
|
value: value,
|
||||||
child: Text('${value.tableName} (Occupied)'),
|
child: Text(
|
||||||
|
"${value.tableNumber ?? ""} - ${value.metadata?['customer_name'] ?? ""}",
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.toList(),
|
.toList(),
|
||||||
@ -95,10 +128,39 @@ class _PaymentAddOrderDialogState extends State<PaymentAddOrderDialog> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
SpaceHeight(24),
|
SpaceHeight(24),
|
||||||
Button.filled(
|
BlocListener<OrderFormBloc, OrderFormState>(
|
||||||
onPressed: () {},
|
listener: (context, state) {
|
||||||
|
state.maybeWhen(
|
||||||
|
orElse: () {},
|
||||||
|
success: (data) {
|
||||||
|
context.pushReplacement(SuccessSaveOrderPage(
|
||||||
|
order: data,
|
||||||
|
));
|
||||||
|
},
|
||||||
|
error: (message) => AppFlushbar.showError(context, message),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child: BlocBuilder<OrderFormBloc, OrderFormState>(
|
||||||
|
builder: (context, state) {
|
||||||
|
return state.maybeWhen(
|
||||||
|
orElse: () => Button.filled(
|
||||||
|
onPressed: () {
|
||||||
|
context
|
||||||
|
.read<OrderFormBloc>()
|
||||||
|
.add(OrderFormEvent.addToOrder(
|
||||||
|
items: widget.items,
|
||||||
|
orderId: selectOrder?.id ?? "",
|
||||||
|
));
|
||||||
|
},
|
||||||
label: "Simpan",
|
label: "Simpan",
|
||||||
),
|
),
|
||||||
|
loading: () => Center(
|
||||||
|
child: const CircularProgressIndicator(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@ -58,7 +58,9 @@ class _SaveDialogState extends State<SaveDialog> {
|
|||||||
subtitle: 'Tambah item ke daftar pesanan',
|
subtitle: 'Tambah item ke daftar pesanan',
|
||||||
onTap: () => showDialog(
|
onTap: () => showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) => const PaymentAddOrderDialog(),
|
builder: (context) => PaymentAddOrderDialog(
|
||||||
|
items: widget.items,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user