feat: update success order
This commit is contained in:
parent
00cd5bbeb8
commit
cd071db0cb
@ -302,6 +302,38 @@ class OrderRemoteDatasource {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<Either<String, OrderDetailResponseModel>> getOrderById(
|
||||||
|
{required String orderId}) async {
|
||||||
|
try {
|
||||||
|
final authData = await AuthLocalDataSource().getAuthData();
|
||||||
|
final response = await dio.get(
|
||||||
|
'${Variables.baseUrl}/api/v1/orders/$orderId',
|
||||||
|
options: Options(
|
||||||
|
headers: {
|
||||||
|
'Authorization': 'Bearer ${authData.token}',
|
||||||
|
'Accept': 'application/json',
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
if (response.statusCode == 200) {
|
||||||
|
return Right(OrderDetailResponseModel.fromMap(response.data));
|
||||||
|
} else {
|
||||||
|
log("❌ OrderDetailResponseModel API call failed - Status: ${response.statusCode}");
|
||||||
|
return const Left("Failed Load Data");
|
||||||
|
}
|
||||||
|
} on DioException catch (e) {
|
||||||
|
final errorMessage = 'Something went wrong';
|
||||||
|
log("💥 Dio error: ${e.message}");
|
||||||
|
log("💥 Dio response: ${e.response?.data}");
|
||||||
|
return Left(errorMessage);
|
||||||
|
} catch (e) {
|
||||||
|
log("💥 Unexpected error: $e");
|
||||||
|
return Left("Unexpected Error: $e");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Future<Either<String, OrderDetailResponseModel>> createOrderWithPayment(
|
Future<Either<String, OrderDetailResponseModel>> createOrderWithPayment(
|
||||||
OrderRequestModel orderModel,
|
OrderRequestModel orderModel,
|
||||||
PaymentMethod payment,
|
PaymentMethod payment,
|
||||||
|
|||||||
@ -136,7 +136,7 @@ class _PaymentAddOrderDialogState extends State<PaymentAddOrderDialog> {
|
|||||||
context.pushReplacement(
|
context.pushReplacement(
|
||||||
SuccessSaveOrderPage(
|
SuccessSaveOrderPage(
|
||||||
productQuantity: widget.items,
|
productQuantity: widget.items,
|
||||||
order: data,
|
orderId: selectOrder?.id ?? "",
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
@ -146,7 +146,7 @@ class _PaymentSaveDialogState extends State<PaymentSaveDialog> {
|
|||||||
success: (data) {
|
success: (data) {
|
||||||
context.pushReplacement(SuccessSaveOrderPage(
|
context.pushReplacement(SuccessSaveOrderPage(
|
||||||
productQuantity: widget.items,
|
productQuantity: widget.items,
|
||||||
order: data,
|
orderId: data.id ?? "",
|
||||||
));
|
));
|
||||||
},
|
},
|
||||||
error: (message) => AppFlushbar.showError(context, message),
|
error: (message) => AppFlushbar.showError(context, message),
|
||||||
|
|||||||
@ -1,7 +1,5 @@
|
|||||||
import 'package:enaklo_pos/data/models/response/product_response_model.dart';
|
import 'package:enaklo_pos/data/models/response/product_response_model.dart';
|
||||||
|
|
||||||
import 'product_model.dart';
|
|
||||||
|
|
||||||
class OrderItem {
|
class OrderItem {
|
||||||
final Product product;
|
final Product product;
|
||||||
int quantity;
|
int quantity;
|
||||||
|
|||||||
@ -23,5 +23,14 @@ class OrderLoaderBloc extends Bloc<OrderLoaderEvent, OrderLoaderState> {
|
|||||||
)),
|
)),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
on<_GetById>((event, emit) async {
|
||||||
|
emit(const _Loading());
|
||||||
|
final result =
|
||||||
|
await _orderRemoteDatasource.getOrderById(orderId: event.id);
|
||||||
|
result.fold(
|
||||||
|
(l) => emit(_Error(l)),
|
||||||
|
(r) => emit(_LoadedDetail(r.data!)),
|
||||||
|
);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,45 +16,44 @@ final _privateConstructorUsedError = UnsupportedError(
|
|||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
mixin _$OrderLoaderEvent {
|
mixin _$OrderLoaderEvent {
|
||||||
String get status => throw _privateConstructorUsedError;
|
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult when<TResult extends Object?>({
|
TResult when<TResult extends Object?>({
|
||||||
required TResult Function(String status) getByStatus,
|
required TResult Function(String status) getByStatus,
|
||||||
|
required TResult Function(String id) getById,
|
||||||
}) =>
|
}) =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult? whenOrNull<TResult extends Object?>({
|
TResult? whenOrNull<TResult extends Object?>({
|
||||||
TResult? Function(String status)? getByStatus,
|
TResult? Function(String status)? getByStatus,
|
||||||
|
TResult? Function(String id)? getById,
|
||||||
}) =>
|
}) =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
TResult maybeWhen<TResult extends Object?>({
|
||||||
TResult Function(String status)? getByStatus,
|
TResult Function(String status)? getByStatus,
|
||||||
|
TResult Function(String id)? getById,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) =>
|
}) =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult map<TResult extends Object?>({
|
TResult map<TResult extends Object?>({
|
||||||
required TResult Function(_GetByStatus value) getByStatus,
|
required TResult Function(_GetByStatus value) getByStatus,
|
||||||
|
required TResult Function(_GetById value) getById,
|
||||||
}) =>
|
}) =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult? mapOrNull<TResult extends Object?>({
|
TResult? mapOrNull<TResult extends Object?>({
|
||||||
TResult? Function(_GetByStatus value)? getByStatus,
|
TResult? Function(_GetByStatus value)? getByStatus,
|
||||||
|
TResult? Function(_GetById value)? getById,
|
||||||
}) =>
|
}) =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult maybeMap<TResult extends Object?>({
|
TResult maybeMap<TResult extends Object?>({
|
||||||
TResult Function(_GetByStatus value)? getByStatus,
|
TResult Function(_GetByStatus value)? getByStatus,
|
||||||
|
TResult Function(_GetById value)? getById,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) =>
|
}) =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
|
|
||||||
/// Create a copy of OrderLoaderEvent
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
||||||
$OrderLoaderEventCopyWith<OrderLoaderEvent> get copyWith =>
|
|
||||||
throw _privateConstructorUsedError;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
@ -62,8 +61,6 @@ abstract class $OrderLoaderEventCopyWith<$Res> {
|
|||||||
factory $OrderLoaderEventCopyWith(
|
factory $OrderLoaderEventCopyWith(
|
||||||
OrderLoaderEvent value, $Res Function(OrderLoaderEvent) then) =
|
OrderLoaderEvent value, $Res Function(OrderLoaderEvent) then) =
|
||||||
_$OrderLoaderEventCopyWithImpl<$Res, OrderLoaderEvent>;
|
_$OrderLoaderEventCopyWithImpl<$Res, OrderLoaderEvent>;
|
||||||
@useResult
|
|
||||||
$Res call({String status});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
@ -78,27 +75,13 @@ class _$OrderLoaderEventCopyWithImpl<$Res, $Val extends OrderLoaderEvent>
|
|||||||
|
|
||||||
/// Create a copy of OrderLoaderEvent
|
/// Create a copy of OrderLoaderEvent
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
@override
|
|
||||||
$Res call({
|
|
||||||
Object? status = null,
|
|
||||||
}) {
|
|
||||||
return _then(_value.copyWith(
|
|
||||||
status: null == status
|
|
||||||
? _value.status
|
|
||||||
: status // ignore: cast_nullable_to_non_nullable
|
|
||||||
as String,
|
|
||||||
) as $Val);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
abstract class _$$GetByStatusImplCopyWith<$Res>
|
abstract class _$$GetByStatusImplCopyWith<$Res> {
|
||||||
implements $OrderLoaderEventCopyWith<$Res> {
|
|
||||||
factory _$$GetByStatusImplCopyWith(
|
factory _$$GetByStatusImplCopyWith(
|
||||||
_$GetByStatusImpl value, $Res Function(_$GetByStatusImpl) then) =
|
_$GetByStatusImpl value, $Res Function(_$GetByStatusImpl) then) =
|
||||||
__$$GetByStatusImplCopyWithImpl<$Res>;
|
__$$GetByStatusImplCopyWithImpl<$Res>;
|
||||||
@override
|
|
||||||
@useResult
|
@useResult
|
||||||
$Res call({String status});
|
$Res call({String status});
|
||||||
}
|
}
|
||||||
@ -163,6 +146,7 @@ class _$GetByStatusImpl implements _GetByStatus {
|
|||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult when<TResult extends Object?>({
|
TResult when<TResult extends Object?>({
|
||||||
required TResult Function(String status) getByStatus,
|
required TResult Function(String status) getByStatus,
|
||||||
|
required TResult Function(String id) getById,
|
||||||
}) {
|
}) {
|
||||||
return getByStatus(status);
|
return getByStatus(status);
|
||||||
}
|
}
|
||||||
@ -171,6 +155,7 @@ class _$GetByStatusImpl implements _GetByStatus {
|
|||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult? whenOrNull<TResult extends Object?>({
|
TResult? whenOrNull<TResult extends Object?>({
|
||||||
TResult? Function(String status)? getByStatus,
|
TResult? Function(String status)? getByStatus,
|
||||||
|
TResult? Function(String id)? getById,
|
||||||
}) {
|
}) {
|
||||||
return getByStatus?.call(status);
|
return getByStatus?.call(status);
|
||||||
}
|
}
|
||||||
@ -179,6 +164,7 @@ class _$GetByStatusImpl implements _GetByStatus {
|
|||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
TResult maybeWhen<TResult extends Object?>({
|
||||||
TResult Function(String status)? getByStatus,
|
TResult Function(String status)? getByStatus,
|
||||||
|
TResult Function(String id)? getById,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) {
|
}) {
|
||||||
if (getByStatus != null) {
|
if (getByStatus != null) {
|
||||||
@ -191,6 +177,7 @@ class _$GetByStatusImpl implements _GetByStatus {
|
|||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult map<TResult extends Object?>({
|
TResult map<TResult extends Object?>({
|
||||||
required TResult Function(_GetByStatus value) getByStatus,
|
required TResult Function(_GetByStatus value) getByStatus,
|
||||||
|
required TResult Function(_GetById value) getById,
|
||||||
}) {
|
}) {
|
||||||
return getByStatus(this);
|
return getByStatus(this);
|
||||||
}
|
}
|
||||||
@ -199,6 +186,7 @@ class _$GetByStatusImpl implements _GetByStatus {
|
|||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult? mapOrNull<TResult extends Object?>({
|
TResult? mapOrNull<TResult extends Object?>({
|
||||||
TResult? Function(_GetByStatus value)? getByStatus,
|
TResult? Function(_GetByStatus value)? getByStatus,
|
||||||
|
TResult? Function(_GetById value)? getById,
|
||||||
}) {
|
}) {
|
||||||
return getByStatus?.call(this);
|
return getByStatus?.call(this);
|
||||||
}
|
}
|
||||||
@ -207,6 +195,7 @@ class _$GetByStatusImpl implements _GetByStatus {
|
|||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult maybeMap<TResult extends Object?>({
|
TResult maybeMap<TResult extends Object?>({
|
||||||
TResult Function(_GetByStatus value)? getByStatus,
|
TResult Function(_GetByStatus value)? getByStatus,
|
||||||
|
TResult Function(_GetById value)? getById,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) {
|
}) {
|
||||||
if (getByStatus != null) {
|
if (getByStatus != null) {
|
||||||
@ -219,17 +208,155 @@ class _$GetByStatusImpl implements _GetByStatus {
|
|||||||
abstract class _GetByStatus implements OrderLoaderEvent {
|
abstract class _GetByStatus implements OrderLoaderEvent {
|
||||||
const factory _GetByStatus(final String status) = _$GetByStatusImpl;
|
const factory _GetByStatus(final String status) = _$GetByStatusImpl;
|
||||||
|
|
||||||
@override
|
|
||||||
String get status;
|
String get status;
|
||||||
|
|
||||||
/// Create a copy of OrderLoaderEvent
|
/// Create a copy of OrderLoaderEvent
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@override
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
_$$GetByStatusImplCopyWith<_$GetByStatusImpl> get copyWith =>
|
_$$GetByStatusImplCopyWith<_$GetByStatusImpl> get copyWith =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
abstract class _$$GetByIdImplCopyWith<$Res> {
|
||||||
|
factory _$$GetByIdImplCopyWith(
|
||||||
|
_$GetByIdImpl value, $Res Function(_$GetByIdImpl) then) =
|
||||||
|
__$$GetByIdImplCopyWithImpl<$Res>;
|
||||||
|
@useResult
|
||||||
|
$Res call({String id});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
class __$$GetByIdImplCopyWithImpl<$Res>
|
||||||
|
extends _$OrderLoaderEventCopyWithImpl<$Res, _$GetByIdImpl>
|
||||||
|
implements _$$GetByIdImplCopyWith<$Res> {
|
||||||
|
__$$GetByIdImplCopyWithImpl(
|
||||||
|
_$GetByIdImpl _value, $Res Function(_$GetByIdImpl) _then)
|
||||||
|
: super(_value, _then);
|
||||||
|
|
||||||
|
/// Create a copy of OrderLoaderEvent
|
||||||
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
@override
|
||||||
|
$Res call({
|
||||||
|
Object? id = null,
|
||||||
|
}) {
|
||||||
|
return _then(_$GetByIdImpl(
|
||||||
|
null == id
|
||||||
|
? _value.id
|
||||||
|
: id // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
|
||||||
|
class _$GetByIdImpl implements _GetById {
|
||||||
|
const _$GetByIdImpl(this.id);
|
||||||
|
|
||||||
|
@override
|
||||||
|
final String id;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'OrderLoaderEvent.getById(id: $id)';
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) {
|
||||||
|
return identical(this, other) ||
|
||||||
|
(other.runtimeType == runtimeType &&
|
||||||
|
other is _$GetByIdImpl &&
|
||||||
|
(identical(other.id, id) || other.id == id));
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode => Object.hash(runtimeType, id);
|
||||||
|
|
||||||
|
/// Create a copy of OrderLoaderEvent
|
||||||
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
|
@override
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
_$$GetByIdImplCopyWith<_$GetByIdImpl> get copyWith =>
|
||||||
|
__$$GetByIdImplCopyWithImpl<_$GetByIdImpl>(this, _$identity);
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult when<TResult extends Object?>({
|
||||||
|
required TResult Function(String status) getByStatus,
|
||||||
|
required TResult Function(String id) getById,
|
||||||
|
}) {
|
||||||
|
return getById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult? whenOrNull<TResult extends Object?>({
|
||||||
|
TResult? Function(String status)? getByStatus,
|
||||||
|
TResult? Function(String id)? getById,
|
||||||
|
}) {
|
||||||
|
return getById?.call(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult maybeWhen<TResult extends Object?>({
|
||||||
|
TResult Function(String status)? getByStatus,
|
||||||
|
TResult Function(String id)? getById,
|
||||||
|
required TResult orElse(),
|
||||||
|
}) {
|
||||||
|
if (getById != null) {
|
||||||
|
return getById(id);
|
||||||
|
}
|
||||||
|
return orElse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult map<TResult extends Object?>({
|
||||||
|
required TResult Function(_GetByStatus value) getByStatus,
|
||||||
|
required TResult Function(_GetById value) getById,
|
||||||
|
}) {
|
||||||
|
return getById(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult? mapOrNull<TResult extends Object?>({
|
||||||
|
TResult? Function(_GetByStatus value)? getByStatus,
|
||||||
|
TResult? Function(_GetById value)? getById,
|
||||||
|
}) {
|
||||||
|
return getById?.call(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult maybeMap<TResult extends Object?>({
|
||||||
|
TResult Function(_GetByStatus value)? getByStatus,
|
||||||
|
TResult Function(_GetById value)? getById,
|
||||||
|
required TResult orElse(),
|
||||||
|
}) {
|
||||||
|
if (getById != null) {
|
||||||
|
return getById(this);
|
||||||
|
}
|
||||||
|
return orElse();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class _GetById implements OrderLoaderEvent {
|
||||||
|
const factory _GetById(final String id) = _$GetByIdImpl;
|
||||||
|
|
||||||
|
String get id;
|
||||||
|
|
||||||
|
/// Create a copy of OrderLoaderEvent
|
||||||
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
|
_$$GetByIdImplCopyWith<_$GetByIdImpl> get copyWith =>
|
||||||
|
throw _privateConstructorUsedError;
|
||||||
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
mixin _$OrderLoaderState {
|
mixin _$OrderLoaderState {
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
@ -238,6 +365,7 @@ mixin _$OrderLoaderState {
|
|||||||
required TResult Function() loading,
|
required TResult Function() loading,
|
||||||
required TResult Function(List<Order> orders, int totalOrder) loaded,
|
required TResult Function(List<Order> orders, int totalOrder) loaded,
|
||||||
required TResult Function(String message) error,
|
required TResult Function(String message) error,
|
||||||
|
required TResult Function(Order order) loadedDetail,
|
||||||
}) =>
|
}) =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
@ -246,6 +374,7 @@ mixin _$OrderLoaderState {
|
|||||||
TResult? Function()? loading,
|
TResult? Function()? loading,
|
||||||
TResult? Function(List<Order> orders, int totalOrder)? loaded,
|
TResult? Function(List<Order> orders, int totalOrder)? loaded,
|
||||||
TResult? Function(String message)? error,
|
TResult? Function(String message)? error,
|
||||||
|
TResult? Function(Order order)? loadedDetail,
|
||||||
}) =>
|
}) =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
@ -254,6 +383,7 @@ mixin _$OrderLoaderState {
|
|||||||
TResult Function()? loading,
|
TResult Function()? loading,
|
||||||
TResult Function(List<Order> orders, int totalOrder)? loaded,
|
TResult Function(List<Order> orders, int totalOrder)? loaded,
|
||||||
TResult Function(String message)? error,
|
TResult Function(String message)? error,
|
||||||
|
TResult Function(Order order)? loadedDetail,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) =>
|
}) =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
@ -263,6 +393,7 @@ mixin _$OrderLoaderState {
|
|||||||
required TResult Function(_Loading value) loading,
|
required TResult Function(_Loading value) loading,
|
||||||
required TResult Function(_Loaded value) loaded,
|
required TResult Function(_Loaded value) loaded,
|
||||||
required TResult Function(_Error value) error,
|
required TResult Function(_Error value) error,
|
||||||
|
required TResult Function(_LoadedDetail value) loadedDetail,
|
||||||
}) =>
|
}) =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
@ -271,6 +402,7 @@ mixin _$OrderLoaderState {
|
|||||||
TResult? Function(_Loading value)? loading,
|
TResult? Function(_Loading value)? loading,
|
||||||
TResult? Function(_Loaded value)? loaded,
|
TResult? Function(_Loaded value)? loaded,
|
||||||
TResult? Function(_Error value)? error,
|
TResult? Function(_Error value)? error,
|
||||||
|
TResult? Function(_LoadedDetail value)? loadedDetail,
|
||||||
}) =>
|
}) =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
@ -279,6 +411,7 @@ mixin _$OrderLoaderState {
|
|||||||
TResult Function(_Loading value)? loading,
|
TResult Function(_Loading value)? loading,
|
||||||
TResult Function(_Loaded value)? loaded,
|
TResult Function(_Loaded value)? loaded,
|
||||||
TResult Function(_Error value)? error,
|
TResult Function(_Error value)? error,
|
||||||
|
TResult Function(_LoadedDetail value)? loadedDetail,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) =>
|
}) =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
@ -350,6 +483,7 @@ class _$InitialImpl implements _Initial {
|
|||||||
required TResult Function() loading,
|
required TResult Function() loading,
|
||||||
required TResult Function(List<Order> orders, int totalOrder) loaded,
|
required TResult Function(List<Order> orders, int totalOrder) loaded,
|
||||||
required TResult Function(String message) error,
|
required TResult Function(String message) error,
|
||||||
|
required TResult Function(Order order) loadedDetail,
|
||||||
}) {
|
}) {
|
||||||
return initial();
|
return initial();
|
||||||
}
|
}
|
||||||
@ -361,6 +495,7 @@ class _$InitialImpl implements _Initial {
|
|||||||
TResult? Function()? loading,
|
TResult? Function()? loading,
|
||||||
TResult? Function(List<Order> orders, int totalOrder)? loaded,
|
TResult? Function(List<Order> orders, int totalOrder)? loaded,
|
||||||
TResult? Function(String message)? error,
|
TResult? Function(String message)? error,
|
||||||
|
TResult? Function(Order order)? loadedDetail,
|
||||||
}) {
|
}) {
|
||||||
return initial?.call();
|
return initial?.call();
|
||||||
}
|
}
|
||||||
@ -372,6 +507,7 @@ class _$InitialImpl implements _Initial {
|
|||||||
TResult Function()? loading,
|
TResult Function()? loading,
|
||||||
TResult Function(List<Order> orders, int totalOrder)? loaded,
|
TResult Function(List<Order> orders, int totalOrder)? loaded,
|
||||||
TResult Function(String message)? error,
|
TResult Function(String message)? error,
|
||||||
|
TResult Function(Order order)? loadedDetail,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) {
|
}) {
|
||||||
if (initial != null) {
|
if (initial != null) {
|
||||||
@ -387,6 +523,7 @@ class _$InitialImpl implements _Initial {
|
|||||||
required TResult Function(_Loading value) loading,
|
required TResult Function(_Loading value) loading,
|
||||||
required TResult Function(_Loaded value) loaded,
|
required TResult Function(_Loaded value) loaded,
|
||||||
required TResult Function(_Error value) error,
|
required TResult Function(_Error value) error,
|
||||||
|
required TResult Function(_LoadedDetail value) loadedDetail,
|
||||||
}) {
|
}) {
|
||||||
return initial(this);
|
return initial(this);
|
||||||
}
|
}
|
||||||
@ -398,6 +535,7 @@ class _$InitialImpl implements _Initial {
|
|||||||
TResult? Function(_Loading value)? loading,
|
TResult? Function(_Loading value)? loading,
|
||||||
TResult? Function(_Loaded value)? loaded,
|
TResult? Function(_Loaded value)? loaded,
|
||||||
TResult? Function(_Error value)? error,
|
TResult? Function(_Error value)? error,
|
||||||
|
TResult? Function(_LoadedDetail value)? loadedDetail,
|
||||||
}) {
|
}) {
|
||||||
return initial?.call(this);
|
return initial?.call(this);
|
||||||
}
|
}
|
||||||
@ -409,6 +547,7 @@ class _$InitialImpl implements _Initial {
|
|||||||
TResult Function(_Loading value)? loading,
|
TResult Function(_Loading value)? loading,
|
||||||
TResult Function(_Loaded value)? loaded,
|
TResult Function(_Loaded value)? loaded,
|
||||||
TResult Function(_Error value)? error,
|
TResult Function(_Error value)? error,
|
||||||
|
TResult Function(_LoadedDetail value)? loadedDetail,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) {
|
}) {
|
||||||
if (initial != null) {
|
if (initial != null) {
|
||||||
@ -467,6 +606,7 @@ class _$LoadingImpl implements _Loading {
|
|||||||
required TResult Function() loading,
|
required TResult Function() loading,
|
||||||
required TResult Function(List<Order> orders, int totalOrder) loaded,
|
required TResult Function(List<Order> orders, int totalOrder) loaded,
|
||||||
required TResult Function(String message) error,
|
required TResult Function(String message) error,
|
||||||
|
required TResult Function(Order order) loadedDetail,
|
||||||
}) {
|
}) {
|
||||||
return loading();
|
return loading();
|
||||||
}
|
}
|
||||||
@ -478,6 +618,7 @@ class _$LoadingImpl implements _Loading {
|
|||||||
TResult? Function()? loading,
|
TResult? Function()? loading,
|
||||||
TResult? Function(List<Order> orders, int totalOrder)? loaded,
|
TResult? Function(List<Order> orders, int totalOrder)? loaded,
|
||||||
TResult? Function(String message)? error,
|
TResult? Function(String message)? error,
|
||||||
|
TResult? Function(Order order)? loadedDetail,
|
||||||
}) {
|
}) {
|
||||||
return loading?.call();
|
return loading?.call();
|
||||||
}
|
}
|
||||||
@ -489,6 +630,7 @@ class _$LoadingImpl implements _Loading {
|
|||||||
TResult Function()? loading,
|
TResult Function()? loading,
|
||||||
TResult Function(List<Order> orders, int totalOrder)? loaded,
|
TResult Function(List<Order> orders, int totalOrder)? loaded,
|
||||||
TResult Function(String message)? error,
|
TResult Function(String message)? error,
|
||||||
|
TResult Function(Order order)? loadedDetail,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) {
|
}) {
|
||||||
if (loading != null) {
|
if (loading != null) {
|
||||||
@ -504,6 +646,7 @@ class _$LoadingImpl implements _Loading {
|
|||||||
required TResult Function(_Loading value) loading,
|
required TResult Function(_Loading value) loading,
|
||||||
required TResult Function(_Loaded value) loaded,
|
required TResult Function(_Loaded value) loaded,
|
||||||
required TResult Function(_Error value) error,
|
required TResult Function(_Error value) error,
|
||||||
|
required TResult Function(_LoadedDetail value) loadedDetail,
|
||||||
}) {
|
}) {
|
||||||
return loading(this);
|
return loading(this);
|
||||||
}
|
}
|
||||||
@ -515,6 +658,7 @@ class _$LoadingImpl implements _Loading {
|
|||||||
TResult? Function(_Loading value)? loading,
|
TResult? Function(_Loading value)? loading,
|
||||||
TResult? Function(_Loaded value)? loaded,
|
TResult? Function(_Loaded value)? loaded,
|
||||||
TResult? Function(_Error value)? error,
|
TResult? Function(_Error value)? error,
|
||||||
|
TResult? Function(_LoadedDetail value)? loadedDetail,
|
||||||
}) {
|
}) {
|
||||||
return loading?.call(this);
|
return loading?.call(this);
|
||||||
}
|
}
|
||||||
@ -526,6 +670,7 @@ class _$LoadingImpl implements _Loading {
|
|||||||
TResult Function(_Loading value)? loading,
|
TResult Function(_Loading value)? loading,
|
||||||
TResult Function(_Loaded value)? loaded,
|
TResult Function(_Loaded value)? loaded,
|
||||||
TResult Function(_Error value)? error,
|
TResult Function(_Error value)? error,
|
||||||
|
TResult Function(_LoadedDetail value)? loadedDetail,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) {
|
}) {
|
||||||
if (loading != null) {
|
if (loading != null) {
|
||||||
@ -628,6 +773,7 @@ class _$LoadedImpl implements _Loaded {
|
|||||||
required TResult Function() loading,
|
required TResult Function() loading,
|
||||||
required TResult Function(List<Order> orders, int totalOrder) loaded,
|
required TResult Function(List<Order> orders, int totalOrder) loaded,
|
||||||
required TResult Function(String message) error,
|
required TResult Function(String message) error,
|
||||||
|
required TResult Function(Order order) loadedDetail,
|
||||||
}) {
|
}) {
|
||||||
return loaded(orders, totalOrder);
|
return loaded(orders, totalOrder);
|
||||||
}
|
}
|
||||||
@ -639,6 +785,7 @@ class _$LoadedImpl implements _Loaded {
|
|||||||
TResult? Function()? loading,
|
TResult? Function()? loading,
|
||||||
TResult? Function(List<Order> orders, int totalOrder)? loaded,
|
TResult? Function(List<Order> orders, int totalOrder)? loaded,
|
||||||
TResult? Function(String message)? error,
|
TResult? Function(String message)? error,
|
||||||
|
TResult? Function(Order order)? loadedDetail,
|
||||||
}) {
|
}) {
|
||||||
return loaded?.call(orders, totalOrder);
|
return loaded?.call(orders, totalOrder);
|
||||||
}
|
}
|
||||||
@ -650,6 +797,7 @@ class _$LoadedImpl implements _Loaded {
|
|||||||
TResult Function()? loading,
|
TResult Function()? loading,
|
||||||
TResult Function(List<Order> orders, int totalOrder)? loaded,
|
TResult Function(List<Order> orders, int totalOrder)? loaded,
|
||||||
TResult Function(String message)? error,
|
TResult Function(String message)? error,
|
||||||
|
TResult Function(Order order)? loadedDetail,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) {
|
}) {
|
||||||
if (loaded != null) {
|
if (loaded != null) {
|
||||||
@ -665,6 +813,7 @@ class _$LoadedImpl implements _Loaded {
|
|||||||
required TResult Function(_Loading value) loading,
|
required TResult Function(_Loading value) loading,
|
||||||
required TResult Function(_Loaded value) loaded,
|
required TResult Function(_Loaded value) loaded,
|
||||||
required TResult Function(_Error value) error,
|
required TResult Function(_Error value) error,
|
||||||
|
required TResult Function(_LoadedDetail value) loadedDetail,
|
||||||
}) {
|
}) {
|
||||||
return loaded(this);
|
return loaded(this);
|
||||||
}
|
}
|
||||||
@ -676,6 +825,7 @@ class _$LoadedImpl implements _Loaded {
|
|||||||
TResult? Function(_Loading value)? loading,
|
TResult? Function(_Loading value)? loading,
|
||||||
TResult? Function(_Loaded value)? loaded,
|
TResult? Function(_Loaded value)? loaded,
|
||||||
TResult? Function(_Error value)? error,
|
TResult? Function(_Error value)? error,
|
||||||
|
TResult? Function(_LoadedDetail value)? loadedDetail,
|
||||||
}) {
|
}) {
|
||||||
return loaded?.call(this);
|
return loaded?.call(this);
|
||||||
}
|
}
|
||||||
@ -687,6 +837,7 @@ class _$LoadedImpl implements _Loaded {
|
|||||||
TResult Function(_Loading value)? loading,
|
TResult Function(_Loading value)? loading,
|
||||||
TResult Function(_Loaded value)? loaded,
|
TResult Function(_Loaded value)? loaded,
|
||||||
TResult Function(_Error value)? error,
|
TResult Function(_Error value)? error,
|
||||||
|
TResult Function(_LoadedDetail value)? loadedDetail,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) {
|
}) {
|
||||||
if (loaded != null) {
|
if (loaded != null) {
|
||||||
@ -782,6 +933,7 @@ class _$ErrorImpl implements _Error {
|
|||||||
required TResult Function() loading,
|
required TResult Function() loading,
|
||||||
required TResult Function(List<Order> orders, int totalOrder) loaded,
|
required TResult Function(List<Order> orders, int totalOrder) loaded,
|
||||||
required TResult Function(String message) error,
|
required TResult Function(String message) error,
|
||||||
|
required TResult Function(Order order) loadedDetail,
|
||||||
}) {
|
}) {
|
||||||
return error(message);
|
return error(message);
|
||||||
}
|
}
|
||||||
@ -793,6 +945,7 @@ class _$ErrorImpl implements _Error {
|
|||||||
TResult? Function()? loading,
|
TResult? Function()? loading,
|
||||||
TResult? Function(List<Order> orders, int totalOrder)? loaded,
|
TResult? Function(List<Order> orders, int totalOrder)? loaded,
|
||||||
TResult? Function(String message)? error,
|
TResult? Function(String message)? error,
|
||||||
|
TResult? Function(Order order)? loadedDetail,
|
||||||
}) {
|
}) {
|
||||||
return error?.call(message);
|
return error?.call(message);
|
||||||
}
|
}
|
||||||
@ -804,6 +957,7 @@ class _$ErrorImpl implements _Error {
|
|||||||
TResult Function()? loading,
|
TResult Function()? loading,
|
||||||
TResult Function(List<Order> orders, int totalOrder)? loaded,
|
TResult Function(List<Order> orders, int totalOrder)? loaded,
|
||||||
TResult Function(String message)? error,
|
TResult Function(String message)? error,
|
||||||
|
TResult Function(Order order)? loadedDetail,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) {
|
}) {
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
@ -819,6 +973,7 @@ class _$ErrorImpl implements _Error {
|
|||||||
required TResult Function(_Loading value) loading,
|
required TResult Function(_Loading value) loading,
|
||||||
required TResult Function(_Loaded value) loaded,
|
required TResult Function(_Loaded value) loaded,
|
||||||
required TResult Function(_Error value) error,
|
required TResult Function(_Error value) error,
|
||||||
|
required TResult Function(_LoadedDetail value) loadedDetail,
|
||||||
}) {
|
}) {
|
||||||
return error(this);
|
return error(this);
|
||||||
}
|
}
|
||||||
@ -830,6 +985,7 @@ class _$ErrorImpl implements _Error {
|
|||||||
TResult? Function(_Loading value)? loading,
|
TResult? Function(_Loading value)? loading,
|
||||||
TResult? Function(_Loaded value)? loaded,
|
TResult? Function(_Loaded value)? loaded,
|
||||||
TResult? Function(_Error value)? error,
|
TResult? Function(_Error value)? error,
|
||||||
|
TResult? Function(_LoadedDetail value)? loadedDetail,
|
||||||
}) {
|
}) {
|
||||||
return error?.call(this);
|
return error?.call(this);
|
||||||
}
|
}
|
||||||
@ -841,6 +997,7 @@ class _$ErrorImpl implements _Error {
|
|||||||
TResult Function(_Loading value)? loading,
|
TResult Function(_Loading value)? loading,
|
||||||
TResult Function(_Loaded value)? loaded,
|
TResult Function(_Loaded value)? loaded,
|
||||||
TResult Function(_Error value)? error,
|
TResult Function(_Error value)? error,
|
||||||
|
TResult Function(_LoadedDetail value)? loadedDetail,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) {
|
}) {
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
@ -861,3 +1018,161 @@ abstract class _Error implements OrderLoaderState {
|
|||||||
_$$ErrorImplCopyWith<_$ErrorImpl> get copyWith =>
|
_$$ErrorImplCopyWith<_$ErrorImpl> get copyWith =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
abstract class _$$LoadedDetailImplCopyWith<$Res> {
|
||||||
|
factory _$$LoadedDetailImplCopyWith(
|
||||||
|
_$LoadedDetailImpl value, $Res Function(_$LoadedDetailImpl) then) =
|
||||||
|
__$$LoadedDetailImplCopyWithImpl<$Res>;
|
||||||
|
@useResult
|
||||||
|
$Res call({Order order});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
class __$$LoadedDetailImplCopyWithImpl<$Res>
|
||||||
|
extends _$OrderLoaderStateCopyWithImpl<$Res, _$LoadedDetailImpl>
|
||||||
|
implements _$$LoadedDetailImplCopyWith<$Res> {
|
||||||
|
__$$LoadedDetailImplCopyWithImpl(
|
||||||
|
_$LoadedDetailImpl _value, $Res Function(_$LoadedDetailImpl) _then)
|
||||||
|
: super(_value, _then);
|
||||||
|
|
||||||
|
/// Create a copy of OrderLoaderState
|
||||||
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
@override
|
||||||
|
$Res call({
|
||||||
|
Object? order = null,
|
||||||
|
}) {
|
||||||
|
return _then(_$LoadedDetailImpl(
|
||||||
|
null == order
|
||||||
|
? _value.order
|
||||||
|
: order // ignore: cast_nullable_to_non_nullable
|
||||||
|
as Order,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
|
||||||
|
class _$LoadedDetailImpl implements _LoadedDetail {
|
||||||
|
const _$LoadedDetailImpl(this.order);
|
||||||
|
|
||||||
|
@override
|
||||||
|
final Order order;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'OrderLoaderState.loadedDetail(order: $order)';
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) {
|
||||||
|
return identical(this, other) ||
|
||||||
|
(other.runtimeType == runtimeType &&
|
||||||
|
other is _$LoadedDetailImpl &&
|
||||||
|
(identical(other.order, order) || other.order == order));
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode => Object.hash(runtimeType, order);
|
||||||
|
|
||||||
|
/// Create a copy of OrderLoaderState
|
||||||
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
|
@override
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
_$$LoadedDetailImplCopyWith<_$LoadedDetailImpl> get copyWith =>
|
||||||
|
__$$LoadedDetailImplCopyWithImpl<_$LoadedDetailImpl>(this, _$identity);
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult when<TResult extends Object?>({
|
||||||
|
required TResult Function() initial,
|
||||||
|
required TResult Function() loading,
|
||||||
|
required TResult Function(List<Order> orders, int totalOrder) loaded,
|
||||||
|
required TResult Function(String message) error,
|
||||||
|
required TResult Function(Order order) loadedDetail,
|
||||||
|
}) {
|
||||||
|
return loadedDetail(order);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult? whenOrNull<TResult extends Object?>({
|
||||||
|
TResult? Function()? initial,
|
||||||
|
TResult? Function()? loading,
|
||||||
|
TResult? Function(List<Order> orders, int totalOrder)? loaded,
|
||||||
|
TResult? Function(String message)? error,
|
||||||
|
TResult? Function(Order order)? loadedDetail,
|
||||||
|
}) {
|
||||||
|
return loadedDetail?.call(order);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult maybeWhen<TResult extends Object?>({
|
||||||
|
TResult Function()? initial,
|
||||||
|
TResult Function()? loading,
|
||||||
|
TResult Function(List<Order> orders, int totalOrder)? loaded,
|
||||||
|
TResult Function(String message)? error,
|
||||||
|
TResult Function(Order order)? loadedDetail,
|
||||||
|
required TResult orElse(),
|
||||||
|
}) {
|
||||||
|
if (loadedDetail != null) {
|
||||||
|
return loadedDetail(order);
|
||||||
|
}
|
||||||
|
return orElse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult map<TResult extends Object?>({
|
||||||
|
required TResult Function(_Initial value) initial,
|
||||||
|
required TResult Function(_Loading value) loading,
|
||||||
|
required TResult Function(_Loaded value) loaded,
|
||||||
|
required TResult Function(_Error value) error,
|
||||||
|
required TResult Function(_LoadedDetail value) loadedDetail,
|
||||||
|
}) {
|
||||||
|
return loadedDetail(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult? mapOrNull<TResult extends Object?>({
|
||||||
|
TResult? Function(_Initial value)? initial,
|
||||||
|
TResult? Function(_Loading value)? loading,
|
||||||
|
TResult? Function(_Loaded value)? loaded,
|
||||||
|
TResult? Function(_Error value)? error,
|
||||||
|
TResult? Function(_LoadedDetail value)? loadedDetail,
|
||||||
|
}) {
|
||||||
|
return loadedDetail?.call(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult maybeMap<TResult extends Object?>({
|
||||||
|
TResult Function(_Initial value)? initial,
|
||||||
|
TResult Function(_Loading value)? loading,
|
||||||
|
TResult Function(_Loaded value)? loaded,
|
||||||
|
TResult Function(_Error value)? error,
|
||||||
|
TResult Function(_LoadedDetail value)? loadedDetail,
|
||||||
|
required TResult orElse(),
|
||||||
|
}) {
|
||||||
|
if (loadedDetail != null) {
|
||||||
|
return loadedDetail(this);
|
||||||
|
}
|
||||||
|
return orElse();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class _LoadedDetail implements OrderLoaderState {
|
||||||
|
const factory _LoadedDetail(final Order order) = _$LoadedDetailImpl;
|
||||||
|
|
||||||
|
Order get order;
|
||||||
|
|
||||||
|
/// Create a copy of OrderLoaderState
|
||||||
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
|
_$$LoadedDetailImplCopyWith<_$LoadedDetailImpl> get copyWith =>
|
||||||
|
throw _privateConstructorUsedError;
|
||||||
|
}
|
||||||
|
|||||||
@ -3,4 +3,5 @@ part of 'order_loader_bloc.dart';
|
|||||||
@freezed
|
@freezed
|
||||||
class OrderLoaderEvent with _$OrderLoaderEvent {
|
class OrderLoaderEvent with _$OrderLoaderEvent {
|
||||||
const factory OrderLoaderEvent.getByStatus(String status) = _GetByStatus;
|
const factory OrderLoaderEvent.getByStatus(String status) = _GetByStatus;
|
||||||
|
const factory OrderLoaderEvent.getById(String id) = _GetById;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,4 +7,5 @@ class OrderLoaderState with _$OrderLoaderState {
|
|||||||
const factory OrderLoaderState.loaded(List<Order> orders, int totalOrder) =
|
const factory OrderLoaderState.loaded(List<Order> orders, int totalOrder) =
|
||||||
_Loaded;
|
_Loaded;
|
||||||
const factory OrderLoaderState.error(String message) = _Error;
|
const factory OrderLoaderState.error(String message) = _Error;
|
||||||
|
const factory OrderLoaderState.loadedDetail(Order order) = _LoadedDetail;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,7 +11,9 @@ import 'package:enaklo_pos/core/extensions/string_ext.dart';
|
|||||||
import 'package:enaklo_pos/data/models/request/payment_request.dart';
|
import 'package:enaklo_pos/data/models/request/payment_request.dart';
|
||||||
import 'package:enaklo_pos/data/models/response/order_response_model.dart';
|
import 'package:enaklo_pos/data/models/response/order_response_model.dart';
|
||||||
import 'package:enaklo_pos/data/models/response/payment_methods_response_model.dart';
|
import 'package:enaklo_pos/data/models/response/payment_methods_response_model.dart';
|
||||||
|
import 'package:enaklo_pos/data/models/response/product_response_model.dart';
|
||||||
import 'package:enaklo_pos/presentation/home/bloc/payment_methods/payment_methods_bloc.dart';
|
import 'package:enaklo_pos/presentation/home/bloc/payment_methods/payment_methods_bloc.dart';
|
||||||
|
import 'package:enaklo_pos/presentation/home/models/product_quantity.dart';
|
||||||
import 'package:enaklo_pos/presentation/sales/blocs/payment_form/payment_form_bloc.dart';
|
import 'package:enaklo_pos/presentation/sales/blocs/payment_form/payment_form_bloc.dart';
|
||||||
import 'package:enaklo_pos/presentation/success/pages/success_payment_page.dart';
|
import 'package:enaklo_pos/presentation/success/pages/success_payment_page.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@ -328,6 +330,18 @@ class _PaymentDialogState extends State<PaymentDialog> {
|
|||||||
orElse: () {},
|
orElse: () {},
|
||||||
success: (data) {
|
success: (data) {
|
||||||
context.pushReplacement(SuccessPaymentPage(
|
context.pushReplacement(SuccessPaymentPage(
|
||||||
|
productQuantity: widget.order.orderItems
|
||||||
|
?.map(
|
||||||
|
(item) => ProductQuantity(
|
||||||
|
product: Product(
|
||||||
|
name: item.productName,
|
||||||
|
price: item.unitPrice,
|
||||||
|
),
|
||||||
|
quantity: item.quantity ?? 0,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.toList() ??
|
||||||
|
[],
|
||||||
payment: data,
|
payment: data,
|
||||||
));
|
));
|
||||||
},
|
},
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
|
import 'dart:developer';
|
||||||
|
|
||||||
import 'package:enaklo_pos/core/components/buttons.dart';
|
import 'package:enaklo_pos/core/components/buttons.dart';
|
||||||
import 'package:enaklo_pos/core/components/dashed_divider.dart';
|
import 'package:enaklo_pos/core/components/dashed_divider.dart';
|
||||||
import 'package:enaklo_pos/core/components/spaces.dart';
|
import 'package:enaklo_pos/core/components/spaces.dart';
|
||||||
@ -5,13 +7,34 @@ 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/core/extensions/date_time_ext.dart';
|
import 'package:enaklo_pos/core/extensions/date_time_ext.dart';
|
||||||
import 'package:enaklo_pos/core/extensions/string_ext.dart';
|
import 'package:enaklo_pos/core/extensions/string_ext.dart';
|
||||||
|
import 'package:enaklo_pos/core/utils/printer_service.dart';
|
||||||
|
import 'package:enaklo_pos/data/dataoutputs/print_dataoutputs.dart';
|
||||||
|
import 'package:enaklo_pos/data/datasources/product_local_datasource.dart';
|
||||||
import 'package:enaklo_pos/data/models/response/payment_response_model.dart';
|
import 'package:enaklo_pos/data/models/response/payment_response_model.dart';
|
||||||
|
import 'package:enaklo_pos/presentation/home/models/product_quantity.dart';
|
||||||
import 'package:enaklo_pos/presentation/home/pages/dashboard_page.dart';
|
import 'package:enaklo_pos/presentation/home/pages/dashboard_page.dart';
|
||||||
|
import 'package:enaklo_pos/presentation/sales/blocs/order_loader/order_loader_bloc.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
|
||||||
class SuccessPaymentPage extends StatelessWidget {
|
class SuccessPaymentPage extends StatefulWidget {
|
||||||
|
final List<ProductQuantity> productQuantity;
|
||||||
final PaymentData payment;
|
final PaymentData payment;
|
||||||
const SuccessPaymentPage({super.key, required this.payment});
|
const SuccessPaymentPage(
|
||||||
|
{super.key, required this.payment, required this.productQuantity});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<SuccessPaymentPage> createState() => _SuccessPaymentPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _SuccessPaymentPageState extends State<SuccessPaymentPage> {
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
context
|
||||||
|
.read<OrderLoaderBloc>()
|
||||||
|
.add(OrderLoaderEvent.getById(widget.payment.orderId ?? ""));
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -25,137 +48,249 @@ class SuccessPaymentPage extends StatelessWidget {
|
|||||||
color: AppColors.white,
|
color: AppColors.white,
|
||||||
borderRadius: const BorderRadius.all(Radius.circular(12.0)),
|
borderRadius: const BorderRadius.all(Radius.circular(12.0)),
|
||||||
),
|
),
|
||||||
child: Column(
|
child: BlocBuilder<OrderLoaderBloc, OrderLoaderState>(
|
||||||
children: [
|
builder: (context, state) {
|
||||||
Padding(
|
return state.maybeWhen(
|
||||||
padding: const EdgeInsets.all(16.0),
|
orElse: () => Center(
|
||||||
child: Column(
|
child: CircularProgressIndicator(),
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
'Pembayaran!',
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 18, fontWeight: FontWeight.bold),
|
|
||||||
),
|
|
||||||
Text('Pembayaran berhasil dilalukan',
|
|
||||||
style: const TextStyle(fontSize: 14)),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
loading: () => Center(
|
||||||
DashedDivider(
|
child: CircularProgressIndicator(),
|
||||||
color: AppColors.grey,
|
|
||||||
),
|
|
||||||
SpaceHeight(24),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
|
||||||
child: Icon(
|
|
||||||
Icons.check_circle_outline,
|
|
||||||
size: 64,
|
|
||||||
color: Colors.green,
|
|
||||||
),
|
),
|
||||||
),
|
error: (message) => Center(
|
||||||
Spacer(),
|
child: Text(message),
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.all(16.0).copyWith(top: 24),
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
// Row(
|
|
||||||
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
// children: [
|
|
||||||
// Text(
|
|
||||||
// 'No. Pesanan',
|
|
||||||
// ),
|
|
||||||
// Text(
|
|
||||||
// order.orderNumber ?? "-",
|
|
||||||
// style: const TextStyle(fontWeight: FontWeight.bold),
|
|
||||||
// ),
|
|
||||||
// ],
|
|
||||||
// ),
|
|
||||||
SpaceHeight(4),
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
'Waktu',
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
(payment.createdAt ?? DateTime.now())
|
|
||||||
.toFormattedDate3(),
|
|
||||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
loadedDetail: (order) => Column(
|
||||||
DashedDivider(
|
|
||||||
color: AppColors.grey,
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.all(16.0),
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Padding(
|
||||||
'Status Pembayaran',
|
padding: const EdgeInsets.all(16.0),
|
||||||
),
|
child: Column(
|
||||||
Text(
|
children: [
|
||||||
'Lunas',
|
Text(
|
||||||
style: const TextStyle(
|
'Pembayaran!',
|
||||||
fontWeight: FontWeight.bold, color: Colors.green),
|
style: const TextStyle(
|
||||||
),
|
fontSize: 18, fontWeight: FontWeight.bold),
|
||||||
],
|
),
|
||||||
),
|
Text('Pembayaran berhasil dilalukan',
|
||||||
),
|
style: const TextStyle(fontSize: 14)),
|
||||||
DashedDivider(
|
],
|
||||||
color: AppColors.grey,
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.all(16.0),
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
'Total Pembayaran',
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
(payment.amount ?? 0).toString().currencyFormatRpV2,
|
|
||||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
DashedDivider(
|
|
||||||
color: AppColors.grey,
|
|
||||||
),
|
|
||||||
Spacer(),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.all(16.0),
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
child: Button.outlined(
|
|
||||||
onPressed: () =>
|
|
||||||
context.pushReplacement(DashboardPage()),
|
|
||||||
label: 'Kembali',
|
|
||||||
height: 44,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SpaceWidth(12),
|
DashedDivider(
|
||||||
Expanded(
|
color: AppColors.grey,
|
||||||
child: Button.filled(
|
),
|
||||||
onPressed: () {},
|
SpaceHeight(24),
|
||||||
label: 'Cetak',
|
Padding(
|
||||||
icon: Icon(
|
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||||
Icons.print,
|
child: Icon(
|
||||||
color: AppColors.white,
|
Icons.check_circle_outline,
|
||||||
),
|
size: 64,
|
||||||
height: 44,
|
color: Colors.green,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Spacer(),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(16.0).copyWith(top: 24),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'No. Pesanan',
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
order.orderNumber ?? "-",
|
||||||
|
style: const TextStyle(
|
||||||
|
fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
SpaceHeight(4),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'Waktu',
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
(widget.payment.createdAt ?? DateTime.now())
|
||||||
|
.toFormattedDate3(),
|
||||||
|
style: const TextStyle(
|
||||||
|
fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
DashedDivider(
|
||||||
|
color: AppColors.grey,
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(16.0),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'Status Pembayaran',
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
'Lunas',
|
||||||
|
style: const TextStyle(
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: Colors.green),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
DashedDivider(
|
||||||
|
color: AppColors.grey,
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(16.0),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'Total Pembayaran',
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
(widget.payment.amount ?? 0)
|
||||||
|
.toString()
|
||||||
|
.currencyFormatRpV2,
|
||||||
|
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
DashedDivider(
|
||||||
|
color: AppColors.grey,
|
||||||
|
),
|
||||||
|
Spacer(),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(16.0),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: Button.outlined(
|
||||||
|
onPressed: () =>
|
||||||
|
context.pushReplacement(DashboardPage()),
|
||||||
|
label: 'Kembali',
|
||||||
|
height: 44,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SpaceWidth(12),
|
||||||
|
Expanded(
|
||||||
|
child: Button.filled(
|
||||||
|
onPressed: () async {
|
||||||
|
final checkerPrinter =
|
||||||
|
await ProductLocalDatasource.instance
|
||||||
|
.getPrinterByCode('checker');
|
||||||
|
final kitchenPrinter =
|
||||||
|
await ProductLocalDatasource.instance
|
||||||
|
.getPrinterByCode('kitchen');
|
||||||
|
final barPrinter = await ProductLocalDatasource
|
||||||
|
.instance
|
||||||
|
.getPrinterByCode('bar');
|
||||||
|
|
||||||
|
log("Checker printer: ${checkerPrinter?.toMap()}");
|
||||||
|
log("Kitchen printer: ${kitchenPrinter?.toMap()}");
|
||||||
|
log("Bar printer: ${barPrinter?.toMap()}");
|
||||||
|
|
||||||
|
// Checker printer
|
||||||
|
if (checkerPrinter != null) {
|
||||||
|
try {
|
||||||
|
final printValue = await PrintDataoutputs
|
||||||
|
.instance
|
||||||
|
.printChecker(
|
||||||
|
widget.productQuantity,
|
||||||
|
order.tableNumber ?? "",
|
||||||
|
order.orderNumber ?? "",
|
||||||
|
'kasir',
|
||||||
|
checkerPrinter.paper.toIntegerFromText,
|
||||||
|
order.orderType ?? "",
|
||||||
|
);
|
||||||
|
|
||||||
|
await PrinterService().printWithPrinter(
|
||||||
|
checkerPrinter, printValue, context);
|
||||||
|
} catch (e) {
|
||||||
|
log("Error printing checker: $e");
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
SnackBar(
|
||||||
|
content: Text(
|
||||||
|
'Error printing checker: $e')),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Kitchen printer
|
||||||
|
if (kitchenPrinter != null) {
|
||||||
|
try {
|
||||||
|
final printValue = await PrintDataoutputs
|
||||||
|
.instance
|
||||||
|
.printKitchen(
|
||||||
|
widget.productQuantity,
|
||||||
|
order.tableNumber!,
|
||||||
|
order.orderNumber ?? "",
|
||||||
|
'kasir',
|
||||||
|
kitchenPrinter.paper.toIntegerFromText,
|
||||||
|
order.orderType ?? "",
|
||||||
|
);
|
||||||
|
|
||||||
|
await PrinterService().printWithPrinter(
|
||||||
|
kitchenPrinter, printValue, context);
|
||||||
|
} catch (e) {
|
||||||
|
log("Error printing kitchen order: $e");
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
SnackBar(
|
||||||
|
content: Text(
|
||||||
|
'Error printing kitchen order: $e')),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bar printer
|
||||||
|
if (barPrinter != null) {
|
||||||
|
try {
|
||||||
|
final printValue = await PrintDataoutputs
|
||||||
|
.instance
|
||||||
|
.printBar(
|
||||||
|
widget.productQuantity,
|
||||||
|
order.tableNumber ?? "",
|
||||||
|
order.orderNumber ?? "",
|
||||||
|
'kasir',
|
||||||
|
barPrinter.paper.toIntegerFromText,
|
||||||
|
order.orderType ?? "",
|
||||||
|
);
|
||||||
|
|
||||||
|
await PrinterService().printWithPrinter(
|
||||||
|
barPrinter, printValue, context);
|
||||||
|
} catch (e) {
|
||||||
|
log("Error printing bar order: $e");
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
SnackBar(
|
||||||
|
content: Text(
|
||||||
|
'Error printing bar order: $e')),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
label: 'Cetak',
|
||||||
|
icon: Icon(
|
||||||
|
Icons.print,
|
||||||
|
color: AppColors.white,
|
||||||
|
),
|
||||||
|
height: 44,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
],
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@ -9,16 +9,33 @@ import 'package:enaklo_pos/core/extensions/string_ext.dart';
|
|||||||
import 'package:enaklo_pos/core/utils/printer_service.dart';
|
import 'package:enaklo_pos/core/utils/printer_service.dart';
|
||||||
import 'package:enaklo_pos/data/dataoutputs/print_dataoutputs.dart';
|
import 'package:enaklo_pos/data/dataoutputs/print_dataoutputs.dart';
|
||||||
import 'package:enaklo_pos/data/datasources/product_local_datasource.dart';
|
import 'package:enaklo_pos/data/datasources/product_local_datasource.dart';
|
||||||
import 'package:enaklo_pos/data/models/response/order_response_model.dart';
|
|
||||||
import 'package:enaklo_pos/presentation/home/models/product_quantity.dart';
|
import 'package:enaklo_pos/presentation/home/models/product_quantity.dart';
|
||||||
import 'package:enaklo_pos/presentation/home/pages/dashboard_page.dart';
|
import 'package:enaklo_pos/presentation/home/pages/dashboard_page.dart';
|
||||||
|
import 'package:enaklo_pos/presentation/sales/blocs/order_loader/order_loader_bloc.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
|
||||||
class SuccessSaveOrderPage extends StatelessWidget {
|
class SuccessSaveOrderPage extends StatefulWidget {
|
||||||
final List<ProductQuantity> productQuantity;
|
final List<ProductQuantity> productQuantity;
|
||||||
final Order order;
|
final String orderId;
|
||||||
const SuccessSaveOrderPage(
|
const SuccessSaveOrderPage({
|
||||||
{super.key, required this.order, required this.productQuantity});
|
super.key,
|
||||||
|
required this.orderId,
|
||||||
|
required this.productQuantity,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<SuccessSaveOrderPage> createState() => _SuccessSaveOrderPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _SuccessSaveOrderPageState extends State<SuccessSaveOrderPage> {
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
context
|
||||||
|
.read<OrderLoaderBloc>()
|
||||||
|
.add(OrderLoaderEvent.getById(widget.orderId));
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -32,244 +49,267 @@ class SuccessSaveOrderPage extends StatelessWidget {
|
|||||||
color: AppColors.white,
|
color: AppColors.white,
|
||||||
borderRadius: const BorderRadius.all(Radius.circular(12.0)),
|
borderRadius: const BorderRadius.all(Radius.circular(12.0)),
|
||||||
),
|
),
|
||||||
child: Column(
|
child: BlocBuilder<OrderLoaderBloc, OrderLoaderState>(
|
||||||
children: [
|
builder: (context, state) {
|
||||||
Padding(
|
return state.maybeWhen(
|
||||||
padding: const EdgeInsets.all(16.0),
|
orElse: () => Center(
|
||||||
child: Column(
|
child: CircularProgressIndicator(),
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
'Pesanan!',
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 18, fontWeight: FontWeight.bold),
|
|
||||||
),
|
|
||||||
Text('Pesanan Berhasil disimpan',
|
|
||||||
style: const TextStyle(fontSize: 14)),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
loading: () => Center(
|
||||||
DashedDivider(
|
child: CircularProgressIndicator(),
|
||||||
color: AppColors.grey,
|
|
||||||
),
|
|
||||||
SpaceHeight(24),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
|
||||||
child: Text(
|
|
||||||
order.metadata?['customer_name'] ?? "-",
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 24,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
color: AppColors.primary,
|
|
||||||
),
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
maxLines: 2,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
),
|
),
|
||||||
),
|
error: (message) => Center(
|
||||||
Padding(
|
child: Text(message),
|
||||||
padding: const EdgeInsets.all(16.0).copyWith(top: 24),
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
'No. Pesanan',
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
order.orderNumber ?? "-",
|
|
||||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
SpaceHeight(4),
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
'No. Meja',
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
order.tableNumber ?? "-",
|
|
||||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
SpaceHeight(4),
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
'Waktu',
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
(order.createdAt ?? DateTime.now())
|
|
||||||
.toFormattedDate3(),
|
|
||||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
loadedDetail: (orderx) => Column(
|
||||||
Spacer(),
|
|
||||||
DashedDivider(
|
|
||||||
color: AppColors.grey,
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.all(16.0),
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Padding(
|
||||||
'Status Pembayaran',
|
padding: const EdgeInsets.all(16.0),
|
||||||
),
|
child: Column(
|
||||||
Text(
|
children: [
|
||||||
'Belum Bayar',
|
Text(
|
||||||
style: const TextStyle(
|
'Pesanan!',
|
||||||
fontWeight: FontWeight.bold, color: Colors.red),
|
style: const TextStyle(
|
||||||
),
|
fontSize: 18, fontWeight: FontWeight.bold),
|
||||||
],
|
),
|
||||||
),
|
Text('Pesanan Berhasil disimpan',
|
||||||
),
|
style: const TextStyle(fontSize: 14)),
|
||||||
DashedDivider(
|
],
|
||||||
color: AppColors.grey,
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.all(16.0),
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
'Total Pembayaran',
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
(order.totalAmount ?? 0).toString().currencyFormatRpV2,
|
|
||||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
DashedDivider(
|
|
||||||
color: AppColors.grey,
|
|
||||||
),
|
|
||||||
Spacer(),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.all(16.0),
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
child: Button.outlined(
|
|
||||||
onPressed: () => context.push(DashboardPage()),
|
|
||||||
label: 'Kembali',
|
|
||||||
height: 44,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SpaceWidth(12),
|
DashedDivider(
|
||||||
Expanded(
|
color: AppColors.grey,
|
||||||
child: Button.filled(
|
),
|
||||||
onPressed: () async {
|
SpaceHeight(24),
|
||||||
final checkerPrinter = await ProductLocalDatasource
|
Padding(
|
||||||
.instance
|
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||||
.getPrinterByCode('checker');
|
child: Text(
|
||||||
final kitchenPrinter = await ProductLocalDatasource
|
orderx.metadata?['customer_name'] ?? "-",
|
||||||
.instance
|
style: const TextStyle(
|
||||||
.getPrinterByCode('kitchen');
|
fontSize: 24,
|
||||||
final barPrinter = await ProductLocalDatasource
|
fontWeight: FontWeight.bold,
|
||||||
.instance
|
color: AppColors.primary,
|
||||||
.getPrinterByCode('bar');
|
|
||||||
|
|
||||||
log("Checker printer: ${checkerPrinter?.toMap()}");
|
|
||||||
log("Kitchen printer: ${kitchenPrinter?.toMap()}");
|
|
||||||
log("Bar printer: ${barPrinter?.toMap()}");
|
|
||||||
|
|
||||||
// Checker printer
|
|
||||||
if (checkerPrinter != null) {
|
|
||||||
try {
|
|
||||||
final printValue =
|
|
||||||
await PrintDataoutputs.instance.printChecker(
|
|
||||||
productQuantity,
|
|
||||||
order.tableNumber ?? "",
|
|
||||||
order.orderNumber ?? "",
|
|
||||||
'kasir',
|
|
||||||
checkerPrinter.paper.toIntegerFromText,
|
|
||||||
order.orderType ?? "",
|
|
||||||
);
|
|
||||||
|
|
||||||
await PrinterService().printWithPrinter(
|
|
||||||
checkerPrinter, printValue, context);
|
|
||||||
} catch (e) {
|
|
||||||
log("Error printing checker: $e");
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
SnackBar(
|
|
||||||
content:
|
|
||||||
Text('Error printing checker: $e')),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Kitchen printer
|
|
||||||
if (kitchenPrinter != null) {
|
|
||||||
try {
|
|
||||||
final printValue =
|
|
||||||
await PrintDataoutputs.instance.printKitchen(
|
|
||||||
productQuantity,
|
|
||||||
order.tableNumber!,
|
|
||||||
order.orderNumber ?? "",
|
|
||||||
'kasir',
|
|
||||||
kitchenPrinter.paper.toIntegerFromText,
|
|
||||||
order.orderType ?? "",
|
|
||||||
);
|
|
||||||
|
|
||||||
await PrinterService().printWithPrinter(
|
|
||||||
kitchenPrinter, printValue, context);
|
|
||||||
} catch (e) {
|
|
||||||
log("Error printing kitchen order: $e");
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
SnackBar(
|
|
||||||
content: Text(
|
|
||||||
'Error printing kitchen order: $e')),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bar printer
|
|
||||||
if (barPrinter != null) {
|
|
||||||
try {
|
|
||||||
final printValue =
|
|
||||||
await PrintDataoutputs.instance.printBar(
|
|
||||||
productQuantity,
|
|
||||||
order.tableNumber ?? "",
|
|
||||||
order.orderNumber ?? "",
|
|
||||||
'kasir',
|
|
||||||
barPrinter.paper.toIntegerFromText,
|
|
||||||
order.orderType ?? "",
|
|
||||||
);
|
|
||||||
|
|
||||||
await PrinterService().printWithPrinter(
|
|
||||||
barPrinter, printValue, context);
|
|
||||||
} catch (e) {
|
|
||||||
log("Error printing bar order: $e");
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
SnackBar(
|
|
||||||
content:
|
|
||||||
Text('Error printing bar order: $e')),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
label: 'Cetak',
|
|
||||||
icon: Icon(
|
|
||||||
Icons.print,
|
|
||||||
color: AppColors.white,
|
|
||||||
),
|
),
|
||||||
height: 44,
|
textAlign: TextAlign.center,
|
||||||
|
maxLines: 2,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(16.0).copyWith(top: 24),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'No. Pesanan',
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
orderx.orderNumber ?? "-",
|
||||||
|
style: const TextStyle(
|
||||||
|
fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
SpaceHeight(4),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'No. Meja',
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
orderx.tableNumber ?? "-",
|
||||||
|
style: const TextStyle(
|
||||||
|
fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
SpaceHeight(4),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'Waktu',
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
(orderx.createdAt ?? DateTime.now())
|
||||||
|
.toFormattedDate3(),
|
||||||
|
style: const TextStyle(
|
||||||
|
fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Spacer(),
|
||||||
|
DashedDivider(
|
||||||
|
color: AppColors.grey,
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(16.0),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'Status Pembayaran',
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
'Belum Bayar',
|
||||||
|
style: const TextStyle(
|
||||||
|
fontWeight: FontWeight.bold, color: Colors.red),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
DashedDivider(
|
||||||
|
color: AppColors.grey,
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(16.0),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'Total Pembayaran',
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
(orderx.totalAmount ?? 0)
|
||||||
|
.toString()
|
||||||
|
.currencyFormatRpV2,
|
||||||
|
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
DashedDivider(
|
||||||
|
color: AppColors.grey,
|
||||||
|
),
|
||||||
|
Spacer(),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(16.0),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: Button.outlined(
|
||||||
|
onPressed: () => context.push(DashboardPage()),
|
||||||
|
label: 'Kembali',
|
||||||
|
height: 44,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SpaceWidth(12),
|
||||||
|
Expanded(
|
||||||
|
child: Button.filled(
|
||||||
|
onPressed: () async {
|
||||||
|
final checkerPrinter =
|
||||||
|
await ProductLocalDatasource.instance
|
||||||
|
.getPrinterByCode('checker');
|
||||||
|
final kitchenPrinter =
|
||||||
|
await ProductLocalDatasource.instance
|
||||||
|
.getPrinterByCode('kitchen');
|
||||||
|
final barPrinter = await ProductLocalDatasource
|
||||||
|
.instance
|
||||||
|
.getPrinterByCode('bar');
|
||||||
|
|
||||||
|
log("Checker printer: ${checkerPrinter?.toMap()}");
|
||||||
|
log("Kitchen printer: ${kitchenPrinter?.toMap()}");
|
||||||
|
log("Bar printer: ${barPrinter?.toMap()}");
|
||||||
|
|
||||||
|
// Checker printer
|
||||||
|
if (checkerPrinter != null) {
|
||||||
|
try {
|
||||||
|
final printValue = await PrintDataoutputs
|
||||||
|
.instance
|
||||||
|
.printChecker(
|
||||||
|
widget.productQuantity,
|
||||||
|
orderx.tableNumber ?? "",
|
||||||
|
orderx.orderNumber ?? "",
|
||||||
|
'kasir',
|
||||||
|
checkerPrinter.paper.toIntegerFromText,
|
||||||
|
orderx.orderType ?? "",
|
||||||
|
);
|
||||||
|
|
||||||
|
await PrinterService().printWithPrinter(
|
||||||
|
checkerPrinter, printValue, context);
|
||||||
|
} catch (e) {
|
||||||
|
log("Error printing checker: $e");
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
SnackBar(
|
||||||
|
content: Text(
|
||||||
|
'Error printing checker: $e')),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Kitchen printer
|
||||||
|
if (kitchenPrinter != null) {
|
||||||
|
try {
|
||||||
|
final printValue = await PrintDataoutputs
|
||||||
|
.instance
|
||||||
|
.printKitchen(
|
||||||
|
widget.productQuantity,
|
||||||
|
orderx.tableNumber!,
|
||||||
|
orderx.orderNumber ?? "",
|
||||||
|
'kasir',
|
||||||
|
kitchenPrinter.paper.toIntegerFromText,
|
||||||
|
orderx.orderType ?? "",
|
||||||
|
);
|
||||||
|
|
||||||
|
await PrinterService().printWithPrinter(
|
||||||
|
kitchenPrinter, printValue, context);
|
||||||
|
} catch (e) {
|
||||||
|
log("Error printing kitchen order: $e");
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
SnackBar(
|
||||||
|
content: Text(
|
||||||
|
'Error printing kitchen order: $e')),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bar printer
|
||||||
|
if (barPrinter != null) {
|
||||||
|
try {
|
||||||
|
final printValue = await PrintDataoutputs
|
||||||
|
.instance
|
||||||
|
.printBar(
|
||||||
|
widget.productQuantity,
|
||||||
|
orderx.tableNumber ?? "",
|
||||||
|
orderx.orderNumber ?? "",
|
||||||
|
'kasir',
|
||||||
|
barPrinter.paper.toIntegerFromText,
|
||||||
|
orderx.orderType ?? "",
|
||||||
|
);
|
||||||
|
|
||||||
|
await PrinterService().printWithPrinter(
|
||||||
|
barPrinter, printValue, context);
|
||||||
|
} catch (e) {
|
||||||
|
log("Error printing bar order: $e");
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
SnackBar(
|
||||||
|
content: Text(
|
||||||
|
'Error printing bar order: $e')),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
label: 'Cetak',
|
||||||
|
icon: Icon(
|
||||||
|
Icons.print,
|
||||||
|
color: AppColors.white,
|
||||||
|
),
|
||||||
|
height: 44,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
],
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user