diff --git a/lib/application/void/void_form/void_form_bloc.dart b/lib/application/void/void_form/void_form_bloc.dart new file mode 100644 index 0000000..b1e3a4a --- /dev/null +++ b/lib/application/void/void_form/void_form_bloc.dart @@ -0,0 +1,120 @@ +import 'package:bloc/bloc.dart'; +import 'package:dartz/dartz.dart' hide Order; +import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:injectable/injectable.dart' hide Order; + +import '../../../common/types/void_type.dart'; +import '../../../domain/order/order.dart'; + +part 'void_form_event.dart'; +part 'void_form_state.dart'; +part 'void_form_bloc.freezed.dart'; + +@injectable +class VoidFormBloc extends Bloc { + final IOrderRepository _repository; + VoidFormBloc(this._repository) : super(VoidFormState.initial()) { + on(_onVoidFormEvent); + } + + Future _onVoidFormEvent( + VoidFormEvent event, + Emitter emit, + ) { + return event.map( + setOrder: (e) async { + List pendingItems = e.order.orderItems + .where((item) => item.status == 'pending') + .toList(); + + emit(state.copyWith(order: e.order, pendingItems: pendingItems)); + }, + voidTypeChanged: (e) async { + emit(state.copyWith(voidType: e.voidType)); + }, + voidReasonChanged: (e) async { + emit(state.copyWith(voidReason: e.voidReason)); + }, + itemQuantityChanged: (e) async { + final newQuantities = Map.from( + state.selectedItemQuantities, + ); + + if (e.quantity > 0) { + newQuantities[e.itemId] = e.quantity; + } else { + newQuantities.remove(e.itemId); + } + + // Recalculate total price + int newTotal = 0; + for (var entry in newQuantities.entries) { + final item = state.pendingItems.firstWhere( + (item) => item.id == entry.key, + ); + newTotal += item.unitPrice.toInt() * entry.value; + } + + emit( + state.copyWith( + selectedItemQuantities: newQuantities, + totalPriceVoid: newTotal, + ), + ); + }, + clearSelectedItem: (e) async { + emit(state.copyWith(selectedItemQuantities: {}, totalPriceVoid: 0)); + }, + submitted: (e) async { + Either failureOrVoid; + List voidItems = []; + + if (state.voidType.isItem) { + state.selectedItemQuantities.forEach((itemId, voidQty) { + final originalItem = state.order.orderItems.firstWhere( + (item) => item.id == itemId, + ); + + voidItems.add( + OrderItem( + id: originalItem.id, + orderId: originalItem.orderId, + productId: originalItem.productId, + productName: originalItem.productName, + productVariantId: originalItem.productVariantId, + productVariantName: originalItem.productVariantName, + quantity: voidQty, + unitPrice: originalItem.unitPrice, + totalPrice: (originalItem.unitPrice) * voidQty, + modifiers: originalItem.modifiers, + notes: originalItem.notes, + status: originalItem.status, + createdAt: originalItem.createdAt, + updatedAt: originalItem.updatedAt, + printerType: originalItem.printerType, + paidQuantity: originalItem.paidQuantity, + ), + ); + }); + } + + emit(state.copyWith(isSubmitting: true, failureOrVoid: none())); + + failureOrVoid = await _repository.voidOrder( + orderId: state.order.id, + reason: state.voidReason ?? '', + orderItems: voidItems, + type: state.voidType.toStringType(), + ); + + emit( + state.copyWith( + isSubmitting: false, + failureOrVoid: optionOf(failureOrVoid), + voidItems: state.voidType.isItem ? voidItems : state.pendingItems, + ), + ); + }, + ); + } +} diff --git a/lib/application/void/void_form/void_form_bloc.freezed.dart b/lib/application/void/void_form/void_form_bloc.freezed.dart new file mode 100644 index 0000000..baf0d23 --- /dev/null +++ b/lib/application/void/void_form/void_form_bloc.freezed.dart @@ -0,0 +1,1432 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'void_form_bloc.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models', +); + +/// @nodoc +mixin _$VoidFormEvent { + @optionalTypeArgs + TResult when({ + required TResult Function(Order order) setOrder, + required TResult Function(VoidType voidType) voidTypeChanged, + required TResult Function(String voidReason) voidReasonChanged, + required TResult Function(String itemId, int quantity) itemQuantityChanged, + required TResult Function() clearSelectedItem, + required TResult Function() submitted, + }) => throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(Order order)? setOrder, + TResult? Function(VoidType voidType)? voidTypeChanged, + TResult? Function(String voidReason)? voidReasonChanged, + TResult? Function(String itemId, int quantity)? itemQuantityChanged, + TResult? Function()? clearSelectedItem, + TResult? Function()? submitted, + }) => throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(Order order)? setOrder, + TResult Function(VoidType voidType)? voidTypeChanged, + TResult Function(String voidReason)? voidReasonChanged, + TResult Function(String itemId, int quantity)? itemQuantityChanged, + TResult Function()? clearSelectedItem, + TResult Function()? submitted, + required TResult orElse(), + }) => throw _privateConstructorUsedError; + @optionalTypeArgs + TResult map({ + required TResult Function(_SetOrder value) setOrder, + required TResult Function(_VoidTypeChanged value) voidTypeChanged, + required TResult Function(_VoidReasonChanged value) voidReasonChanged, + required TResult Function(_ItemQuantityChanged value) itemQuantityChanged, + required TResult Function(_ClearSelectedItem value) clearSelectedItem, + required TResult Function(_Submitted value) submitted, + }) => throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(_SetOrder value)? setOrder, + TResult? Function(_VoidTypeChanged value)? voidTypeChanged, + TResult? Function(_VoidReasonChanged value)? voidReasonChanged, + TResult? Function(_ItemQuantityChanged value)? itemQuantityChanged, + TResult? Function(_ClearSelectedItem value)? clearSelectedItem, + TResult? Function(_Submitted value)? submitted, + }) => throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeMap({ + TResult Function(_SetOrder value)? setOrder, + TResult Function(_VoidTypeChanged value)? voidTypeChanged, + TResult Function(_VoidReasonChanged value)? voidReasonChanged, + TResult Function(_ItemQuantityChanged value)? itemQuantityChanged, + TResult Function(_ClearSelectedItem value)? clearSelectedItem, + TResult Function(_Submitted value)? submitted, + required TResult orElse(), + }) => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $VoidFormEventCopyWith<$Res> { + factory $VoidFormEventCopyWith( + VoidFormEvent value, + $Res Function(VoidFormEvent) then, + ) = _$VoidFormEventCopyWithImpl<$Res, VoidFormEvent>; +} + +/// @nodoc +class _$VoidFormEventCopyWithImpl<$Res, $Val extends VoidFormEvent> + implements $VoidFormEventCopyWith<$Res> { + _$VoidFormEventCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of VoidFormEvent + /// with the given fields replaced by the non-null parameter values. +} + +/// @nodoc +abstract class _$$SetOrderImplCopyWith<$Res> { + factory _$$SetOrderImplCopyWith( + _$SetOrderImpl value, + $Res Function(_$SetOrderImpl) then, + ) = __$$SetOrderImplCopyWithImpl<$Res>; + @useResult + $Res call({Order order}); + + $OrderCopyWith<$Res> get order; +} + +/// @nodoc +class __$$SetOrderImplCopyWithImpl<$Res> + extends _$VoidFormEventCopyWithImpl<$Res, _$SetOrderImpl> + implements _$$SetOrderImplCopyWith<$Res> { + __$$SetOrderImplCopyWithImpl( + _$SetOrderImpl _value, + $Res Function(_$SetOrderImpl) _then, + ) : super(_value, _then); + + /// Create a copy of VoidFormEvent + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({Object? order = null}) { + return _then( + _$SetOrderImpl( + null == order + ? _value.order + : order // ignore: cast_nullable_to_non_nullable + as Order, + ), + ); + } + + /// Create a copy of VoidFormEvent + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $OrderCopyWith<$Res> get order { + return $OrderCopyWith<$Res>(_value.order, (value) { + return _then(_value.copyWith(order: value)); + }); + } +} + +/// @nodoc + +class _$SetOrderImpl implements _SetOrder { + const _$SetOrderImpl(this.order); + + @override + final Order order; + + @override + String toString() { + return 'VoidFormEvent.setOrder(order: $order)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$SetOrderImpl && + (identical(other.order, order) || other.order == order)); + } + + @override + int get hashCode => Object.hash(runtimeType, order); + + /// Create a copy of VoidFormEvent + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$SetOrderImplCopyWith<_$SetOrderImpl> get copyWith => + __$$SetOrderImplCopyWithImpl<_$SetOrderImpl>(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(Order order) setOrder, + required TResult Function(VoidType voidType) voidTypeChanged, + required TResult Function(String voidReason) voidReasonChanged, + required TResult Function(String itemId, int quantity) itemQuantityChanged, + required TResult Function() clearSelectedItem, + required TResult Function() submitted, + }) { + return setOrder(order); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(Order order)? setOrder, + TResult? Function(VoidType voidType)? voidTypeChanged, + TResult? Function(String voidReason)? voidReasonChanged, + TResult? Function(String itemId, int quantity)? itemQuantityChanged, + TResult? Function()? clearSelectedItem, + TResult? Function()? submitted, + }) { + return setOrder?.call(order); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(Order order)? setOrder, + TResult Function(VoidType voidType)? voidTypeChanged, + TResult Function(String voidReason)? voidReasonChanged, + TResult Function(String itemId, int quantity)? itemQuantityChanged, + TResult Function()? clearSelectedItem, + TResult Function()? submitted, + required TResult orElse(), + }) { + if (setOrder != null) { + return setOrder(order); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(_SetOrder value) setOrder, + required TResult Function(_VoidTypeChanged value) voidTypeChanged, + required TResult Function(_VoidReasonChanged value) voidReasonChanged, + required TResult Function(_ItemQuantityChanged value) itemQuantityChanged, + required TResult Function(_ClearSelectedItem value) clearSelectedItem, + required TResult Function(_Submitted value) submitted, + }) { + return setOrder(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(_SetOrder value)? setOrder, + TResult? Function(_VoidTypeChanged value)? voidTypeChanged, + TResult? Function(_VoidReasonChanged value)? voidReasonChanged, + TResult? Function(_ItemQuantityChanged value)? itemQuantityChanged, + TResult? Function(_ClearSelectedItem value)? clearSelectedItem, + TResult? Function(_Submitted value)? submitted, + }) { + return setOrder?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(_SetOrder value)? setOrder, + TResult Function(_VoidTypeChanged value)? voidTypeChanged, + TResult Function(_VoidReasonChanged value)? voidReasonChanged, + TResult Function(_ItemQuantityChanged value)? itemQuantityChanged, + TResult Function(_ClearSelectedItem value)? clearSelectedItem, + TResult Function(_Submitted value)? submitted, + required TResult orElse(), + }) { + if (setOrder != null) { + return setOrder(this); + } + return orElse(); + } +} + +abstract class _SetOrder implements VoidFormEvent { + const factory _SetOrder(final Order order) = _$SetOrderImpl; + + Order get order; + + /// Create a copy of VoidFormEvent + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + _$$SetOrderImplCopyWith<_$SetOrderImpl> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$VoidTypeChangedImplCopyWith<$Res> { + factory _$$VoidTypeChangedImplCopyWith( + _$VoidTypeChangedImpl value, + $Res Function(_$VoidTypeChangedImpl) then, + ) = __$$VoidTypeChangedImplCopyWithImpl<$Res>; + @useResult + $Res call({VoidType voidType}); +} + +/// @nodoc +class __$$VoidTypeChangedImplCopyWithImpl<$Res> + extends _$VoidFormEventCopyWithImpl<$Res, _$VoidTypeChangedImpl> + implements _$$VoidTypeChangedImplCopyWith<$Res> { + __$$VoidTypeChangedImplCopyWithImpl( + _$VoidTypeChangedImpl _value, + $Res Function(_$VoidTypeChangedImpl) _then, + ) : super(_value, _then); + + /// Create a copy of VoidFormEvent + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({Object? voidType = null}) { + return _then( + _$VoidTypeChangedImpl( + null == voidType + ? _value.voidType + : voidType // ignore: cast_nullable_to_non_nullable + as VoidType, + ), + ); + } +} + +/// @nodoc + +class _$VoidTypeChangedImpl implements _VoidTypeChanged { + const _$VoidTypeChangedImpl(this.voidType); + + @override + final VoidType voidType; + + @override + String toString() { + return 'VoidFormEvent.voidTypeChanged(voidType: $voidType)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$VoidTypeChangedImpl && + (identical(other.voidType, voidType) || + other.voidType == voidType)); + } + + @override + int get hashCode => Object.hash(runtimeType, voidType); + + /// Create a copy of VoidFormEvent + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$VoidTypeChangedImplCopyWith<_$VoidTypeChangedImpl> get copyWith => + __$$VoidTypeChangedImplCopyWithImpl<_$VoidTypeChangedImpl>( + this, + _$identity, + ); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(Order order) setOrder, + required TResult Function(VoidType voidType) voidTypeChanged, + required TResult Function(String voidReason) voidReasonChanged, + required TResult Function(String itemId, int quantity) itemQuantityChanged, + required TResult Function() clearSelectedItem, + required TResult Function() submitted, + }) { + return voidTypeChanged(voidType); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(Order order)? setOrder, + TResult? Function(VoidType voidType)? voidTypeChanged, + TResult? Function(String voidReason)? voidReasonChanged, + TResult? Function(String itemId, int quantity)? itemQuantityChanged, + TResult? Function()? clearSelectedItem, + TResult? Function()? submitted, + }) { + return voidTypeChanged?.call(voidType); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(Order order)? setOrder, + TResult Function(VoidType voidType)? voidTypeChanged, + TResult Function(String voidReason)? voidReasonChanged, + TResult Function(String itemId, int quantity)? itemQuantityChanged, + TResult Function()? clearSelectedItem, + TResult Function()? submitted, + required TResult orElse(), + }) { + if (voidTypeChanged != null) { + return voidTypeChanged(voidType); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(_SetOrder value) setOrder, + required TResult Function(_VoidTypeChanged value) voidTypeChanged, + required TResult Function(_VoidReasonChanged value) voidReasonChanged, + required TResult Function(_ItemQuantityChanged value) itemQuantityChanged, + required TResult Function(_ClearSelectedItem value) clearSelectedItem, + required TResult Function(_Submitted value) submitted, + }) { + return voidTypeChanged(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(_SetOrder value)? setOrder, + TResult? Function(_VoidTypeChanged value)? voidTypeChanged, + TResult? Function(_VoidReasonChanged value)? voidReasonChanged, + TResult? Function(_ItemQuantityChanged value)? itemQuantityChanged, + TResult? Function(_ClearSelectedItem value)? clearSelectedItem, + TResult? Function(_Submitted value)? submitted, + }) { + return voidTypeChanged?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(_SetOrder value)? setOrder, + TResult Function(_VoidTypeChanged value)? voidTypeChanged, + TResult Function(_VoidReasonChanged value)? voidReasonChanged, + TResult Function(_ItemQuantityChanged value)? itemQuantityChanged, + TResult Function(_ClearSelectedItem value)? clearSelectedItem, + TResult Function(_Submitted value)? submitted, + required TResult orElse(), + }) { + if (voidTypeChanged != null) { + return voidTypeChanged(this); + } + return orElse(); + } +} + +abstract class _VoidTypeChanged implements VoidFormEvent { + const factory _VoidTypeChanged(final VoidType voidType) = + _$VoidTypeChangedImpl; + + VoidType get voidType; + + /// Create a copy of VoidFormEvent + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + _$$VoidTypeChangedImplCopyWith<_$VoidTypeChangedImpl> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$VoidReasonChangedImplCopyWith<$Res> { + factory _$$VoidReasonChangedImplCopyWith( + _$VoidReasonChangedImpl value, + $Res Function(_$VoidReasonChangedImpl) then, + ) = __$$VoidReasonChangedImplCopyWithImpl<$Res>; + @useResult + $Res call({String voidReason}); +} + +/// @nodoc +class __$$VoidReasonChangedImplCopyWithImpl<$Res> + extends _$VoidFormEventCopyWithImpl<$Res, _$VoidReasonChangedImpl> + implements _$$VoidReasonChangedImplCopyWith<$Res> { + __$$VoidReasonChangedImplCopyWithImpl( + _$VoidReasonChangedImpl _value, + $Res Function(_$VoidReasonChangedImpl) _then, + ) : super(_value, _then); + + /// Create a copy of VoidFormEvent + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({Object? voidReason = null}) { + return _then( + _$VoidReasonChangedImpl( + null == voidReason + ? _value.voidReason + : voidReason // ignore: cast_nullable_to_non_nullable + as String, + ), + ); + } +} + +/// @nodoc + +class _$VoidReasonChangedImpl implements _VoidReasonChanged { + const _$VoidReasonChangedImpl(this.voidReason); + + @override + final String voidReason; + + @override + String toString() { + return 'VoidFormEvent.voidReasonChanged(voidReason: $voidReason)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$VoidReasonChangedImpl && + (identical(other.voidReason, voidReason) || + other.voidReason == voidReason)); + } + + @override + int get hashCode => Object.hash(runtimeType, voidReason); + + /// Create a copy of VoidFormEvent + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$VoidReasonChangedImplCopyWith<_$VoidReasonChangedImpl> get copyWith => + __$$VoidReasonChangedImplCopyWithImpl<_$VoidReasonChangedImpl>( + this, + _$identity, + ); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(Order order) setOrder, + required TResult Function(VoidType voidType) voidTypeChanged, + required TResult Function(String voidReason) voidReasonChanged, + required TResult Function(String itemId, int quantity) itemQuantityChanged, + required TResult Function() clearSelectedItem, + required TResult Function() submitted, + }) { + return voidReasonChanged(voidReason); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(Order order)? setOrder, + TResult? Function(VoidType voidType)? voidTypeChanged, + TResult? Function(String voidReason)? voidReasonChanged, + TResult? Function(String itemId, int quantity)? itemQuantityChanged, + TResult? Function()? clearSelectedItem, + TResult? Function()? submitted, + }) { + return voidReasonChanged?.call(voidReason); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(Order order)? setOrder, + TResult Function(VoidType voidType)? voidTypeChanged, + TResult Function(String voidReason)? voidReasonChanged, + TResult Function(String itemId, int quantity)? itemQuantityChanged, + TResult Function()? clearSelectedItem, + TResult Function()? submitted, + required TResult orElse(), + }) { + if (voidReasonChanged != null) { + return voidReasonChanged(voidReason); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(_SetOrder value) setOrder, + required TResult Function(_VoidTypeChanged value) voidTypeChanged, + required TResult Function(_VoidReasonChanged value) voidReasonChanged, + required TResult Function(_ItemQuantityChanged value) itemQuantityChanged, + required TResult Function(_ClearSelectedItem value) clearSelectedItem, + required TResult Function(_Submitted value) submitted, + }) { + return voidReasonChanged(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(_SetOrder value)? setOrder, + TResult? Function(_VoidTypeChanged value)? voidTypeChanged, + TResult? Function(_VoidReasonChanged value)? voidReasonChanged, + TResult? Function(_ItemQuantityChanged value)? itemQuantityChanged, + TResult? Function(_ClearSelectedItem value)? clearSelectedItem, + TResult? Function(_Submitted value)? submitted, + }) { + return voidReasonChanged?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(_SetOrder value)? setOrder, + TResult Function(_VoidTypeChanged value)? voidTypeChanged, + TResult Function(_VoidReasonChanged value)? voidReasonChanged, + TResult Function(_ItemQuantityChanged value)? itemQuantityChanged, + TResult Function(_ClearSelectedItem value)? clearSelectedItem, + TResult Function(_Submitted value)? submitted, + required TResult orElse(), + }) { + if (voidReasonChanged != null) { + return voidReasonChanged(this); + } + return orElse(); + } +} + +abstract class _VoidReasonChanged implements VoidFormEvent { + const factory _VoidReasonChanged(final String voidReason) = + _$VoidReasonChangedImpl; + + String get voidReason; + + /// Create a copy of VoidFormEvent + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + _$$VoidReasonChangedImplCopyWith<_$VoidReasonChangedImpl> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$ItemQuantityChangedImplCopyWith<$Res> { + factory _$$ItemQuantityChangedImplCopyWith( + _$ItemQuantityChangedImpl value, + $Res Function(_$ItemQuantityChangedImpl) then, + ) = __$$ItemQuantityChangedImplCopyWithImpl<$Res>; + @useResult + $Res call({String itemId, int quantity}); +} + +/// @nodoc +class __$$ItemQuantityChangedImplCopyWithImpl<$Res> + extends _$VoidFormEventCopyWithImpl<$Res, _$ItemQuantityChangedImpl> + implements _$$ItemQuantityChangedImplCopyWith<$Res> { + __$$ItemQuantityChangedImplCopyWithImpl( + _$ItemQuantityChangedImpl _value, + $Res Function(_$ItemQuantityChangedImpl) _then, + ) : super(_value, _then); + + /// Create a copy of VoidFormEvent + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({Object? itemId = null, Object? quantity = null}) { + return _then( + _$ItemQuantityChangedImpl( + itemId: null == itemId + ? _value.itemId + : itemId // ignore: cast_nullable_to_non_nullable + as String, + quantity: null == quantity + ? _value.quantity + : quantity // ignore: cast_nullable_to_non_nullable + as int, + ), + ); + } +} + +/// @nodoc + +class _$ItemQuantityChangedImpl implements _ItemQuantityChanged { + const _$ItemQuantityChangedImpl({ + required this.itemId, + required this.quantity, + }); + + @override + final String itemId; + @override + final int quantity; + + @override + String toString() { + return 'VoidFormEvent.itemQuantityChanged(itemId: $itemId, quantity: $quantity)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$ItemQuantityChangedImpl && + (identical(other.itemId, itemId) || other.itemId == itemId) && + (identical(other.quantity, quantity) || + other.quantity == quantity)); + } + + @override + int get hashCode => Object.hash(runtimeType, itemId, quantity); + + /// Create a copy of VoidFormEvent + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$ItemQuantityChangedImplCopyWith<_$ItemQuantityChangedImpl> get copyWith => + __$$ItemQuantityChangedImplCopyWithImpl<_$ItemQuantityChangedImpl>( + this, + _$identity, + ); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(Order order) setOrder, + required TResult Function(VoidType voidType) voidTypeChanged, + required TResult Function(String voidReason) voidReasonChanged, + required TResult Function(String itemId, int quantity) itemQuantityChanged, + required TResult Function() clearSelectedItem, + required TResult Function() submitted, + }) { + return itemQuantityChanged(itemId, quantity); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(Order order)? setOrder, + TResult? Function(VoidType voidType)? voidTypeChanged, + TResult? Function(String voidReason)? voidReasonChanged, + TResult? Function(String itemId, int quantity)? itemQuantityChanged, + TResult? Function()? clearSelectedItem, + TResult? Function()? submitted, + }) { + return itemQuantityChanged?.call(itemId, quantity); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(Order order)? setOrder, + TResult Function(VoidType voidType)? voidTypeChanged, + TResult Function(String voidReason)? voidReasonChanged, + TResult Function(String itemId, int quantity)? itemQuantityChanged, + TResult Function()? clearSelectedItem, + TResult Function()? submitted, + required TResult orElse(), + }) { + if (itemQuantityChanged != null) { + return itemQuantityChanged(itemId, quantity); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(_SetOrder value) setOrder, + required TResult Function(_VoidTypeChanged value) voidTypeChanged, + required TResult Function(_VoidReasonChanged value) voidReasonChanged, + required TResult Function(_ItemQuantityChanged value) itemQuantityChanged, + required TResult Function(_ClearSelectedItem value) clearSelectedItem, + required TResult Function(_Submitted value) submitted, + }) { + return itemQuantityChanged(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(_SetOrder value)? setOrder, + TResult? Function(_VoidTypeChanged value)? voidTypeChanged, + TResult? Function(_VoidReasonChanged value)? voidReasonChanged, + TResult? Function(_ItemQuantityChanged value)? itemQuantityChanged, + TResult? Function(_ClearSelectedItem value)? clearSelectedItem, + TResult? Function(_Submitted value)? submitted, + }) { + return itemQuantityChanged?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(_SetOrder value)? setOrder, + TResult Function(_VoidTypeChanged value)? voidTypeChanged, + TResult Function(_VoidReasonChanged value)? voidReasonChanged, + TResult Function(_ItemQuantityChanged value)? itemQuantityChanged, + TResult Function(_ClearSelectedItem value)? clearSelectedItem, + TResult Function(_Submitted value)? submitted, + required TResult orElse(), + }) { + if (itemQuantityChanged != null) { + return itemQuantityChanged(this); + } + return orElse(); + } +} + +abstract class _ItemQuantityChanged implements VoidFormEvent { + const factory _ItemQuantityChanged({ + required final String itemId, + required final int quantity, + }) = _$ItemQuantityChangedImpl; + + String get itemId; + int get quantity; + + /// Create a copy of VoidFormEvent + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + _$$ItemQuantityChangedImplCopyWith<_$ItemQuantityChangedImpl> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$ClearSelectedItemImplCopyWith<$Res> { + factory _$$ClearSelectedItemImplCopyWith( + _$ClearSelectedItemImpl value, + $Res Function(_$ClearSelectedItemImpl) then, + ) = __$$ClearSelectedItemImplCopyWithImpl<$Res>; +} + +/// @nodoc +class __$$ClearSelectedItemImplCopyWithImpl<$Res> + extends _$VoidFormEventCopyWithImpl<$Res, _$ClearSelectedItemImpl> + implements _$$ClearSelectedItemImplCopyWith<$Res> { + __$$ClearSelectedItemImplCopyWithImpl( + _$ClearSelectedItemImpl _value, + $Res Function(_$ClearSelectedItemImpl) _then, + ) : super(_value, _then); + + /// Create a copy of VoidFormEvent + /// with the given fields replaced by the non-null parameter values. +} + +/// @nodoc + +class _$ClearSelectedItemImpl implements _ClearSelectedItem { + const _$ClearSelectedItemImpl(); + + @override + String toString() { + return 'VoidFormEvent.clearSelectedItem()'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && other is _$ClearSelectedItemImpl); + } + + @override + int get hashCode => runtimeType.hashCode; + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(Order order) setOrder, + required TResult Function(VoidType voidType) voidTypeChanged, + required TResult Function(String voidReason) voidReasonChanged, + required TResult Function(String itemId, int quantity) itemQuantityChanged, + required TResult Function() clearSelectedItem, + required TResult Function() submitted, + }) { + return clearSelectedItem(); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(Order order)? setOrder, + TResult? Function(VoidType voidType)? voidTypeChanged, + TResult? Function(String voidReason)? voidReasonChanged, + TResult? Function(String itemId, int quantity)? itemQuantityChanged, + TResult? Function()? clearSelectedItem, + TResult? Function()? submitted, + }) { + return clearSelectedItem?.call(); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(Order order)? setOrder, + TResult Function(VoidType voidType)? voidTypeChanged, + TResult Function(String voidReason)? voidReasonChanged, + TResult Function(String itemId, int quantity)? itemQuantityChanged, + TResult Function()? clearSelectedItem, + TResult Function()? submitted, + required TResult orElse(), + }) { + if (clearSelectedItem != null) { + return clearSelectedItem(); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(_SetOrder value) setOrder, + required TResult Function(_VoidTypeChanged value) voidTypeChanged, + required TResult Function(_VoidReasonChanged value) voidReasonChanged, + required TResult Function(_ItemQuantityChanged value) itemQuantityChanged, + required TResult Function(_ClearSelectedItem value) clearSelectedItem, + required TResult Function(_Submitted value) submitted, + }) { + return clearSelectedItem(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(_SetOrder value)? setOrder, + TResult? Function(_VoidTypeChanged value)? voidTypeChanged, + TResult? Function(_VoidReasonChanged value)? voidReasonChanged, + TResult? Function(_ItemQuantityChanged value)? itemQuantityChanged, + TResult? Function(_ClearSelectedItem value)? clearSelectedItem, + TResult? Function(_Submitted value)? submitted, + }) { + return clearSelectedItem?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(_SetOrder value)? setOrder, + TResult Function(_VoidTypeChanged value)? voidTypeChanged, + TResult Function(_VoidReasonChanged value)? voidReasonChanged, + TResult Function(_ItemQuantityChanged value)? itemQuantityChanged, + TResult Function(_ClearSelectedItem value)? clearSelectedItem, + TResult Function(_Submitted value)? submitted, + required TResult orElse(), + }) { + if (clearSelectedItem != null) { + return clearSelectedItem(this); + } + return orElse(); + } +} + +abstract class _ClearSelectedItem implements VoidFormEvent { + const factory _ClearSelectedItem() = _$ClearSelectedItemImpl; +} + +/// @nodoc +abstract class _$$SubmittedImplCopyWith<$Res> { + factory _$$SubmittedImplCopyWith( + _$SubmittedImpl value, + $Res Function(_$SubmittedImpl) then, + ) = __$$SubmittedImplCopyWithImpl<$Res>; +} + +/// @nodoc +class __$$SubmittedImplCopyWithImpl<$Res> + extends _$VoidFormEventCopyWithImpl<$Res, _$SubmittedImpl> + implements _$$SubmittedImplCopyWith<$Res> { + __$$SubmittedImplCopyWithImpl( + _$SubmittedImpl _value, + $Res Function(_$SubmittedImpl) _then, + ) : super(_value, _then); + + /// Create a copy of VoidFormEvent + /// with the given fields replaced by the non-null parameter values. +} + +/// @nodoc + +class _$SubmittedImpl implements _Submitted { + const _$SubmittedImpl(); + + @override + String toString() { + return 'VoidFormEvent.submitted()'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && other is _$SubmittedImpl); + } + + @override + int get hashCode => runtimeType.hashCode; + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(Order order) setOrder, + required TResult Function(VoidType voidType) voidTypeChanged, + required TResult Function(String voidReason) voidReasonChanged, + required TResult Function(String itemId, int quantity) itemQuantityChanged, + required TResult Function() clearSelectedItem, + required TResult Function() submitted, + }) { + return submitted(); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(Order order)? setOrder, + TResult? Function(VoidType voidType)? voidTypeChanged, + TResult? Function(String voidReason)? voidReasonChanged, + TResult? Function(String itemId, int quantity)? itemQuantityChanged, + TResult? Function()? clearSelectedItem, + TResult? Function()? submitted, + }) { + return submitted?.call(); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(Order order)? setOrder, + TResult Function(VoidType voidType)? voidTypeChanged, + TResult Function(String voidReason)? voidReasonChanged, + TResult Function(String itemId, int quantity)? itemQuantityChanged, + TResult Function()? clearSelectedItem, + TResult Function()? submitted, + required TResult orElse(), + }) { + if (submitted != null) { + return submitted(); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(_SetOrder value) setOrder, + required TResult Function(_VoidTypeChanged value) voidTypeChanged, + required TResult Function(_VoidReasonChanged value) voidReasonChanged, + required TResult Function(_ItemQuantityChanged value) itemQuantityChanged, + required TResult Function(_ClearSelectedItem value) clearSelectedItem, + required TResult Function(_Submitted value) submitted, + }) { + return submitted(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(_SetOrder value)? setOrder, + TResult? Function(_VoidTypeChanged value)? voidTypeChanged, + TResult? Function(_VoidReasonChanged value)? voidReasonChanged, + TResult? Function(_ItemQuantityChanged value)? itemQuantityChanged, + TResult? Function(_ClearSelectedItem value)? clearSelectedItem, + TResult? Function(_Submitted value)? submitted, + }) { + return submitted?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(_SetOrder value)? setOrder, + TResult Function(_VoidTypeChanged value)? voidTypeChanged, + TResult Function(_VoidReasonChanged value)? voidReasonChanged, + TResult Function(_ItemQuantityChanged value)? itemQuantityChanged, + TResult Function(_ClearSelectedItem value)? clearSelectedItem, + TResult Function(_Submitted value)? submitted, + required TResult orElse(), + }) { + if (submitted != null) { + return submitted(this); + } + return orElse(); + } +} + +abstract class _Submitted implements VoidFormEvent { + const factory _Submitted() = _$SubmittedImpl; +} + +/// @nodoc +mixin _$VoidFormState { + Order get order => throw _privateConstructorUsedError; + List get pendingItems => throw _privateConstructorUsedError; + List get voidItems => throw _privateConstructorUsedError; + VoidType get voidType => throw _privateConstructorUsedError; + Map get selectedItemQuantities => + throw _privateConstructorUsedError; + String? get voidReason => throw _privateConstructorUsedError; + int get totalPriceVoid => throw _privateConstructorUsedError; + Option> get failureOrVoid => + throw _privateConstructorUsedError; + bool get isSubmitting => throw _privateConstructorUsedError; + + /// Create a copy of VoidFormState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $VoidFormStateCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $VoidFormStateCopyWith<$Res> { + factory $VoidFormStateCopyWith( + VoidFormState value, + $Res Function(VoidFormState) then, + ) = _$VoidFormStateCopyWithImpl<$Res, VoidFormState>; + @useResult + $Res call({ + Order order, + List pendingItems, + List voidItems, + VoidType voidType, + Map selectedItemQuantities, + String? voidReason, + int totalPriceVoid, + Option> failureOrVoid, + bool isSubmitting, + }); + + $OrderCopyWith<$Res> get order; +} + +/// @nodoc +class _$VoidFormStateCopyWithImpl<$Res, $Val extends VoidFormState> + implements $VoidFormStateCopyWith<$Res> { + _$VoidFormStateCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of VoidFormState + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? order = null, + Object? pendingItems = null, + Object? voidItems = null, + Object? voidType = null, + Object? selectedItemQuantities = null, + Object? voidReason = freezed, + Object? totalPriceVoid = null, + Object? failureOrVoid = null, + Object? isSubmitting = null, + }) { + return _then( + _value.copyWith( + order: null == order + ? _value.order + : order // ignore: cast_nullable_to_non_nullable + as Order, + pendingItems: null == pendingItems + ? _value.pendingItems + : pendingItems // ignore: cast_nullable_to_non_nullable + as List, + voidItems: null == voidItems + ? _value.voidItems + : voidItems // ignore: cast_nullable_to_non_nullable + as List, + voidType: null == voidType + ? _value.voidType + : voidType // ignore: cast_nullable_to_non_nullable + as VoidType, + selectedItemQuantities: null == selectedItemQuantities + ? _value.selectedItemQuantities + : selectedItemQuantities // ignore: cast_nullable_to_non_nullable + as Map, + voidReason: freezed == voidReason + ? _value.voidReason + : voidReason // ignore: cast_nullable_to_non_nullable + as String?, + totalPriceVoid: null == totalPriceVoid + ? _value.totalPriceVoid + : totalPriceVoid // ignore: cast_nullable_to_non_nullable + as int, + failureOrVoid: null == failureOrVoid + ? _value.failureOrVoid + : failureOrVoid // ignore: cast_nullable_to_non_nullable + as Option>, + isSubmitting: null == isSubmitting + ? _value.isSubmitting + : isSubmitting // ignore: cast_nullable_to_non_nullable + as bool, + ) + as $Val, + ); + } + + /// Create a copy of VoidFormState + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $OrderCopyWith<$Res> get order { + return $OrderCopyWith<$Res>(_value.order, (value) { + return _then(_value.copyWith(order: value) as $Val); + }); + } +} + +/// @nodoc +abstract class _$$VoidFormStateImplCopyWith<$Res> + implements $VoidFormStateCopyWith<$Res> { + factory _$$VoidFormStateImplCopyWith( + _$VoidFormStateImpl value, + $Res Function(_$VoidFormStateImpl) then, + ) = __$$VoidFormStateImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({ + Order order, + List pendingItems, + List voidItems, + VoidType voidType, + Map selectedItemQuantities, + String? voidReason, + int totalPriceVoid, + Option> failureOrVoid, + bool isSubmitting, + }); + + @override + $OrderCopyWith<$Res> get order; +} + +/// @nodoc +class __$$VoidFormStateImplCopyWithImpl<$Res> + extends _$VoidFormStateCopyWithImpl<$Res, _$VoidFormStateImpl> + implements _$$VoidFormStateImplCopyWith<$Res> { + __$$VoidFormStateImplCopyWithImpl( + _$VoidFormStateImpl _value, + $Res Function(_$VoidFormStateImpl) _then, + ) : super(_value, _then); + + /// Create a copy of VoidFormState + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? order = null, + Object? pendingItems = null, + Object? voidItems = null, + Object? voidType = null, + Object? selectedItemQuantities = null, + Object? voidReason = freezed, + Object? totalPriceVoid = null, + Object? failureOrVoid = null, + Object? isSubmitting = null, + }) { + return _then( + _$VoidFormStateImpl( + order: null == order + ? _value.order + : order // ignore: cast_nullable_to_non_nullable + as Order, + pendingItems: null == pendingItems + ? _value._pendingItems + : pendingItems // ignore: cast_nullable_to_non_nullable + as List, + voidItems: null == voidItems + ? _value._voidItems + : voidItems // ignore: cast_nullable_to_non_nullable + as List, + voidType: null == voidType + ? _value.voidType + : voidType // ignore: cast_nullable_to_non_nullable + as VoidType, + selectedItemQuantities: null == selectedItemQuantities + ? _value._selectedItemQuantities + : selectedItemQuantities // ignore: cast_nullable_to_non_nullable + as Map, + voidReason: freezed == voidReason + ? _value.voidReason + : voidReason // ignore: cast_nullable_to_non_nullable + as String?, + totalPriceVoid: null == totalPriceVoid + ? _value.totalPriceVoid + : totalPriceVoid // ignore: cast_nullable_to_non_nullable + as int, + failureOrVoid: null == failureOrVoid + ? _value.failureOrVoid + : failureOrVoid // ignore: cast_nullable_to_non_nullable + as Option>, + isSubmitting: null == isSubmitting + ? _value.isSubmitting + : isSubmitting // ignore: cast_nullable_to_non_nullable + as bool, + ), + ); + } +} + +/// @nodoc + +class _$VoidFormStateImpl implements _VoidFormState { + _$VoidFormStateImpl({ + required this.order, + required final List pendingItems, + required final List voidItems, + required this.voidType, + required final Map selectedItemQuantities, + this.voidReason, + required this.totalPriceVoid, + required this.failureOrVoid, + this.isSubmitting = false, + }) : _pendingItems = pendingItems, + _voidItems = voidItems, + _selectedItemQuantities = selectedItemQuantities; + + @override + final Order order; + final List _pendingItems; + @override + List get pendingItems { + if (_pendingItems is EqualUnmodifiableListView) return _pendingItems; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_pendingItems); + } + + final List _voidItems; + @override + List get voidItems { + if (_voidItems is EqualUnmodifiableListView) return _voidItems; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_voidItems); + } + + @override + final VoidType voidType; + final Map _selectedItemQuantities; + @override + Map get selectedItemQuantities { + if (_selectedItemQuantities is EqualUnmodifiableMapView) + return _selectedItemQuantities; + // ignore: implicit_dynamic_type + return EqualUnmodifiableMapView(_selectedItemQuantities); + } + + @override + final String? voidReason; + @override + final int totalPriceVoid; + @override + final Option> failureOrVoid; + @override + @JsonKey() + final bool isSubmitting; + + @override + String toString() { + return 'VoidFormState(order: $order, pendingItems: $pendingItems, voidItems: $voidItems, voidType: $voidType, selectedItemQuantities: $selectedItemQuantities, voidReason: $voidReason, totalPriceVoid: $totalPriceVoid, failureOrVoid: $failureOrVoid, isSubmitting: $isSubmitting)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$VoidFormStateImpl && + (identical(other.order, order) || other.order == order) && + const DeepCollectionEquality().equals( + other._pendingItems, + _pendingItems, + ) && + const DeepCollectionEquality().equals( + other._voidItems, + _voidItems, + ) && + (identical(other.voidType, voidType) || + other.voidType == voidType) && + const DeepCollectionEquality().equals( + other._selectedItemQuantities, + _selectedItemQuantities, + ) && + (identical(other.voidReason, voidReason) || + other.voidReason == voidReason) && + (identical(other.totalPriceVoid, totalPriceVoid) || + other.totalPriceVoid == totalPriceVoid) && + (identical(other.failureOrVoid, failureOrVoid) || + other.failureOrVoid == failureOrVoid) && + (identical(other.isSubmitting, isSubmitting) || + other.isSubmitting == isSubmitting)); + } + + @override + int get hashCode => Object.hash( + runtimeType, + order, + const DeepCollectionEquality().hash(_pendingItems), + const DeepCollectionEquality().hash(_voidItems), + voidType, + const DeepCollectionEquality().hash(_selectedItemQuantities), + voidReason, + totalPriceVoid, + failureOrVoid, + isSubmitting, + ); + + /// Create a copy of VoidFormState + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$VoidFormStateImplCopyWith<_$VoidFormStateImpl> get copyWith => + __$$VoidFormStateImplCopyWithImpl<_$VoidFormStateImpl>(this, _$identity); +} + +abstract class _VoidFormState implements VoidFormState { + factory _VoidFormState({ + required final Order order, + required final List pendingItems, + required final List voidItems, + required final VoidType voidType, + required final Map selectedItemQuantities, + final String? voidReason, + required final int totalPriceVoid, + required final Option> failureOrVoid, + final bool isSubmitting, + }) = _$VoidFormStateImpl; + + @override + Order get order; + @override + List get pendingItems; + @override + List get voidItems; + @override + VoidType get voidType; + @override + Map get selectedItemQuantities; + @override + String? get voidReason; + @override + int get totalPriceVoid; + @override + Option> get failureOrVoid; + @override + bool get isSubmitting; + + /// Create a copy of VoidFormState + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$VoidFormStateImplCopyWith<_$VoidFormStateImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/lib/application/void/void_form/void_form_event.dart b/lib/application/void/void_form/void_form_event.dart new file mode 100644 index 0000000..3b78b25 --- /dev/null +++ b/lib/application/void/void_form/void_form_event.dart @@ -0,0 +1,16 @@ +part of 'void_form_bloc.dart'; + +@freezed +class VoidFormEvent with _$VoidFormEvent { + const factory VoidFormEvent.setOrder(Order order) = _SetOrder; + const factory VoidFormEvent.voidTypeChanged(VoidType voidType) = + _VoidTypeChanged; + const factory VoidFormEvent.voidReasonChanged(String voidReason) = + _VoidReasonChanged; + const factory VoidFormEvent.itemQuantityChanged({ + required String itemId, + required int quantity, + }) = _ItemQuantityChanged; + const factory VoidFormEvent.clearSelectedItem() = _ClearSelectedItem; + const factory VoidFormEvent.submitted() = _Submitted; +} diff --git a/lib/application/void/void_form/void_form_state.dart b/lib/application/void/void_form/void_form_state.dart new file mode 100644 index 0000000..b094324 --- /dev/null +++ b/lib/application/void/void_form/void_form_state.dart @@ -0,0 +1,26 @@ +part of 'void_form_bloc.dart'; + +@freezed +class VoidFormState with _$VoidFormState { + factory VoidFormState({ + required Order order, + required List pendingItems, + required List voidItems, + required VoidType voidType, + required Map selectedItemQuantities, + String? voidReason, + required int totalPriceVoid, + required Option> failureOrVoid, + @Default(false) bool isSubmitting, + }) = _VoidFormState; + + factory VoidFormState.initial() => VoidFormState( + order: Order.empty(), + voidType: VoidType.all, + selectedItemQuantities: {}, + pendingItems: [], + totalPriceVoid: 0, + failureOrVoid: none(), + voidItems: [], + ); +} diff --git a/lib/common/extension/extension.dart b/lib/common/extension/extension.dart index ebb80e1..c699ca8 100644 --- a/lib/common/extension/extension.dart +++ b/lib/common/extension/extension.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:intl/intl.dart'; import '../../domain/table/table.dart'; +import '../types/void_type.dart'; part 'build_context_extension.dart'; part 'int_extension.dart'; diff --git a/lib/common/extension/string_extension.dart b/lib/common/extension/string_extension.dart index 0b937b3..802c567 100644 --- a/lib/common/extension/string_extension.dart +++ b/lib/common/extension/string_extension.dart @@ -36,4 +36,15 @@ extension StringX on String { return TableStatusType.unknown; } } + + VoidType toVoidType() { + switch (this) { + case 'all': + return VoidType.all; + case 'item': + return VoidType.item; + default: + return VoidType.unknown; + } + } } diff --git a/lib/common/types/void_type.dart b/lib/common/types/void_type.dart new file mode 100644 index 0000000..5220869 --- /dev/null +++ b/lib/common/types/void_type.dart @@ -0,0 +1,12 @@ +enum VoidType { all, item, unknown } + +extension VoidTypeX on VoidType { + String toStringType() => switch (this) { + VoidType.all => 'ALL', + VoidType.item => 'ITEM', + VoidType.unknown => 'unknown', + }; + + bool get isAll => this == VoidType.all; + bool get isItem => this == VoidType.item; +} diff --git a/lib/domain/order/repositories/i_order_repository.dart b/lib/domain/order/repositories/i_order_repository.dart index 8aab055..e3f512a 100644 --- a/lib/domain/order/repositories/i_order_repository.dart +++ b/lib/domain/order/repositories/i_order_repository.dart @@ -29,4 +29,11 @@ abstract class IOrderRepository { Future> createPayment({ required PaymentRequest request, }); + + Future> voidOrder({ + required String orderId, + required String reason, + String type = "ITEM", // TYPE: ALL, ITEM + required List orderItems, + }); } diff --git a/lib/infrastructure/order/datasources/remote_data_provider.dart b/lib/infrastructure/order/datasources/remote_data_provider.dart index b641942..42eaed4 100644 --- a/lib/infrastructure/order/datasources/remote_data_provider.dart +++ b/lib/infrastructure/order/datasources/remote_data_provider.dart @@ -1,5 +1,6 @@ import 'dart:developer'; +import 'package:dartz/dartz.dart'; import 'package:data_channel/data_channel.dart'; import 'package:injectable/injectable.dart'; import 'package:intl/intl.dart'; @@ -202,4 +203,37 @@ class OrderRemoteDataProvider { return DC.error(OrderFailure.serverError(e)); } } + + Future> voidOrder({ + required String orderId, + required String reason, + String type = "ITEM", // TYPE: ALL, ITEM + required List orderItems, + }) async { + try { + final response = await _apiClient.post( + '${ApiPath.orders}/void', + data: { + 'order_id': orderId, + 'type': orderItems.isEmpty ? "ALL" : type, + 'reason': reason, + "items": orderItems + .map( + (item) => {'order_item_id': item.id, "quantity": item.quantity}, + ) + .toList(), + }, + headers: getAuthorizationHeader(), + ); + + if (response.data['success'] == false) { + return DC.error(OrderFailure.unexpectedError()); + } + + return DC.data(unit); + } on ApiFailure catch (e, s) { + log('voidOrderError', name: _logName, error: e, stackTrace: s); + return DC.error(OrderFailure.serverError(e)); + } + } } diff --git a/lib/infrastructure/order/dtos/order_dto.dart b/lib/infrastructure/order/dtos/order_dto.dart index 0b713cf..2b68eef 100644 --- a/lib/infrastructure/order/dtos/order_dto.dart +++ b/lib/infrastructure/order/dtos/order_dto.dart @@ -136,4 +136,23 @@ class OrderItemDto with _$OrderItemDto { printerType: printerType ?? '', paidQuantity: paidQuantity ?? 0, ); + + factory OrderItemDto.fromDomain(OrderItem orderItem) => OrderItemDto( + id: orderItem.id, + orderId: orderItem.orderId, + productId: orderItem.productId, + productName: orderItem.productName, + productVariantId: orderItem.productVariantId, + productVariantName: orderItem.productVariantName, + quantity: orderItem.quantity, + unitPrice: orderItem.unitPrice, + totalPrice: orderItem.totalPrice, + modifiers: orderItem.modifiers, + notes: orderItem.notes, + status: orderItem.status, + createdAt: orderItem.createdAt.toIso8601String(), + updatedAt: orderItem.updatedAt.toIso8601String(), + printerType: orderItem.printerType, + paidQuantity: orderItem.paidQuantity, + ); } diff --git a/lib/infrastructure/order/dtos/order_request_dto.dart b/lib/infrastructure/order/dtos/order_request_dto.dart index 8ee3ceb..761230f 100644 --- a/lib/infrastructure/order/dtos/order_request_dto.dart +++ b/lib/infrastructure/order/dtos/order_request_dto.dart @@ -98,11 +98,18 @@ class OrderItemRequestDto with _$OrderItemRequestDto { notes: request.notes, ); - Map toRequest() => { - "product_id": productId, - "product_variant_id": productVariantId, - "quantity": quantity, - "unit_price": unitPrice, - "notes": notes, - }; + Map toRequest() { + Map data = { + "product_id": productId, + "quantity": quantity, + "unit_price": unitPrice, + "notes": notes, + }; + + if (productVariantId != null && productVariantId != '') { + data["product_variant_id"] = productVariantId; + } + + return data; + } } diff --git a/lib/infrastructure/order/repositories/order_repository.dart b/lib/infrastructure/order/repositories/order_repository.dart index 2068693..1b37b98 100644 --- a/lib/infrastructure/order/repositories/order_repository.dart +++ b/lib/infrastructure/order/repositories/order_repository.dart @@ -151,4 +151,30 @@ class OrderRepository implements IOrderRepository { return left(const OrderFailure.unexpectedError()); } } + + @override + Future> voidOrder({ + required String orderId, + required String reason, + String type = "ITEM", + required List orderItems, + }) async { + try { + final result = await _dataProvider.voidOrder( + orderId: orderId, + reason: reason, + type: type, + orderItems: orderItems.map((e) => OrderItemDto.fromDomain(e)).toList(), + ); + + if (result.hasError) { + return left(result.error!); + } + + return right(unit); + } catch (e) { + log('voidOrderError', name: _logName, error: e); + return left(const OrderFailure.unexpectedError()); + } + } } diff --git a/lib/injection.config.dart b/lib/injection.config.dart index 552da7a..a29b471 100644 --- a/lib/injection.config.dart +++ b/lib/injection.config.dart @@ -35,6 +35,8 @@ import 'package:apskel_pos_flutter_v2/application/table/table_form/table_form_bl as _i248; import 'package:apskel_pos_flutter_v2/application/table/table_loader/table_loader_bloc.dart' as _i424; +import 'package:apskel_pos_flutter_v2/application/void/void_form/void_form_bloc.dart' + as _i822; import 'package:apskel_pos_flutter_v2/common/api/api_client.dart' as _i457; import 'package:apskel_pos_flutter_v2/common/database/database_helper.dart' as _i487; @@ -237,6 +239,9 @@ extension GetItInjectableX on _i174.GetIt { gh.factory<_i194.PaymentFormBloc>( () => _i194.PaymentFormBloc(gh<_i299.IOrderRepository>()), ); + gh.factory<_i822.VoidFormBloc>( + () => _i822.VoidFormBloc(gh<_i299.IOrderRepository>()), + ); gh.factory<_i683.CustomerLoaderBloc>( () => _i683.CustomerLoaderBloc(gh<_i143.ICustomerRepository>()), ); diff --git a/lib/presentation/app_widget.dart b/lib/presentation/app_widget.dart index c1bf2a5..b0c71bf 100644 --- a/lib/presentation/app_widget.dart +++ b/lib/presentation/app_widget.dart @@ -12,6 +12,7 @@ import '../application/payment_method/payment_method_loader/payment_method_loade import '../application/product/product_loader/product_loader_bloc.dart'; import '../application/table/table_form/table_form_bloc.dart'; import '../application/table/table_loader/table_loader_bloc.dart'; +import '../application/void/void_form/void_form_bloc.dart'; import '../common/theme/theme.dart'; import '../common/constant/app_constant.dart'; import '../injection.dart'; @@ -43,6 +44,7 @@ class _AppWidgetState extends State { BlocProvider(create: (context) => getIt()), BlocProvider(create: (context) => getIt()), BlocProvider(create: (context) => getIt()), + BlocProvider(create: (context) => getIt()), ], child: MaterialApp.router( debugShowCheckedModeBanner: false, diff --git a/lib/presentation/components/dialog/order/order_void_confirm_dialog.dart b/lib/presentation/components/dialog/order/order_void_confirm_dialog.dart new file mode 100644 index 0000000..63422a9 --- /dev/null +++ b/lib/presentation/components/dialog/order/order_void_confirm_dialog.dart @@ -0,0 +1,263 @@ +import 'package:auto_route/auto_route.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; + +import '../../../../application/void/void_form/void_form_bloc.dart'; +import '../../../../common/extension/extension.dart'; +import '../../../../common/theme/theme.dart'; +import '../../../../common/types/void_type.dart'; +import '../../button/button.dart'; +import '../../spaces/space.dart'; +import '../dialog.dart'; + +class OrderVoidConfirmDialog extends StatelessWidget { + final String message; + const OrderVoidConfirmDialog({super.key, required this.message}); + + @override + Widget build(BuildContext context) { + return BlocBuilder( + builder: (context, state) { + return CustomModalDialog( + title: 'Konfirmasi Void', + subtitle: 'Tindakan ini tidak dapat dibatalkan', + contentPadding: EdgeInsets.all(16), + bottom: Padding( + padding: const EdgeInsets.all(16.0), + child: Row( + children: [ + Expanded( + child: AppElevatedButton.outlined( + onPressed: () => context.maybePop(), + label: 'Batal', + ), + ), + const SpaceWidth(16), + Expanded( + child: AppElevatedButton.filled( + onPressed: () { + context.read().add( + VoidFormEvent.submitted(), + ); + }, + label: state.voidType.isAll ? 'Void Pesanan' : 'Void Item', + isLoading: state.isSubmitting, + ), + ), + ], + ), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + message, + style: AppStyle.md.copyWith( + height: 1, + color: AppColor.textPrimary, + ), + ), + + if (state.voidType.isItem && + state.selectedItemQuantities.isNotEmpty) ...[ + SizedBox(height: 16), + + // Items section + Container( + width: double.infinity, + decoration: BoxDecoration( + color: AppColor.primary.withOpacity(0.1), + borderRadius: BorderRadius.circular(12), + border: Border.all(color: AppColor.primary), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: EdgeInsets.all(16), + child: Row( + children: [ + Container( + padding: EdgeInsets.all(6), + decoration: BoxDecoration( + color: AppColor.primary.withOpacity(0.2), + borderRadius: BorderRadius.circular(6), + ), + child: Icon( + Icons.list_alt_rounded, + color: AppColor.primary, + size: 16, + ), + ), + SizedBox(width: 8), + Text( + 'Item yang akan divoid:', + style: AppStyle.md.copyWith( + fontWeight: FontWeight.bold, + color: AppColor.primary, + ), + ), + ], + ), + ), + Container( + constraints: BoxConstraints(maxHeight: 120), + child: Scrollbar( + child: SingleChildScrollView( + padding: EdgeInsets.only( + left: 16, + right: 16, + bottom: 16, + ), + child: Column( + children: state.selectedItemQuantities.entries + .map((entry) { + final item = state.order.orderItems + .firstWhere( + (item) => item.id == entry.key, + ); + return Container( + margin: EdgeInsets.only(bottom: 6), + padding: EdgeInsets.all(10), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(6), + boxShadow: [ + BoxShadow( + color: Colors.black.withOpacity( + 0.03, + ), + blurRadius: 2, + offset: Offset(0, 1), + ), + ], + ), + child: Row( + children: [ + Container( + width: 6, + height: 6, + decoration: BoxDecoration( + color: AppColor.primary, + shape: BoxShape.circle, + ), + ), + SizedBox(width: 8), + Expanded( + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Text( + item.productName, + style: AppStyle.sm.copyWith( + fontWeight: FontWeight.w600, + ), + maxLines: 1, + overflow: + TextOverflow.ellipsis, + ), + Text( + '${entry.value} qty', + style: AppStyle.xs.copyWith( + fontSize: 10, + color: + AppColor.textSecondary, + ), + ), + ], + ), + ), + Container( + padding: EdgeInsets.symmetric( + horizontal: 6, + vertical: 2, + ), + decoration: BoxDecoration( + color: AppColor.primary + .withOpacity(0.2), + borderRadius: + BorderRadius.circular(4), + ), + child: Text( + ((item.unitPrice) * entry.value) + .currencyFormatRpV2, + style: AppStyle.xs.copyWith( + fontWeight: FontWeight.bold, + color: AppColor.primary, + ), + ), + ), + ], + ), + ); + }) + .toList(), + ), + ), + ), + ), + ], + ), + ), + ], + SizedBox(height: 16), + // Reason section + Container( + width: double.infinity, + padding: EdgeInsets.all(12), + decoration: BoxDecoration( + color: Colors.blue[50], + borderRadius: BorderRadius.circular(8), + border: Border.all(color: Colors.blue[200]!), + ), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + padding: EdgeInsets.all(6), + decoration: BoxDecoration( + color: AppColor.info.withOpacity(0.1), + borderRadius: BorderRadius.circular(6), + ), + child: Icon( + Icons.note_alt_rounded, + color: AppColor.info, + size: 16, + ), + ), + SizedBox(width: 8), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'Alasan:', + style: AppStyle.sm.copyWith( + fontWeight: FontWeight.w600, + color: AppColor.info, + fontSize: 12, + ), + ), + SizedBox(height: 2), + Text( + state.voidReason ?? "", + style: TextStyle( + fontStyle: FontStyle.italic, + color: AppColor.info.withOpacity(0.7), + fontSize: 12, + ), + ), + ], + ), + ), + ], + ), + ), + ], + ), + ); + }, + ); + } +} diff --git a/lib/presentation/components/field/text_field.dart b/lib/presentation/components/field/text_field.dart index beec9af..055b282 100644 --- a/lib/presentation/components/field/text_field.dart +++ b/lib/presentation/components/field/text_field.dart @@ -52,7 +52,7 @@ class AppTextFormField extends StatelessWidget { maxLines: maxLines, validator: validator, decoration: InputDecoration( - contentPadding: EdgeInsets.symmetric(vertical: 0, horizontal: 12), + contentPadding: EdgeInsets.symmetric(vertical: 4, horizontal: 12), prefixIcon: prefixIcon, suffixIcon: suffixIcon, hintText: label, diff --git a/lib/presentation/pages/order/widgets/order_right_panel.dart b/lib/presentation/pages/order/widgets/order_right_panel.dart index a6ec3be..ff5b3d7 100644 --- a/lib/presentation/pages/order/widgets/order_right_panel.dart +++ b/lib/presentation/pages/order/widgets/order_right_panel.dart @@ -87,7 +87,9 @@ class OrderRightPanel extends StatelessWidget { SpaceWidth(8), if (state.selectedOrder?.status == 'pending') ...[ AppElevatedButton.outlined( - onPressed: () {}, + onPressed: () => context.router.push( + VoidRoute(order: state.selectedOrder!), + ), label: 'Void', icon: Icon(Icons.undo), ), diff --git a/lib/presentation/pages/void/void_page.dart b/lib/presentation/pages/void/void_page.dart new file mode 100644 index 0000000..fea07a9 --- /dev/null +++ b/lib/presentation/pages/void/void_page.dart @@ -0,0 +1,63 @@ +import 'package:auto_route/auto_route.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; + +import '../../../application/void/void_form/void_form_bloc.dart'; +import '../../../common/theme/theme.dart'; +import '../../../domain/order/order.dart'; +import '../../components/spaces/space.dart'; +import '../../components/toast/flushbar.dart'; +import 'widgets/void_left_panel.dart'; +import 'widgets/void_right_panel.dart'; + +@RoutePage() +class VoidPage extends StatelessWidget implements AutoRouteWrapper { + final Order order; + const VoidPage({super.key, required this.order}); + + @override + Widget build(BuildContext context) { + return BlocListener( + listenWhen: (previous, current) => + previous.failureOrVoid != current.failureOrVoid, + listener: (context, state) { + state.failureOrVoid.fold( + () => null, + (either) => either.fold( + (f) => AppFlushbar.showOrderFailureToast(context, f), + (success) { + if (context.mounted) {} + }, + ), + ); + }, + child: Scaffold( + backgroundColor: AppColor.background, + body: SafeArea( + child: BlocBuilder( + builder: (context, state) { + return Container( + padding: EdgeInsets.all(24), + child: Row( + children: [ + // Left Panel - Order Details & Items + Expanded(flex: 3, child: VoidLeftPanel(state: state)), + SpaceWidth(24), + // Right Panel - Void Configuration + Expanded(flex: 2, child: VoidRightPanel(state: state)), + ], + ), + ); + }, + ), + ), + ), + ); + } + + @override + Widget wrappedRoute(BuildContext context) { + context.read().add(VoidFormEvent.setOrder(order)); + return this; + } +} diff --git a/lib/presentation/pages/void/widgets/void_left_panel.dart b/lib/presentation/pages/void/widgets/void_left_panel.dart new file mode 100644 index 0000000..c235b61 --- /dev/null +++ b/lib/presentation/pages/void/widgets/void_left_panel.dart @@ -0,0 +1,249 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; + +import '../../../../application/void/void_form/void_form_bloc.dart'; +import '../../../../common/extension/extension.dart'; +import '../../../../common/theme/theme.dart'; +import '../../../../common/types/void_type.dart'; +import '../../../components/spaces/space.dart'; +import 'void_product_card.dart'; + +class VoidLeftPanel extends StatefulWidget { + final VoidFormState state; + const VoidLeftPanel({super.key, required this.state}); + + @override + State createState() => _VoidLeftPanelState(); +} + +class _VoidLeftPanelState extends State { + final ScrollController _scrollController = ScrollController(); + + @override + void dispose() { + super.dispose(); + _scrollController.dispose(); + } + + @override + Widget build(BuildContext context) { + return Container( + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(12), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + padding: EdgeInsets.all(16), + decoration: BoxDecoration( + border: Border( + bottom: BorderSide(width: 1, color: AppColor.border), + ), + borderRadius: BorderRadius.only( + topLeft: Radius.circular(12), + topRight: Radius.circular(12), + ), + ), + child: Row( + children: [ + Icon(Icons.receipt_long, color: AppColor.primary, size: 24), + SpaceWidth(12), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'Pesanan #${widget.state.order.orderNumber}', + style: AppStyle.xl.copyWith( + fontWeight: FontWeight.bold, + color: AppColor.primary, + ), + ), + Text( + 'Meja: ${widget.state.order.tableNumber} • ${widget.state.order.orderType}', + style: AppStyle.md.copyWith( + color: AppColor.textSecondary, + ), + ), + ], + ), + ), + Container( + padding: EdgeInsets.symmetric(horizontal: 12, vertical: 6), + decoration: BoxDecoration( + color: _getStatusColor( + widget.state.order.status, + ).withOpacity(0.2), + borderRadius: BorderRadius.circular(16), + ), + child: Text( + widget.state.order.status.toUpperCase(), + style: AppStyle.sm.copyWith( + fontWeight: FontWeight.w600, + color: _getStatusColor(widget.state.order.status), + ), + ), + ), + ], + ), + ), + Expanded( + child: Scrollbar( + controller: _scrollController, + thumbVisibility: true, + child: SingleChildScrollView( + controller: _scrollController, + padding: EdgeInsets.all(20), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Icon( + Icons.shopping_cart, + color: AppColor.primary, + size: 20, + ), + SpaceWidth(8), + Text( + 'Produk Pesanan (${widget.state.pendingItems.length})', + style: AppStyle.lg.copyWith( + fontWeight: FontWeight.bold, + color: AppColor.primary, + ), + ), + ], + ), + SpaceHeight(16), + + ...List.generate(widget.state.pendingItems.length, (index) { + final item = widget.state.pendingItems[index]; + final voidQty = + widget.state.selectedItemQuantities[item.id] ?? 0; + final isSelected = voidQty > 0; + final canSelect = widget.state.voidType.isItem; + + return VoidProductCard( + isSelected: isSelected, + item: item, + voidQty: voidQty, + canSelect: canSelect, + onTapDecrease: voidQty > 0 + ? () { + context.read().add( + VoidFormEvent.itemQuantityChanged( + itemId: item.id, + quantity: voidQty - 1, + ), + ); + } + : null, + onTapIncrease: voidQty < item.quantity + ? () { + context.read().add( + VoidFormEvent.itemQuantityChanged( + itemId: item.id, + quantity: voidQty + 1, + ), + ); + } + : null, + ); + }), + ], + ), + ), + ), + ), + Container( + padding: EdgeInsets.all(16), + child: Column( + children: [ + _buildSummaryRow( + 'Subtotal:', + (widget.state.order.subtotal).currencyFormatRpV2, + ), + _buildSummaryRow( + 'Pajak:', + (widget.state.order.taxAmount).currencyFormatRpV2, + ), + // _buildSummaryRow( + // 'Diskon:', + // '- ${(widget.state.order.discountAmount).currencyFormatRpV2}', + // ), + Divider(thickness: 1), + _buildSummaryRow( + 'Total:', + (widget.state.order.totalAmount).currencyFormatRpV2, + isTotal: true, + ), + if (widget.state.voidType.isItem && + widget.state.selectedItemQuantities.isNotEmpty) ...[ + Divider(thickness: 1, color: Colors.red[300]), + _buildSummaryRow( + 'Total Void:', + '- ${widget.state.totalPriceVoid.currencyFormatRpV2}', + isVoid: true, + ), + ], + ], + ), + ), + ], + ), + ); + } + + Widget _buildSummaryRow( + String label, + String value, { + bool isTotal = false, + bool isVoid = false, + }) { + return Padding( + padding: EdgeInsets.symmetric(vertical: 4), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + label, + style: TextStyle( + fontSize: isTotal ? 16 : 14, + fontWeight: isTotal ? FontWeight.bold : FontWeight.normal, + color: isVoid + ? AppColor.error + : (isTotal ? AppColor.primary : AppColor.textPrimary), + ), + ), + Text( + value, + style: TextStyle( + fontSize: isTotal ? 16 : 14, + fontWeight: isTotal ? FontWeight.bold : FontWeight.w500, + color: isVoid + ? AppColor.error + : (isTotal ? AppColor.primary : AppColor.textPrimary), + ), + ), + ], + ), + ); + } + + Color _getStatusColor(String? status) { + switch (status?.toLowerCase()) { + case 'completed': + return AppColor.success; + case 'pending': + return AppColor.warning; + case 'cancelled': + return AppColor.error; + case 'processing': + return AppColor.info; + default: + return AppColor.primary; + } + } +} diff --git a/lib/presentation/pages/void/widgets/void_product_card.dart b/lib/presentation/pages/void/widgets/void_product_card.dart new file mode 100644 index 0000000..cc61bd4 --- /dev/null +++ b/lib/presentation/pages/void/widgets/void_product_card.dart @@ -0,0 +1,217 @@ +import 'package:flutter/material.dart'; + +import '../../../../common/extension/extension.dart'; +import '../../../../common/theme/theme.dart'; +import '../../../../domain/order/order.dart'; +import '../../../components/spaces/space.dart'; + +class VoidProductCard extends StatelessWidget { + final bool isSelected; + final OrderItem item; + final int voidQty; + final bool canSelect; + final Function()? onTapDecrease; + final Function()? onTapIncrease; + const VoidProductCard({ + super.key, + required this.isSelected, + required this.item, + required this.voidQty, + required this.canSelect, + required this.onTapDecrease, + required this.onTapIncrease, + }); + + @override + Widget build(BuildContext context) { + return Container( + margin: EdgeInsets.only(bottom: 12), + decoration: BoxDecoration( + color: isSelected ? AppColor.primary.withOpacity(0.1) : Colors.white, + border: Border.all( + color: isSelected ? AppColor.primary : AppColor.border, + width: isSelected ? 2 : 1, + ), + borderRadius: BorderRadius.circular(8), + ), + child: Padding( + padding: EdgeInsets.all(16), + child: Column( + children: [ + Row( + children: [ + // Product Info + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + item.productName, + style: AppStyle.lg.copyWith( + fontWeight: FontWeight.w600, + ), + ), + if (item.productVariantName.isNotEmpty) + Text( + 'Varian: ${item.productVariantName}', + style: AppStyle.sm.copyWith( + color: AppColor.textSecondary, + ), + ), + SpaceHeight(4), + Row( + children: [ + Container( + padding: EdgeInsets.symmetric( + horizontal: 8, + vertical: 2, + ), + decoration: BoxDecoration( + color: Colors.blue.withOpacity(0.1), + borderRadius: BorderRadius.circular(12), + ), + child: Text( + 'Qty: ${item.quantity}', + style: AppStyle.sm.copyWith( + fontWeight: FontWeight.w500, + color: Colors.blue[700], + ), + ), + ), + SpaceWidth(8), + Text( + (item.unitPrice).currencyFormatRpV2, + style: AppStyle.sm.copyWith( + color: AppColor.textSecondary, + ), + ), + ], + ), + if (item.notes.isNotEmpty) + Padding( + padding: EdgeInsets.only(top: 4), + child: Container( + padding: EdgeInsets.symmetric( + horizontal: 8, + vertical: 2, + ), + decoration: BoxDecoration( + color: Colors.orange.withOpacity(0.1), + borderRadius: BorderRadius.circular(4), + ), + child: Text( + 'Catatan: ${item.notes}', + style: AppStyle.xs.copyWith( + color: AppColor.warning, + ), + ), + ), + ), + ], + ), + ), + + if (canSelect) ...[ + Container( + decoration: BoxDecoration( + border: Border.all(color: AppColor.border), + borderRadius: BorderRadius.circular(6), + ), + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + // Decrease Button + InkWell( + onTap: onTapDecrease, + child: Container( + padding: EdgeInsets.all(8), + child: Icon( + Icons.remove, + size: 16, + color: voidQty > 0 + ? AppColor.primary + : Colors.grey[400], + ), + ), + ), + + // Quantity Display + Container( + padding: EdgeInsets.symmetric( + horizontal: 16, + vertical: 8, + ), + decoration: BoxDecoration( + border: Border.symmetric( + vertical: BorderSide(color: AppColor.border), + ), + ), + child: Text( + '$voidQty', + style: AppStyle.sm.copyWith( + fontWeight: FontWeight.w600, + ), + ), + ), + + // Increase Button + InkWell( + onTap: onTapIncrease, + child: Container( + padding: EdgeInsets.all(8), + child: Icon( + Icons.add, + size: 16, + color: voidQty < (item.quantity) + ? AppColor.primary + : Colors.grey[400], + ), + ), + ), + ], + ), + ), + SpaceWidth(20), + ], + // Price + Column( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Text( + (item.totalPrice).currencyFormatRpV2, + style: AppStyle.lg.copyWith( + fontWeight: FontWeight.bold, + color: AppColor.primary, + ), + ), + if (isSelected) + Container( + padding: EdgeInsets.symmetric( + horizontal: 6, + vertical: 2, + ), + decoration: BoxDecoration( + color: Colors.red.withOpacity(0.1), + borderRadius: BorderRadius.circular(4), + ), + child: Text( + 'Void: ${((item.unitPrice) * voidQty).currencyFormatRpV2}', + style: AppStyle.sm.copyWith( + fontSize: 12, + color: AppColor.error, + fontWeight: FontWeight.w500, + ), + ), + ), + ], + ), + ], + ), + + // Quantity Controls (only show for item void) + ], + ), + ), + ); + } +} diff --git a/lib/presentation/pages/void/widgets/void_radio.dart b/lib/presentation/pages/void/widgets/void_radio.dart new file mode 100644 index 0000000..7624b4b --- /dev/null +++ b/lib/presentation/pages/void/widgets/void_radio.dart @@ -0,0 +1,47 @@ +import 'package:flutter/material.dart'; + +import '../../../../common/theme/theme.dart'; +import '../../../../common/types/void_type.dart'; + +class VoidRadio extends StatelessWidget { + final VoidType voidType; + final VoidType value; + final Function(VoidType?)? onChanged; + final String title; + final String subtitle; + const VoidRadio({ + super.key, + required this.voidType, + required this.value, + this.onChanged, + required this.title, + required this.subtitle, + }); + + @override + Widget build(BuildContext context) { + return Container( + decoration: BoxDecoration( + border: Border.all( + color: voidType == value ? AppColor.primary : Colors.grey[300]!, + width: voidType == value ? 2 : 1, + ), + borderRadius: BorderRadius.circular(8), + ), + child: RadioListTile( + title: Text( + title, + style: AppStyle.md.copyWith(fontWeight: FontWeight.w600), + ), + subtitle: Text( + subtitle, + style: AppStyle.sm.copyWith(color: AppColor.textSecondary), + ), + value: value, + groupValue: voidType, + activeColor: AppColor.primary, + onChanged: onChanged, + ), + ); + } +} diff --git a/lib/presentation/pages/void/widgets/void_right_panel.dart b/lib/presentation/pages/void/widgets/void_right_panel.dart new file mode 100644 index 0000000..d3b92cf --- /dev/null +++ b/lib/presentation/pages/void/widgets/void_right_panel.dart @@ -0,0 +1,372 @@ +import 'package:auto_route/auto_route.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; + +import '../../../../application/void/void_form/void_form_bloc.dart'; +import '../../../../common/extension/extension.dart'; +import '../../../../common/theme/theme.dart'; +import '../../../../common/types/void_type.dart'; +import '../../../components/button/button.dart'; +import '../../../components/dialog/order/order_void_confirm_dialog.dart'; +import '../../../components/field/field.dart'; +import '../../../components/spaces/space.dart'; +import 'void_radio.dart'; + +class VoidRightPanel extends StatefulWidget { + final VoidFormState state; + const VoidRightPanel({super.key, required this.state}); + + @override + State createState() => _VoidRightPanelState(); +} + +class _VoidRightPanelState extends State { + final ScrollController _scrollController = ScrollController(); + + @override + void dispose() { + super.dispose(); + _scrollController.dispose(); + } + + @override + Widget build(BuildContext context) { + return Container( + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(12), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + padding: EdgeInsets.all(20), + decoration: BoxDecoration( + border: Border( + bottom: BorderSide(width: 1, color: AppColor.border), + ), + borderRadius: BorderRadius.only( + topLeft: Radius.circular(12), + topRight: Radius.circular(12), + ), + ), + child: Row( + children: [ + Text( + 'Konfigurasi Void', + style: AppStyle.xxl.copyWith( + fontWeight: FontWeight.bold, + color: AppColor.primary, + ), + ), + ], + ), + ), + Expanded( + child: Scrollbar( + controller: _scrollController, + thumbVisibility: true, + child: SingleChildScrollView( + controller: _scrollController, + padding: EdgeInsets.all(20), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'Tipe Void *', + style: AppStyle.lg.copyWith( + fontWeight: FontWeight.bold, + color: AppColor.primary, + ), + ), + SpaceHeight(12), + VoidRadio( + voidType: widget.state.voidType, + value: VoidType.all, + title: 'Batalkan Seluruh Pesanan', + subtitle: "Batalkan pesanan lengkap dan semua item", + onChanged: (VoidType? value) { + context.read().add( + VoidFormEvent.clearSelectedItem(), + ); + context.read().add( + VoidFormEvent.voidTypeChanged(value!), + ); + }, + ), + SpaceHeight(12), + VoidRadio( + voidType: widget.state.voidType, + value: VoidType.item, + title: 'Batalkan Barang/Jumlah Tertentu', + subtitle: + "Mengurangi atau membatalkan jumlah item tertentu", + onChanged: (VoidType? value) { + context.read().add( + VoidFormEvent.voidTypeChanged(value!), + ); + }, + ), + SpaceHeight(24), + + // Selected Items Summary (only show for item void) + if (widget.state.voidType.isItem) ...[ + Container( + padding: EdgeInsets.all(16), + decoration: BoxDecoration( + color: widget.state.selectedItemQuantities.isEmpty + ? AppColor.warning.withOpacity(0.1) + : AppColor.success.withOpacity(0.1), + borderRadius: BorderRadius.circular(8), + border: Border.all( + color: widget.state.selectedItemQuantities.isEmpty + ? AppColor.warning.withOpacity(0.6) + : AppColor.success.withOpacity(0.6), + ), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Icon( + widget.state.selectedItemQuantities.isEmpty + ? Icons.warning + : Icons.check_circle, + color: + widget + .state + .selectedItemQuantities + .isEmpty + ? AppColor.warning + : AppColor.success, + size: 20, + ), + SpaceWidth(8), + Expanded( + child: Text( + widget.state.selectedItemQuantities.isEmpty + ? 'Silakan pilih item dan jumlah yang akan dibatalkan' + : 'Item yang dipilih untuk dibatalkan:', + style: AppStyle.md.copyWith( + fontWeight: FontWeight.w500, + color: + widget + .state + .selectedItemQuantities + .isEmpty + ? AppColor.warning + : AppColor.success, + ), + ), + ), + ], + ), + if (widget + .state + .selectedItemQuantities + .isNotEmpty) ...[ + SpaceHeight(12), + Container( + constraints: BoxConstraints(maxHeight: 150), + child: Scrollbar( + child: SingleChildScrollView( + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: widget + .state + .selectedItemQuantities + .entries + .map((entry) { + final item = widget + .state + .order + .orderItems + .firstWhere( + (item) => + item.id == entry.key, + ); + return Container( + margin: EdgeInsets.only( + bottom: 8, + ), + padding: EdgeInsets.all(8), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: + BorderRadius.circular(6), + border: Border.all( + color: AppColor.success, + ), + ), + child: Row( + children: [ + Expanded( + child: Column( + crossAxisAlignment: + CrossAxisAlignment + .start, + children: [ + Text( + item.productName, + style: AppStyle.sm + .copyWith( + fontWeight: + FontWeight + .w500, + ), + ), + Text( + 'Qty: ${entry.value}', + style: AppStyle.xs + .copyWith( + color: AppColor + .textSecondary, + ), + ), + ], + ), + ), + Text( + ((item.unitPrice) * + entry.value) + .currencyFormatRpV2, + style: AppStyle.xs.copyWith( + fontWeight: + FontWeight.bold, + color: AppColor.error, + ), + ), + ], + ), + ); + }) + .toList(), + ), + ), + ), + ), + Divider(height: 16, thickness: 1), + Container( + padding: EdgeInsets.all(8), + decoration: BoxDecoration( + color: AppColor.error, + borderRadius: BorderRadius.circular(6), + ), + child: Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Text( + 'Jumlah Total Void:', + style: AppStyle.md.copyWith( + fontWeight: FontWeight.bold, + color: Colors.white, + ), + ), + Text( + widget + .state + .totalPriceVoid + .currencyFormatRpV2, + style: AppStyle.md.copyWith( + fontWeight: FontWeight.bold, + color: Colors.white, + ), + ), + ], + ), + ), + ], + ], + ), + ), + SpaceHeight(24), + ], + + Text( + 'Alasan Void *', + style: AppStyle.lg.copyWith( + fontWeight: FontWeight.bold, + color: AppColor.primary, + ), + ), + SpaceHeight(8), + AppTextFormField( + label: 'Harap berikan alasan untuk membatalkan...', + showLabel: false, + maxLines: 4, + onChanged: (value) { + context.read().add( + VoidFormEvent.voidReasonChanged(value), + ); + }, + ), + SpaceHeight(32), + ], + ), + ), + ), + ), + + // Action Buttons + Padding( + padding: EdgeInsets.all(20), + child: Row( + children: [ + Expanded( + child: AppElevatedButton.outlined( + onPressed: () => context.router.maybePop(), + label: 'Batal', + ), + ), + SpaceWidth(12), + Expanded( + child: AppElevatedButton.filled( + onPressed: _canProcessVoid() ? _processVoid : null, + label: widget.state.voidType.isAll + ? 'Void Pesanan' + : 'Void Produk', + ), + ), + ], + ), + ), + ], + ), + ); + } + + bool _canProcessVoid() { + if (widget.state.voidReason?.isEmpty ?? true) return false; + if (widget.state.voidType.isItem && + widget.state.selectedItemQuantities.isEmpty) { + return false; + } + return true; + } + + void _processVoid() { + String confirmMessage; + if (widget.state.voidType.isAll) { + confirmMessage = + 'Apakah Anda yakin ingin membatalkan seluruh pesanan #${widget.state.order.orderNumber}?\n\nIni akan membatalkan semua item dalam pesanan.'; + } else { + int totalItems = widget.state.selectedItemQuantities.values.fold( + 0, + (sum, qty) => sum + qty, + ); + confirmMessage = + 'Apakah Anda yakin ingin membatalkan $totalItems item dari pesanan #${widget.state.order.orderNumber}?\n\nJumlah Batal: ${widget.state.totalPriceVoid.currencyFormatRpV2}'; + } + + showDialog( + context: context, + barrierDismissible: false, + builder: (BuildContext context) { + return OrderVoidConfirmDialog(message: confirmMessage); + }, + ); + } +} diff --git a/lib/presentation/router/app_router.dart b/lib/presentation/router/app_router.dart index 875e612..50e7ce7 100644 --- a/lib/presentation/router/app_router.dart +++ b/lib/presentation/router/app_router.dart @@ -37,5 +37,8 @@ class AppRouter extends RootStackRouter { // Payment AutoRoute(page: PaymentRoute.page), AutoRoute(page: PaymentSuccessRoute.page), + + // Void + AutoRoute(page: VoidRoute.page), ]; } diff --git a/lib/presentation/router/app_router.gr.dart b/lib/presentation/router/app_router.gr.dart index e0ce77e..7d05abd 100644 --- a/lib/presentation/router/app_router.gr.dart +++ b/lib/presentation/router/app_router.gr.dart @@ -9,7 +9,7 @@ // coverage:ignore-file // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'package:apskel_pos_flutter_v2/domain/order/order.dart' as _i18; +import 'package:apskel_pos_flutter_v2/domain/order/order.dart' as _i19; import 'package:apskel_pos_flutter_v2/presentation/pages/auth/login/login_page.dart' as _i4; import 'package:apskel_pos_flutter_v2/presentation/pages/checkout/checkout_page.dart' @@ -40,82 +40,84 @@ import 'package:apskel_pos_flutter_v2/presentation/pages/splash/splash_page.dart as _i11; import 'package:apskel_pos_flutter_v2/presentation/pages/sync/sync_page.dart' as _i14; -import 'package:auto_route/auto_route.dart' as _i16; -import 'package:flutter/material.dart' as _i17; +import 'package:apskel_pos_flutter_v2/presentation/pages/void/void_page.dart' + as _i16; +import 'package:auto_route/auto_route.dart' as _i17; +import 'package:flutter/material.dart' as _i18; /// generated route for /// [_i1.CheckoutPage] -class CheckoutRoute extends _i16.PageRouteInfo { - const CheckoutRoute({List<_i16.PageRouteInfo>? children}) +class CheckoutRoute extends _i17.PageRouteInfo { + const CheckoutRoute({List<_i17.PageRouteInfo>? children}) : super(CheckoutRoute.name, initialChildren: children); static const String name = 'CheckoutRoute'; - static _i16.PageInfo page = _i16.PageInfo( + static _i17.PageInfo page = _i17.PageInfo( name, builder: (data) { - return _i16.WrappedRoute(child: const _i1.CheckoutPage()); + return _i17.WrappedRoute(child: const _i1.CheckoutPage()); }, ); } /// generated route for /// [_i2.CustomerPage] -class CustomerRoute extends _i16.PageRouteInfo { - const CustomerRoute({List<_i16.PageRouteInfo>? children}) +class CustomerRoute extends _i17.PageRouteInfo { + const CustomerRoute({List<_i17.PageRouteInfo>? children}) : super(CustomerRoute.name, initialChildren: children); static const String name = 'CustomerRoute'; - static _i16.PageInfo page = _i16.PageInfo( + static _i17.PageInfo page = _i17.PageInfo( name, builder: (data) { - return _i16.WrappedRoute(child: const _i2.CustomerPage()); + return _i17.WrappedRoute(child: const _i2.CustomerPage()); }, ); } /// generated route for /// [_i3.HomePage] -class HomeRoute extends _i16.PageRouteInfo { - const HomeRoute({List<_i16.PageRouteInfo>? children}) +class HomeRoute extends _i17.PageRouteInfo { + const HomeRoute({List<_i17.PageRouteInfo>? children}) : super(HomeRoute.name, initialChildren: children); static const String name = 'HomeRoute'; - static _i16.PageInfo page = _i16.PageInfo( + static _i17.PageInfo page = _i17.PageInfo( name, builder: (data) { - return _i16.WrappedRoute(child: const _i3.HomePage()); + return _i17.WrappedRoute(child: const _i3.HomePage()); }, ); } /// generated route for /// [_i4.LoginPage] -class LoginRoute extends _i16.PageRouteInfo { - const LoginRoute({List<_i16.PageRouteInfo>? children}) +class LoginRoute extends _i17.PageRouteInfo { + const LoginRoute({List<_i17.PageRouteInfo>? children}) : super(LoginRoute.name, initialChildren: children); static const String name = 'LoginRoute'; - static _i16.PageInfo page = _i16.PageInfo( + static _i17.PageInfo page = _i17.PageInfo( name, builder: (data) { - return _i16.WrappedRoute(child: const _i4.LoginPage()); + return _i17.WrappedRoute(child: const _i4.LoginPage()); }, ); } /// generated route for /// [_i5.MainPage] -class MainRoute extends _i16.PageRouteInfo { - const MainRoute({List<_i16.PageRouteInfo>? children}) +class MainRoute extends _i17.PageRouteInfo { + const MainRoute({List<_i17.PageRouteInfo>? children}) : super(MainRoute.name, initialChildren: children); static const String name = 'MainRoute'; - static _i16.PageInfo page = _i16.PageInfo( + static _i17.PageInfo page = _i17.PageInfo( name, builder: (data) { return const _i5.MainPage(); @@ -125,11 +127,11 @@ class MainRoute extends _i16.PageRouteInfo { /// generated route for /// [_i6.OrderPage] -class OrderRoute extends _i16.PageRouteInfo { +class OrderRoute extends _i17.PageRouteInfo { OrderRoute({ - _i17.Key? key, + _i18.Key? key, required String status, - List<_i16.PageRouteInfo>? children, + List<_i17.PageRouteInfo>? children, }) : super( OrderRoute.name, args: OrderRouteArgs(key: key, status: status), @@ -138,11 +140,11 @@ class OrderRoute extends _i16.PageRouteInfo { static const String name = 'OrderRoute'; - static _i16.PageInfo page = _i16.PageInfo( + static _i17.PageInfo page = _i17.PageInfo( name, builder: (data) { final args = data.argsAs(); - return _i16.WrappedRoute( + return _i17.WrappedRoute( child: _i6.OrderPage(key: args.key, status: args.status), ); }, @@ -152,7 +154,7 @@ class OrderRoute extends _i16.PageRouteInfo { class OrderRouteArgs { const OrderRouteArgs({this.key, required this.status}); - final _i17.Key? key; + final _i18.Key? key; final String status; @@ -164,11 +166,11 @@ class OrderRouteArgs { /// generated route for /// [_i7.PaymentPage] -class PaymentRoute extends _i16.PageRouteInfo { +class PaymentRoute extends _i17.PageRouteInfo { PaymentRoute({ - _i17.Key? key, - required _i18.Order order, - List<_i16.PageRouteInfo>? children, + _i18.Key? key, + required _i19.Order order, + List<_i17.PageRouteInfo>? children, }) : super( PaymentRoute.name, args: PaymentRouteArgs(key: key, order: order), @@ -177,11 +179,11 @@ class PaymentRoute extends _i16.PageRouteInfo { static const String name = 'PaymentRoute'; - static _i16.PageInfo page = _i16.PageInfo( + static _i17.PageInfo page = _i17.PageInfo( name, builder: (data) { final args = data.argsAs(); - return _i16.WrappedRoute( + return _i17.WrappedRoute( child: _i7.PaymentPage(key: args.key, order: args.order), ); }, @@ -191,9 +193,9 @@ class PaymentRoute extends _i16.PageRouteInfo { class PaymentRouteArgs { const PaymentRouteArgs({this.key, required this.order}); - final _i17.Key? key; + final _i18.Key? key; - final _i18.Order order; + final _i19.Order order; @override String toString() { @@ -203,11 +205,11 @@ class PaymentRouteArgs { /// generated route for /// [_i8.PaymentSuccessPage] -class PaymentSuccessRoute extends _i16.PageRouteInfo { +class PaymentSuccessRoute extends _i17.PageRouteInfo { PaymentSuccessRoute({ - _i17.Key? key, + _i18.Key? key, required String orderId, - List<_i16.PageRouteInfo>? children, + List<_i17.PageRouteInfo>? children, }) : super( PaymentSuccessRoute.name, args: PaymentSuccessRouteArgs(key: key, orderId: orderId), @@ -216,11 +218,11 @@ class PaymentSuccessRoute extends _i16.PageRouteInfo { static const String name = 'PaymentSuccessRoute'; - static _i16.PageInfo page = _i16.PageInfo( + static _i17.PageInfo page = _i17.PageInfo( name, builder: (data) { final args = data.argsAs(); - return _i16.WrappedRoute( + return _i17.WrappedRoute( child: _i8.PaymentSuccessPage(key: args.key, orderId: args.orderId), ); }, @@ -230,7 +232,7 @@ class PaymentSuccessRoute extends _i16.PageRouteInfo { class PaymentSuccessRouteArgs { const PaymentSuccessRouteArgs({this.key, required this.orderId}); - final _i17.Key? key; + final _i18.Key? key; final String orderId; @@ -242,13 +244,13 @@ class PaymentSuccessRouteArgs { /// generated route for /// [_i9.ReportPage] -class ReportRoute extends _i16.PageRouteInfo { - const ReportRoute({List<_i16.PageRouteInfo>? children}) +class ReportRoute extends _i17.PageRouteInfo { + const ReportRoute({List<_i17.PageRouteInfo>? children}) : super(ReportRoute.name, initialChildren: children); static const String name = 'ReportRoute'; - static _i16.PageInfo page = _i16.PageInfo( + static _i17.PageInfo page = _i17.PageInfo( name, builder: (data) { return const _i9.ReportPage(); @@ -258,13 +260,13 @@ class ReportRoute extends _i16.PageRouteInfo { /// generated route for /// [_i10.SettingPage] -class SettingRoute extends _i16.PageRouteInfo { - const SettingRoute({List<_i16.PageRouteInfo>? children}) +class SettingRoute extends _i17.PageRouteInfo { + const SettingRoute({List<_i17.PageRouteInfo>? children}) : super(SettingRoute.name, initialChildren: children); static const String name = 'SettingRoute'; - static _i16.PageInfo page = _i16.PageInfo( + static _i17.PageInfo page = _i17.PageInfo( name, builder: (data) { return const _i10.SettingPage(); @@ -274,13 +276,13 @@ class SettingRoute extends _i16.PageRouteInfo { /// generated route for /// [_i11.SplashPage] -class SplashRoute extends _i16.PageRouteInfo { - const SplashRoute({List<_i16.PageRouteInfo>? children}) +class SplashRoute extends _i17.PageRouteInfo { + const SplashRoute({List<_i17.PageRouteInfo>? children}) : super(SplashRoute.name, initialChildren: children); static const String name = 'SplashRoute'; - static _i16.PageInfo page = _i16.PageInfo( + static _i17.PageInfo page = _i17.PageInfo( name, builder: (data) { return const _i11.SplashPage(); @@ -290,13 +292,13 @@ class SplashRoute extends _i16.PageRouteInfo { /// generated route for /// [_i12.SuccessAddItemOrderPage] -class SuccessAddItemOrderRoute extends _i16.PageRouteInfo { - const SuccessAddItemOrderRoute({List<_i16.PageRouteInfo>? children}) +class SuccessAddItemOrderRoute extends _i17.PageRouteInfo { + const SuccessAddItemOrderRoute({List<_i17.PageRouteInfo>? children}) : super(SuccessAddItemOrderRoute.name, initialChildren: children); static const String name = 'SuccessAddItemOrderRoute'; - static _i16.PageInfo page = _i16.PageInfo( + static _i17.PageInfo page = _i17.PageInfo( name, builder: (data) { return const _i12.SuccessAddItemOrderPage(); @@ -306,11 +308,11 @@ class SuccessAddItemOrderRoute extends _i16.PageRouteInfo { /// generated route for /// [_i13.SuccessOrderPage] -class SuccessOrderRoute extends _i16.PageRouteInfo { +class SuccessOrderRoute extends _i17.PageRouteInfo { SuccessOrderRoute({ - _i17.Key? key, - required _i18.Order order, - List<_i16.PageRouteInfo>? children, + _i18.Key? key, + required _i19.Order order, + List<_i17.PageRouteInfo>? children, }) : super( SuccessOrderRoute.name, args: SuccessOrderRouteArgs(key: key, order: order), @@ -319,11 +321,11 @@ class SuccessOrderRoute extends _i16.PageRouteInfo { static const String name = 'SuccessOrderRoute'; - static _i16.PageInfo page = _i16.PageInfo( + static _i17.PageInfo page = _i17.PageInfo( name, builder: (data) { final args = data.argsAs(); - return _i16.WrappedRoute( + return _i17.WrappedRoute( child: _i13.SuccessOrderPage(key: args.key, order: args.order), ); }, @@ -333,9 +335,9 @@ class SuccessOrderRoute extends _i16.PageRouteInfo { class SuccessOrderRouteArgs { const SuccessOrderRouteArgs({this.key, required this.order}); - final _i17.Key? key; + final _i18.Key? key; - final _i18.Order order; + final _i19.Order order; @override String toString() { @@ -345,32 +347,71 @@ class SuccessOrderRouteArgs { /// generated route for /// [_i14.SyncPage] -class SyncRoute extends _i16.PageRouteInfo { - const SyncRoute({List<_i16.PageRouteInfo>? children}) +class SyncRoute extends _i17.PageRouteInfo { + const SyncRoute({List<_i17.PageRouteInfo>? children}) : super(SyncRoute.name, initialChildren: children); static const String name = 'SyncRoute'; - static _i16.PageInfo page = _i16.PageInfo( + static _i17.PageInfo page = _i17.PageInfo( name, builder: (data) { - return _i16.WrappedRoute(child: const _i14.SyncPage()); + return _i17.WrappedRoute(child: const _i14.SyncPage()); }, ); } /// generated route for /// [_i15.TablePage] -class TableRoute extends _i16.PageRouteInfo { - const TableRoute({List<_i16.PageRouteInfo>? children}) +class TableRoute extends _i17.PageRouteInfo { + const TableRoute({List<_i17.PageRouteInfo>? children}) : super(TableRoute.name, initialChildren: children); static const String name = 'TableRoute'; - static _i16.PageInfo page = _i16.PageInfo( + static _i17.PageInfo page = _i17.PageInfo( name, builder: (data) { - return _i16.WrappedRoute(child: const _i15.TablePage()); + return _i17.WrappedRoute(child: const _i15.TablePage()); }, ); } + +/// generated route for +/// [_i16.VoidPage] +class VoidRoute extends _i17.PageRouteInfo { + VoidRoute({ + _i18.Key? key, + required _i19.Order order, + List<_i17.PageRouteInfo>? children, + }) : super( + VoidRoute.name, + args: VoidRouteArgs(key: key, order: order), + initialChildren: children, + ); + + static const String name = 'VoidRoute'; + + static _i17.PageInfo page = _i17.PageInfo( + name, + builder: (data) { + final args = data.argsAs(); + return _i17.WrappedRoute( + child: _i16.VoidPage(key: args.key, order: args.order), + ); + }, + ); +} + +class VoidRouteArgs { + const VoidRouteArgs({this.key, required this.order}); + + final _i18.Key? key; + + final _i19.Order order; + + @override + String toString() { + return 'VoidRouteArgs{key: $key, order: $order}'; + } +}