refund
This commit is contained in:
parent
ef23839761
commit
069c2296de
56
lib/application/refund/refund_form/refund_form_bloc.dart
Normal file
56
lib/application/refund/refund_form/refund_form_bloc.dart
Normal file
@ -0,0 +1,56 @@
|
||||
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/data/refund_data.dart';
|
||||
import '../../../domain/order/order.dart';
|
||||
|
||||
part 'refund_form_event.dart';
|
||||
part 'refund_form_state.dart';
|
||||
part 'refund_form_bloc.freezed.dart';
|
||||
|
||||
@injectable
|
||||
class RefundFormBloc extends Bloc<RefundFormEvent, RefundFormState> {
|
||||
final IOrderRepository _repository;
|
||||
RefundFormBloc(this._repository) : super(RefundFormState.initial()) {
|
||||
on<RefundFormEvent>(_onRefundFormEvent);
|
||||
}
|
||||
|
||||
Future<void> _onRefundFormEvent(
|
||||
RefundFormEvent event,
|
||||
Emitter<RefundFormState> emit,
|
||||
) {
|
||||
return event.map(
|
||||
setOrder: (e) async {
|
||||
emit(state.copyWith(order: e.order));
|
||||
},
|
||||
reasonChanged: (e) async {
|
||||
emit(state.copyWith(reason: e.reason));
|
||||
},
|
||||
refundReasonChanged: (e) async {
|
||||
emit(state.copyWith(refundReason: e.refundReason));
|
||||
},
|
||||
submitted: (e) async {
|
||||
Either<OrderFailure, Unit>? failureOrRefund;
|
||||
|
||||
emit(state.copyWith(isSubmitting: true, failureOrRefund: none()));
|
||||
|
||||
failureOrRefund = await _repository.refundOrder(
|
||||
id: state.order.id,
|
||||
reason: state.refundReason?.value == 'Lainnya'
|
||||
? state.reason
|
||||
: state.refundReason?.value ?? '',
|
||||
refundAmount: state.order.totalAmount,
|
||||
);
|
||||
|
||||
emit(
|
||||
state.copyWith(
|
||||
isSubmitting: false,
|
||||
failureOrRefund: optionOf(failureOrRefund),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
938
lib/application/refund/refund_form/refund_form_bloc.freezed.dart
Normal file
938
lib/application/refund/refund_form/refund_form_bloc.freezed.dart
Normal file
@ -0,0 +1,938 @@
|
||||
// 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 'refund_form_bloc.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
T _$identity<T>(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 _$RefundFormEvent {
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function(Order order) setOrder,
|
||||
required TResult Function(String reason) reasonChanged,
|
||||
required TResult Function(RefundReason refundReason) refundReasonChanged,
|
||||
required TResult Function() submitted,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function(Order order)? setOrder,
|
||||
TResult? Function(String reason)? reasonChanged,
|
||||
TResult? Function(RefundReason refundReason)? refundReasonChanged,
|
||||
TResult? Function()? submitted,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function(Order order)? setOrder,
|
||||
TResult Function(String reason)? reasonChanged,
|
||||
TResult Function(RefundReason refundReason)? refundReasonChanged,
|
||||
TResult Function()? submitted,
|
||||
required TResult orElse(),
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_SetOrder value) setOrder,
|
||||
required TResult Function(_ReasonChanged value) reasonChanged,
|
||||
required TResult Function(_RefundReasonChanged value) refundReasonChanged,
|
||||
required TResult Function(_Submitted value) submitted,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_SetOrder value)? setOrder,
|
||||
TResult? Function(_ReasonChanged value)? reasonChanged,
|
||||
TResult? Function(_RefundReasonChanged value)? refundReasonChanged,
|
||||
TResult? Function(_Submitted value)? submitted,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_SetOrder value)? setOrder,
|
||||
TResult Function(_ReasonChanged value)? reasonChanged,
|
||||
TResult Function(_RefundReasonChanged value)? refundReasonChanged,
|
||||
TResult Function(_Submitted value)? submitted,
|
||||
required TResult orElse(),
|
||||
}) => throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $RefundFormEventCopyWith<$Res> {
|
||||
factory $RefundFormEventCopyWith(
|
||||
RefundFormEvent value,
|
||||
$Res Function(RefundFormEvent) then,
|
||||
) = _$RefundFormEventCopyWithImpl<$Res, RefundFormEvent>;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$RefundFormEventCopyWithImpl<$Res, $Val extends RefundFormEvent>
|
||||
implements $RefundFormEventCopyWith<$Res> {
|
||||
_$RefundFormEventCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of RefundFormEvent
|
||||
/// 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 _$RefundFormEventCopyWithImpl<$Res, _$SetOrderImpl>
|
||||
implements _$$SetOrderImplCopyWith<$Res> {
|
||||
__$$SetOrderImplCopyWithImpl(
|
||||
_$SetOrderImpl _value,
|
||||
$Res Function(_$SetOrderImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of RefundFormEvent
|
||||
/// 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 RefundFormEvent
|
||||
/// 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 'RefundFormEvent.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 RefundFormEvent
|
||||
/// 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<TResult extends Object?>({
|
||||
required TResult Function(Order order) setOrder,
|
||||
required TResult Function(String reason) reasonChanged,
|
||||
required TResult Function(RefundReason refundReason) refundReasonChanged,
|
||||
required TResult Function() submitted,
|
||||
}) {
|
||||
return setOrder(order);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function(Order order)? setOrder,
|
||||
TResult? Function(String reason)? reasonChanged,
|
||||
TResult? Function(RefundReason refundReason)? refundReasonChanged,
|
||||
TResult? Function()? submitted,
|
||||
}) {
|
||||
return setOrder?.call(order);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function(Order order)? setOrder,
|
||||
TResult Function(String reason)? reasonChanged,
|
||||
TResult Function(RefundReason refundReason)? refundReasonChanged,
|
||||
TResult Function()? submitted,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (setOrder != null) {
|
||||
return setOrder(order);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_SetOrder value) setOrder,
|
||||
required TResult Function(_ReasonChanged value) reasonChanged,
|
||||
required TResult Function(_RefundReasonChanged value) refundReasonChanged,
|
||||
required TResult Function(_Submitted value) submitted,
|
||||
}) {
|
||||
return setOrder(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_SetOrder value)? setOrder,
|
||||
TResult? Function(_ReasonChanged value)? reasonChanged,
|
||||
TResult? Function(_RefundReasonChanged value)? refundReasonChanged,
|
||||
TResult? Function(_Submitted value)? submitted,
|
||||
}) {
|
||||
return setOrder?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_SetOrder value)? setOrder,
|
||||
TResult Function(_ReasonChanged value)? reasonChanged,
|
||||
TResult Function(_RefundReasonChanged value)? refundReasonChanged,
|
||||
TResult Function(_Submitted value)? submitted,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (setOrder != null) {
|
||||
return setOrder(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _SetOrder implements RefundFormEvent {
|
||||
const factory _SetOrder(final Order order) = _$SetOrderImpl;
|
||||
|
||||
Order get order;
|
||||
|
||||
/// Create a copy of RefundFormEvent
|
||||
/// 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 _$$ReasonChangedImplCopyWith<$Res> {
|
||||
factory _$$ReasonChangedImplCopyWith(
|
||||
_$ReasonChangedImpl value,
|
||||
$Res Function(_$ReasonChangedImpl) then,
|
||||
) = __$$ReasonChangedImplCopyWithImpl<$Res>;
|
||||
@useResult
|
||||
$Res call({String reason});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$ReasonChangedImplCopyWithImpl<$Res>
|
||||
extends _$RefundFormEventCopyWithImpl<$Res, _$ReasonChangedImpl>
|
||||
implements _$$ReasonChangedImplCopyWith<$Res> {
|
||||
__$$ReasonChangedImplCopyWithImpl(
|
||||
_$ReasonChangedImpl _value,
|
||||
$Res Function(_$ReasonChangedImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of RefundFormEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({Object? reason = null}) {
|
||||
return _then(
|
||||
_$ReasonChangedImpl(
|
||||
null == reason
|
||||
? _value.reason
|
||||
: reason // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$ReasonChangedImpl implements _ReasonChanged {
|
||||
const _$ReasonChangedImpl(this.reason);
|
||||
|
||||
@override
|
||||
final String reason;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'RefundFormEvent.reasonChanged(reason: $reason)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$ReasonChangedImpl &&
|
||||
(identical(other.reason, reason) || other.reason == reason));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, reason);
|
||||
|
||||
/// Create a copy of RefundFormEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$ReasonChangedImplCopyWith<_$ReasonChangedImpl> get copyWith =>
|
||||
__$$ReasonChangedImplCopyWithImpl<_$ReasonChangedImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function(Order order) setOrder,
|
||||
required TResult Function(String reason) reasonChanged,
|
||||
required TResult Function(RefundReason refundReason) refundReasonChanged,
|
||||
required TResult Function() submitted,
|
||||
}) {
|
||||
return reasonChanged(reason);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function(Order order)? setOrder,
|
||||
TResult? Function(String reason)? reasonChanged,
|
||||
TResult? Function(RefundReason refundReason)? refundReasonChanged,
|
||||
TResult? Function()? submitted,
|
||||
}) {
|
||||
return reasonChanged?.call(reason);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function(Order order)? setOrder,
|
||||
TResult Function(String reason)? reasonChanged,
|
||||
TResult Function(RefundReason refundReason)? refundReasonChanged,
|
||||
TResult Function()? submitted,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (reasonChanged != null) {
|
||||
return reasonChanged(reason);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_SetOrder value) setOrder,
|
||||
required TResult Function(_ReasonChanged value) reasonChanged,
|
||||
required TResult Function(_RefundReasonChanged value) refundReasonChanged,
|
||||
required TResult Function(_Submitted value) submitted,
|
||||
}) {
|
||||
return reasonChanged(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_SetOrder value)? setOrder,
|
||||
TResult? Function(_ReasonChanged value)? reasonChanged,
|
||||
TResult? Function(_RefundReasonChanged value)? refundReasonChanged,
|
||||
TResult? Function(_Submitted value)? submitted,
|
||||
}) {
|
||||
return reasonChanged?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_SetOrder value)? setOrder,
|
||||
TResult Function(_ReasonChanged value)? reasonChanged,
|
||||
TResult Function(_RefundReasonChanged value)? refundReasonChanged,
|
||||
TResult Function(_Submitted value)? submitted,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (reasonChanged != null) {
|
||||
return reasonChanged(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _ReasonChanged implements RefundFormEvent {
|
||||
const factory _ReasonChanged(final String reason) = _$ReasonChangedImpl;
|
||||
|
||||
String get reason;
|
||||
|
||||
/// Create a copy of RefundFormEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$ReasonChangedImplCopyWith<_$ReasonChangedImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$RefundReasonChangedImplCopyWith<$Res> {
|
||||
factory _$$RefundReasonChangedImplCopyWith(
|
||||
_$RefundReasonChangedImpl value,
|
||||
$Res Function(_$RefundReasonChangedImpl) then,
|
||||
) = __$$RefundReasonChangedImplCopyWithImpl<$Res>;
|
||||
@useResult
|
||||
$Res call({RefundReason refundReason});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$RefundReasonChangedImplCopyWithImpl<$Res>
|
||||
extends _$RefundFormEventCopyWithImpl<$Res, _$RefundReasonChangedImpl>
|
||||
implements _$$RefundReasonChangedImplCopyWith<$Res> {
|
||||
__$$RefundReasonChangedImplCopyWithImpl(
|
||||
_$RefundReasonChangedImpl _value,
|
||||
$Res Function(_$RefundReasonChangedImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of RefundFormEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({Object? refundReason = null}) {
|
||||
return _then(
|
||||
_$RefundReasonChangedImpl(
|
||||
null == refundReason
|
||||
? _value.refundReason
|
||||
: refundReason // ignore: cast_nullable_to_non_nullable
|
||||
as RefundReason,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$RefundReasonChangedImpl implements _RefundReasonChanged {
|
||||
const _$RefundReasonChangedImpl(this.refundReason);
|
||||
|
||||
@override
|
||||
final RefundReason refundReason;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'RefundFormEvent.refundReasonChanged(refundReason: $refundReason)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$RefundReasonChangedImpl &&
|
||||
(identical(other.refundReason, refundReason) ||
|
||||
other.refundReason == refundReason));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, refundReason);
|
||||
|
||||
/// Create a copy of RefundFormEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$RefundReasonChangedImplCopyWith<_$RefundReasonChangedImpl> get copyWith =>
|
||||
__$$RefundReasonChangedImplCopyWithImpl<_$RefundReasonChangedImpl>(
|
||||
this,
|
||||
_$identity,
|
||||
);
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function(Order order) setOrder,
|
||||
required TResult Function(String reason) reasonChanged,
|
||||
required TResult Function(RefundReason refundReason) refundReasonChanged,
|
||||
required TResult Function() submitted,
|
||||
}) {
|
||||
return refundReasonChanged(refundReason);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function(Order order)? setOrder,
|
||||
TResult? Function(String reason)? reasonChanged,
|
||||
TResult? Function(RefundReason refundReason)? refundReasonChanged,
|
||||
TResult? Function()? submitted,
|
||||
}) {
|
||||
return refundReasonChanged?.call(refundReason);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function(Order order)? setOrder,
|
||||
TResult Function(String reason)? reasonChanged,
|
||||
TResult Function(RefundReason refundReason)? refundReasonChanged,
|
||||
TResult Function()? submitted,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (refundReasonChanged != null) {
|
||||
return refundReasonChanged(refundReason);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_SetOrder value) setOrder,
|
||||
required TResult Function(_ReasonChanged value) reasonChanged,
|
||||
required TResult Function(_RefundReasonChanged value) refundReasonChanged,
|
||||
required TResult Function(_Submitted value) submitted,
|
||||
}) {
|
||||
return refundReasonChanged(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_SetOrder value)? setOrder,
|
||||
TResult? Function(_ReasonChanged value)? reasonChanged,
|
||||
TResult? Function(_RefundReasonChanged value)? refundReasonChanged,
|
||||
TResult? Function(_Submitted value)? submitted,
|
||||
}) {
|
||||
return refundReasonChanged?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_SetOrder value)? setOrder,
|
||||
TResult Function(_ReasonChanged value)? reasonChanged,
|
||||
TResult Function(_RefundReasonChanged value)? refundReasonChanged,
|
||||
TResult Function(_Submitted value)? submitted,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (refundReasonChanged != null) {
|
||||
return refundReasonChanged(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _RefundReasonChanged implements RefundFormEvent {
|
||||
const factory _RefundReasonChanged(final RefundReason refundReason) =
|
||||
_$RefundReasonChangedImpl;
|
||||
|
||||
RefundReason get refundReason;
|
||||
|
||||
/// Create a copy of RefundFormEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$RefundReasonChangedImplCopyWith<_$RefundReasonChangedImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$SubmittedImplCopyWith<$Res> {
|
||||
factory _$$SubmittedImplCopyWith(
|
||||
_$SubmittedImpl value,
|
||||
$Res Function(_$SubmittedImpl) then,
|
||||
) = __$$SubmittedImplCopyWithImpl<$Res>;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$SubmittedImplCopyWithImpl<$Res>
|
||||
extends _$RefundFormEventCopyWithImpl<$Res, _$SubmittedImpl>
|
||||
implements _$$SubmittedImplCopyWith<$Res> {
|
||||
__$$SubmittedImplCopyWithImpl(
|
||||
_$SubmittedImpl _value,
|
||||
$Res Function(_$SubmittedImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of RefundFormEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$SubmittedImpl implements _Submitted {
|
||||
const _$SubmittedImpl();
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'RefundFormEvent.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<TResult extends Object?>({
|
||||
required TResult Function(Order order) setOrder,
|
||||
required TResult Function(String reason) reasonChanged,
|
||||
required TResult Function(RefundReason refundReason) refundReasonChanged,
|
||||
required TResult Function() submitted,
|
||||
}) {
|
||||
return submitted();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function(Order order)? setOrder,
|
||||
TResult? Function(String reason)? reasonChanged,
|
||||
TResult? Function(RefundReason refundReason)? refundReasonChanged,
|
||||
TResult? Function()? submitted,
|
||||
}) {
|
||||
return submitted?.call();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function(Order order)? setOrder,
|
||||
TResult Function(String reason)? reasonChanged,
|
||||
TResult Function(RefundReason refundReason)? refundReasonChanged,
|
||||
TResult Function()? submitted,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (submitted != null) {
|
||||
return submitted();
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_SetOrder value) setOrder,
|
||||
required TResult Function(_ReasonChanged value) reasonChanged,
|
||||
required TResult Function(_RefundReasonChanged value) refundReasonChanged,
|
||||
required TResult Function(_Submitted value) submitted,
|
||||
}) {
|
||||
return submitted(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_SetOrder value)? setOrder,
|
||||
TResult? Function(_ReasonChanged value)? reasonChanged,
|
||||
TResult? Function(_RefundReasonChanged value)? refundReasonChanged,
|
||||
TResult? Function(_Submitted value)? submitted,
|
||||
}) {
|
||||
return submitted?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_SetOrder value)? setOrder,
|
||||
TResult Function(_ReasonChanged value)? reasonChanged,
|
||||
TResult Function(_RefundReasonChanged value)? refundReasonChanged,
|
||||
TResult Function(_Submitted value)? submitted,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (submitted != null) {
|
||||
return submitted(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _Submitted implements RefundFormEvent {
|
||||
const factory _Submitted() = _$SubmittedImpl;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$RefundFormState {
|
||||
Order get order => throw _privateConstructorUsedError;
|
||||
String get reason => throw _privateConstructorUsedError;
|
||||
RefundReason? get refundReason => throw _privateConstructorUsedError;
|
||||
Option<Either<OrderFailure, Unit>> get failureOrRefund =>
|
||||
throw _privateConstructorUsedError;
|
||||
bool get isSubmitting => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of RefundFormState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$RefundFormStateCopyWith<RefundFormState> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $RefundFormStateCopyWith<$Res> {
|
||||
factory $RefundFormStateCopyWith(
|
||||
RefundFormState value,
|
||||
$Res Function(RefundFormState) then,
|
||||
) = _$RefundFormStateCopyWithImpl<$Res, RefundFormState>;
|
||||
@useResult
|
||||
$Res call({
|
||||
Order order,
|
||||
String reason,
|
||||
RefundReason? refundReason,
|
||||
Option<Either<OrderFailure, Unit>> failureOrRefund,
|
||||
bool isSubmitting,
|
||||
});
|
||||
|
||||
$OrderCopyWith<$Res> get order;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$RefundFormStateCopyWithImpl<$Res, $Val extends RefundFormState>
|
||||
implements $RefundFormStateCopyWith<$Res> {
|
||||
_$RefundFormStateCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of RefundFormState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? order = null,
|
||||
Object? reason = null,
|
||||
Object? refundReason = freezed,
|
||||
Object? failureOrRefund = null,
|
||||
Object? isSubmitting = null,
|
||||
}) {
|
||||
return _then(
|
||||
_value.copyWith(
|
||||
order: null == order
|
||||
? _value.order
|
||||
: order // ignore: cast_nullable_to_non_nullable
|
||||
as Order,
|
||||
reason: null == reason
|
||||
? _value.reason
|
||||
: reason // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
refundReason: freezed == refundReason
|
||||
? _value.refundReason
|
||||
: refundReason // ignore: cast_nullable_to_non_nullable
|
||||
as RefundReason?,
|
||||
failureOrRefund: null == failureOrRefund
|
||||
? _value.failureOrRefund
|
||||
: failureOrRefund // ignore: cast_nullable_to_non_nullable
|
||||
as Option<Either<OrderFailure, Unit>>,
|
||||
isSubmitting: null == isSubmitting
|
||||
? _value.isSubmitting
|
||||
: isSubmitting // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
)
|
||||
as $Val,
|
||||
);
|
||||
}
|
||||
|
||||
/// Create a copy of RefundFormState
|
||||
/// 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 _$$RefundFormStateImplCopyWith<$Res>
|
||||
implements $RefundFormStateCopyWith<$Res> {
|
||||
factory _$$RefundFormStateImplCopyWith(
|
||||
_$RefundFormStateImpl value,
|
||||
$Res Function(_$RefundFormStateImpl) then,
|
||||
) = __$$RefundFormStateImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({
|
||||
Order order,
|
||||
String reason,
|
||||
RefundReason? refundReason,
|
||||
Option<Either<OrderFailure, Unit>> failureOrRefund,
|
||||
bool isSubmitting,
|
||||
});
|
||||
|
||||
@override
|
||||
$OrderCopyWith<$Res> get order;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$RefundFormStateImplCopyWithImpl<$Res>
|
||||
extends _$RefundFormStateCopyWithImpl<$Res, _$RefundFormStateImpl>
|
||||
implements _$$RefundFormStateImplCopyWith<$Res> {
|
||||
__$$RefundFormStateImplCopyWithImpl(
|
||||
_$RefundFormStateImpl _value,
|
||||
$Res Function(_$RefundFormStateImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of RefundFormState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? order = null,
|
||||
Object? reason = null,
|
||||
Object? refundReason = freezed,
|
||||
Object? failureOrRefund = null,
|
||||
Object? isSubmitting = null,
|
||||
}) {
|
||||
return _then(
|
||||
_$RefundFormStateImpl(
|
||||
order: null == order
|
||||
? _value.order
|
||||
: order // ignore: cast_nullable_to_non_nullable
|
||||
as Order,
|
||||
reason: null == reason
|
||||
? _value.reason
|
||||
: reason // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
refundReason: freezed == refundReason
|
||||
? _value.refundReason
|
||||
: refundReason // ignore: cast_nullable_to_non_nullable
|
||||
as RefundReason?,
|
||||
failureOrRefund: null == failureOrRefund
|
||||
? _value.failureOrRefund
|
||||
: failureOrRefund // ignore: cast_nullable_to_non_nullable
|
||||
as Option<Either<OrderFailure, Unit>>,
|
||||
isSubmitting: null == isSubmitting
|
||||
? _value.isSubmitting
|
||||
: isSubmitting // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$RefundFormStateImpl implements _RefundFormState {
|
||||
_$RefundFormStateImpl({
|
||||
required this.order,
|
||||
required this.reason,
|
||||
this.refundReason,
|
||||
required this.failureOrRefund,
|
||||
this.isSubmitting = false,
|
||||
});
|
||||
|
||||
@override
|
||||
final Order order;
|
||||
@override
|
||||
final String reason;
|
||||
@override
|
||||
final RefundReason? refundReason;
|
||||
@override
|
||||
final Option<Either<OrderFailure, Unit>> failureOrRefund;
|
||||
@override
|
||||
@JsonKey()
|
||||
final bool isSubmitting;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'RefundFormState(order: $order, reason: $reason, refundReason: $refundReason, failureOrRefund: $failureOrRefund, isSubmitting: $isSubmitting)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$RefundFormStateImpl &&
|
||||
(identical(other.order, order) || other.order == order) &&
|
||||
(identical(other.reason, reason) || other.reason == reason) &&
|
||||
(identical(other.refundReason, refundReason) ||
|
||||
other.refundReason == refundReason) &&
|
||||
(identical(other.failureOrRefund, failureOrRefund) ||
|
||||
other.failureOrRefund == failureOrRefund) &&
|
||||
(identical(other.isSubmitting, isSubmitting) ||
|
||||
other.isSubmitting == isSubmitting));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(
|
||||
runtimeType,
|
||||
order,
|
||||
reason,
|
||||
refundReason,
|
||||
failureOrRefund,
|
||||
isSubmitting,
|
||||
);
|
||||
|
||||
/// Create a copy of RefundFormState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$RefundFormStateImplCopyWith<_$RefundFormStateImpl> get copyWith =>
|
||||
__$$RefundFormStateImplCopyWithImpl<_$RefundFormStateImpl>(
|
||||
this,
|
||||
_$identity,
|
||||
);
|
||||
}
|
||||
|
||||
abstract class _RefundFormState implements RefundFormState {
|
||||
factory _RefundFormState({
|
||||
required final Order order,
|
||||
required final String reason,
|
||||
final RefundReason? refundReason,
|
||||
required final Option<Either<OrderFailure, Unit>> failureOrRefund,
|
||||
final bool isSubmitting,
|
||||
}) = _$RefundFormStateImpl;
|
||||
|
||||
@override
|
||||
Order get order;
|
||||
@override
|
||||
String get reason;
|
||||
@override
|
||||
RefundReason? get refundReason;
|
||||
@override
|
||||
Option<Either<OrderFailure, Unit>> get failureOrRefund;
|
||||
@override
|
||||
bool get isSubmitting;
|
||||
|
||||
/// Create a copy of RefundFormState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$RefundFormStateImplCopyWith<_$RefundFormStateImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
10
lib/application/refund/refund_form/refund_form_event.dart
Normal file
10
lib/application/refund/refund_form/refund_form_event.dart
Normal file
@ -0,0 +1,10 @@
|
||||
part of 'refund_form_bloc.dart';
|
||||
|
||||
@freezed
|
||||
class RefundFormEvent with _$RefundFormEvent {
|
||||
const factory RefundFormEvent.setOrder(Order order) = _SetOrder;
|
||||
const factory RefundFormEvent.reasonChanged(String reason) = _ReasonChanged;
|
||||
const factory RefundFormEvent.refundReasonChanged(RefundReason refundReason) =
|
||||
_RefundReasonChanged;
|
||||
const factory RefundFormEvent.submitted() = _Submitted;
|
||||
}
|
||||
18
lib/application/refund/refund_form/refund_form_state.dart
Normal file
18
lib/application/refund/refund_form/refund_form_state.dart
Normal file
@ -0,0 +1,18 @@
|
||||
part of 'refund_form_bloc.dart';
|
||||
|
||||
@freezed
|
||||
class RefundFormState with _$RefundFormState {
|
||||
factory RefundFormState({
|
||||
required Order order,
|
||||
required String reason,
|
||||
RefundReason? refundReason,
|
||||
required Option<Either<OrderFailure, Unit>> failureOrRefund,
|
||||
@Default(false) bool isSubmitting,
|
||||
}) = _RefundFormState;
|
||||
|
||||
factory RefundFormState.initial() => RefundFormState(
|
||||
order: Order.empty(),
|
||||
reason: '',
|
||||
failureOrRefund: none(),
|
||||
);
|
||||
}
|
||||
44
lib/common/data/refund_data.dart
Normal file
44
lib/common/data/refund_data.dart
Normal file
@ -0,0 +1,44 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../theme/theme.dart';
|
||||
|
||||
class RefundReason {
|
||||
final String value;
|
||||
final IconData icon;
|
||||
final Color color;
|
||||
|
||||
const RefundReason({
|
||||
required this.value,
|
||||
required this.icon,
|
||||
required this.color,
|
||||
});
|
||||
}
|
||||
|
||||
const List<RefundReason> refundReasons = [
|
||||
RefundReason(
|
||||
value: 'Barang Rusak',
|
||||
icon: Icons.broken_image,
|
||||
color: AppColor.primary,
|
||||
),
|
||||
RefundReason(
|
||||
value: 'Salah Item',
|
||||
icon: Icons.swap_horiz,
|
||||
color: Colors.orange,
|
||||
),
|
||||
RefundReason(
|
||||
value: 'Tidak Sesuai Pesanan',
|
||||
icon: Icons.error_outline,
|
||||
color: Colors.amber,
|
||||
),
|
||||
RefundReason(
|
||||
value: 'Permintaan Customer',
|
||||
icon: Icons.person,
|
||||
color: Colors.blue,
|
||||
),
|
||||
RefundReason(
|
||||
value: 'Kualitas Tidak Baik',
|
||||
icon: Icons.thumb_down,
|
||||
color: Colors.purple,
|
||||
),
|
||||
RefundReason(value: 'Lainnya', icon: Icons.more_horiz, color: Colors.red),
|
||||
];
|
||||
@ -32,6 +32,7 @@ class Order with _$Order {
|
||||
required int remainingAmount,
|
||||
required String paymentStatus,
|
||||
required int refundAmount,
|
||||
required String refundReason,
|
||||
required bool isVoid,
|
||||
required bool isRefund,
|
||||
required String notes,
|
||||
@ -72,6 +73,7 @@ class Order with _$Order {
|
||||
totalPaid: 0,
|
||||
paymentCount: 0,
|
||||
splitType: '',
|
||||
refundReason: '',
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -269,6 +269,7 @@ mixin _$Order {
|
||||
int get remainingAmount => throw _privateConstructorUsedError;
|
||||
String get paymentStatus => throw _privateConstructorUsedError;
|
||||
int get refundAmount => throw _privateConstructorUsedError;
|
||||
String get refundReason => throw _privateConstructorUsedError;
|
||||
bool get isVoid => throw _privateConstructorUsedError;
|
||||
bool get isRefund => throw _privateConstructorUsedError;
|
||||
String get notes => throw _privateConstructorUsedError;
|
||||
@ -308,6 +309,7 @@ abstract class $OrderCopyWith<$Res> {
|
||||
int remainingAmount,
|
||||
String paymentStatus,
|
||||
int refundAmount,
|
||||
String refundReason,
|
||||
bool isVoid,
|
||||
bool isRefund,
|
||||
String notes,
|
||||
@ -352,6 +354,7 @@ class _$OrderCopyWithImpl<$Res, $Val extends Order>
|
||||
Object? remainingAmount = null,
|
||||
Object? paymentStatus = null,
|
||||
Object? refundAmount = null,
|
||||
Object? refundReason = null,
|
||||
Object? isVoid = null,
|
||||
Object? isRefund = null,
|
||||
Object? notes = null,
|
||||
@ -426,6 +429,10 @@ class _$OrderCopyWithImpl<$Res, $Val extends Order>
|
||||
? _value.refundAmount
|
||||
: refundAmount // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
refundReason: null == refundReason
|
||||
? _value.refundReason
|
||||
: refundReason // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
isVoid: null == isVoid
|
||||
? _value.isVoid
|
||||
: isVoid // ignore: cast_nullable_to_non_nullable
|
||||
@ -500,6 +507,7 @@ abstract class _$$OrderImplCopyWith<$Res> implements $OrderCopyWith<$Res> {
|
||||
int remainingAmount,
|
||||
String paymentStatus,
|
||||
int refundAmount,
|
||||
String refundReason,
|
||||
bool isVoid,
|
||||
bool isRefund,
|
||||
String notes,
|
||||
@ -543,6 +551,7 @@ class __$$OrderImplCopyWithImpl<$Res>
|
||||
Object? remainingAmount = null,
|
||||
Object? paymentStatus = null,
|
||||
Object? refundAmount = null,
|
||||
Object? refundReason = null,
|
||||
Object? isVoid = null,
|
||||
Object? isRefund = null,
|
||||
Object? notes = null,
|
||||
@ -617,6 +626,10 @@ class __$$OrderImplCopyWithImpl<$Res>
|
||||
? _value.refundAmount
|
||||
: refundAmount // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
refundReason: null == refundReason
|
||||
? _value.refundReason
|
||||
: refundReason // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
isVoid: null == isVoid
|
||||
? _value.isVoid
|
||||
: isVoid // ignore: cast_nullable_to_non_nullable
|
||||
@ -685,6 +698,7 @@ class _$OrderImpl implements _Order {
|
||||
required this.remainingAmount,
|
||||
required this.paymentStatus,
|
||||
required this.refundAmount,
|
||||
required this.refundReason,
|
||||
required this.isVoid,
|
||||
required this.isRefund,
|
||||
required this.notes,
|
||||
@ -731,6 +745,8 @@ class _$OrderImpl implements _Order {
|
||||
@override
|
||||
final int refundAmount;
|
||||
@override
|
||||
final String refundReason;
|
||||
@override
|
||||
final bool isVoid;
|
||||
@override
|
||||
final bool isRefund;
|
||||
@ -773,7 +789,7 @@ class _$OrderImpl implements _Order {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'Order(id: $id, orderNumber: $orderNumber, outletId: $outletId, userId: $userId, tableNumber: $tableNumber, orderType: $orderType, status: $status, subtotal: $subtotal, taxAmount: $taxAmount, discountAmount: $discountAmount, totalAmount: $totalAmount, totalCost: $totalCost, remainingAmount: $remainingAmount, paymentStatus: $paymentStatus, refundAmount: $refundAmount, isVoid: $isVoid, isRefund: $isRefund, notes: $notes, metadata: $metadata, createdAt: $createdAt, updatedAt: $updatedAt, orderItems: $orderItems, payments: $payments, totalPaid: $totalPaid, paymentCount: $paymentCount, splitType: $splitType)';
|
||||
return 'Order(id: $id, orderNumber: $orderNumber, outletId: $outletId, userId: $userId, tableNumber: $tableNumber, orderType: $orderType, status: $status, subtotal: $subtotal, taxAmount: $taxAmount, discountAmount: $discountAmount, totalAmount: $totalAmount, totalCost: $totalCost, remainingAmount: $remainingAmount, paymentStatus: $paymentStatus, refundAmount: $refundAmount, refundReason: $refundReason, isVoid: $isVoid, isRefund: $isRefund, notes: $notes, metadata: $metadata, createdAt: $createdAt, updatedAt: $updatedAt, orderItems: $orderItems, payments: $payments, totalPaid: $totalPaid, paymentCount: $paymentCount, splitType: $splitType)';
|
||||
}
|
||||
|
||||
@override
|
||||
@ -808,6 +824,8 @@ class _$OrderImpl implements _Order {
|
||||
other.paymentStatus == paymentStatus) &&
|
||||
(identical(other.refundAmount, refundAmount) ||
|
||||
other.refundAmount == refundAmount) &&
|
||||
(identical(other.refundReason, refundReason) ||
|
||||
other.refundReason == refundReason) &&
|
||||
(identical(other.isVoid, isVoid) || other.isVoid == isVoid) &&
|
||||
(identical(other.isRefund, isRefund) ||
|
||||
other.isRefund == isRefund) &&
|
||||
@ -848,6 +866,7 @@ class _$OrderImpl implements _Order {
|
||||
remainingAmount,
|
||||
paymentStatus,
|
||||
refundAmount,
|
||||
refundReason,
|
||||
isVoid,
|
||||
isRefund,
|
||||
notes,
|
||||
@ -887,6 +906,7 @@ abstract class _Order implements Order {
|
||||
required final int remainingAmount,
|
||||
required final String paymentStatus,
|
||||
required final int refundAmount,
|
||||
required final String refundReason,
|
||||
required final bool isVoid,
|
||||
required final bool isRefund,
|
||||
required final String notes,
|
||||
@ -931,6 +951,8 @@ abstract class _Order implements Order {
|
||||
@override
|
||||
int get refundAmount;
|
||||
@override
|
||||
String get refundReason;
|
||||
@override
|
||||
bool get isVoid;
|
||||
@override
|
||||
bool get isRefund;
|
||||
|
||||
@ -40,4 +40,10 @@ abstract class IOrderRepository {
|
||||
Future<Either<OrderFailure, Payment>> createSplitBill(
|
||||
PaymentSplitBillRequest request,
|
||||
);
|
||||
|
||||
Future<Either<OrderFailure, Unit>> refundOrder({
|
||||
required String id,
|
||||
required String reason,
|
||||
required int refundAmount,
|
||||
});
|
||||
}
|
||||
|
||||
@ -262,4 +262,27 @@ class OrderRemoteDataProvider {
|
||||
return DC.error(OrderFailure.serverError(e));
|
||||
}
|
||||
}
|
||||
|
||||
Future<DC<OrderFailure, Unit>> refundPayment({
|
||||
required String id,
|
||||
required String reason,
|
||||
required int refundAmount,
|
||||
}) async {
|
||||
try {
|
||||
final response = await _apiClient.post(
|
||||
'${ApiPath.orders}/$id/refund',
|
||||
data: {'refund_amount': refundAmount, 'reason': reason},
|
||||
headers: getAuthorizationHeader(),
|
||||
);
|
||||
|
||||
if (response.data['success'] == false) {
|
||||
return DC.error(OrderFailure.unexpectedError());
|
||||
}
|
||||
|
||||
return DC.data(unit);
|
||||
} on ApiFailure catch (e, s) {
|
||||
log('refundPaymnetError', name: _logName, error: e, stackTrace: s);
|
||||
return DC.error(OrderFailure.serverError(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -44,6 +44,7 @@ class OrderDto with _$OrderDto {
|
||||
@JsonKey(name: "remaining_amount") int? remainingAmount,
|
||||
@JsonKey(name: "payment_status") String? paymentStatus,
|
||||
@JsonKey(name: "refund_amount") int? refundAmount,
|
||||
@JsonKey(name: "refund_reason") String? refundReason,
|
||||
@JsonKey(name: "is_void") bool? isVoid,
|
||||
@JsonKey(name: "is_refund") bool? isRefund,
|
||||
@JsonKey(name: "notes") String? notes,
|
||||
@ -61,6 +62,7 @@ class OrderDto with _$OrderDto {
|
||||
_$OrderDtoFromJson(json);
|
||||
|
||||
// Optional: mapper ke domain entity
|
||||
|
||||
Order toDomain() => Order(
|
||||
id: id ?? '',
|
||||
orderNumber: orderNumber ?? '',
|
||||
@ -88,6 +90,7 @@ class OrderDto with _$OrderDto {
|
||||
totalPaid: totalPaid ?? 0,
|
||||
paymentCount: paymentCount ?? 0,
|
||||
splitType: splitType ?? '',
|
||||
refundReason: refundReason ?? '',
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -328,6 +328,8 @@ mixin _$OrderDto {
|
||||
String? get paymentStatus => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: "refund_amount")
|
||||
int? get refundAmount => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: "refund_reason")
|
||||
String? get refundReason => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: "is_void")
|
||||
bool? get isVoid => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: "is_refund")
|
||||
@ -382,6 +384,7 @@ abstract class $OrderDtoCopyWith<$Res> {
|
||||
@JsonKey(name: "remaining_amount") int? remainingAmount,
|
||||
@JsonKey(name: "payment_status") String? paymentStatus,
|
||||
@JsonKey(name: "refund_amount") int? refundAmount,
|
||||
@JsonKey(name: "refund_reason") String? refundReason,
|
||||
@JsonKey(name: "is_void") bool? isVoid,
|
||||
@JsonKey(name: "is_refund") bool? isRefund,
|
||||
@JsonKey(name: "notes") String? notes,
|
||||
@ -426,6 +429,7 @@ class _$OrderDtoCopyWithImpl<$Res, $Val extends OrderDto>
|
||||
Object? remainingAmount = freezed,
|
||||
Object? paymentStatus = freezed,
|
||||
Object? refundAmount = freezed,
|
||||
Object? refundReason = freezed,
|
||||
Object? isVoid = freezed,
|
||||
Object? isRefund = freezed,
|
||||
Object? notes = freezed,
|
||||
@ -500,6 +504,10 @@ class _$OrderDtoCopyWithImpl<$Res, $Val extends OrderDto>
|
||||
? _value.refundAmount
|
||||
: refundAmount // ignore: cast_nullable_to_non_nullable
|
||||
as int?,
|
||||
refundReason: freezed == refundReason
|
||||
? _value.refundReason
|
||||
: refundReason // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
isVoid: freezed == isVoid
|
||||
? _value.isVoid
|
||||
: isVoid // ignore: cast_nullable_to_non_nullable
|
||||
@ -575,6 +583,7 @@ abstract class _$$OrderDtoImplCopyWith<$Res>
|
||||
@JsonKey(name: "remaining_amount") int? remainingAmount,
|
||||
@JsonKey(name: "payment_status") String? paymentStatus,
|
||||
@JsonKey(name: "refund_amount") int? refundAmount,
|
||||
@JsonKey(name: "refund_reason") String? refundReason,
|
||||
@JsonKey(name: "is_void") bool? isVoid,
|
||||
@JsonKey(name: "is_refund") bool? isRefund,
|
||||
@JsonKey(name: "notes") String? notes,
|
||||
@ -618,6 +627,7 @@ class __$$OrderDtoImplCopyWithImpl<$Res>
|
||||
Object? remainingAmount = freezed,
|
||||
Object? paymentStatus = freezed,
|
||||
Object? refundAmount = freezed,
|
||||
Object? refundReason = freezed,
|
||||
Object? isVoid = freezed,
|
||||
Object? isRefund = freezed,
|
||||
Object? notes = freezed,
|
||||
@ -692,6 +702,10 @@ class __$$OrderDtoImplCopyWithImpl<$Res>
|
||||
? _value.refundAmount
|
||||
: refundAmount // ignore: cast_nullable_to_non_nullable
|
||||
as int?,
|
||||
refundReason: freezed == refundReason
|
||||
? _value.refundReason
|
||||
: refundReason // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
isVoid: freezed == isVoid
|
||||
? _value.isVoid
|
||||
: isVoid // ignore: cast_nullable_to_non_nullable
|
||||
@ -760,6 +774,7 @@ class _$OrderDtoImpl extends _OrderDto {
|
||||
@JsonKey(name: "remaining_amount") this.remainingAmount,
|
||||
@JsonKey(name: "payment_status") this.paymentStatus,
|
||||
@JsonKey(name: "refund_amount") this.refundAmount,
|
||||
@JsonKey(name: "refund_reason") this.refundReason,
|
||||
@JsonKey(name: "is_void") this.isVoid,
|
||||
@JsonKey(name: "is_refund") this.isRefund,
|
||||
@JsonKey(name: "notes") this.notes,
|
||||
@ -825,6 +840,9 @@ class _$OrderDtoImpl extends _OrderDto {
|
||||
@JsonKey(name: "refund_amount")
|
||||
final int? refundAmount;
|
||||
@override
|
||||
@JsonKey(name: "refund_reason")
|
||||
final String? refundReason;
|
||||
@override
|
||||
@JsonKey(name: "is_void")
|
||||
final bool? isVoid;
|
||||
@override
|
||||
@ -884,7 +902,7 @@ class _$OrderDtoImpl extends _OrderDto {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'OrderDto(id: $id, orderNumber: $orderNumber, outletId: $outletId, userId: $userId, tableNumber: $tableNumber, orderType: $orderType, status: $status, subtotal: $subtotal, taxAmount: $taxAmount, discountAmount: $discountAmount, totalAmount: $totalAmount, totalCost: $totalCost, remainingAmount: $remainingAmount, paymentStatus: $paymentStatus, refundAmount: $refundAmount, isVoid: $isVoid, isRefund: $isRefund, notes: $notes, metadata: $metadata, createdAt: $createdAt, updatedAt: $updatedAt, orderItems: $orderItems, payments: $payments, totalPaid: $totalPaid, paymentCount: $paymentCount, splitType: $splitType)';
|
||||
return 'OrderDto(id: $id, orderNumber: $orderNumber, outletId: $outletId, userId: $userId, tableNumber: $tableNumber, orderType: $orderType, status: $status, subtotal: $subtotal, taxAmount: $taxAmount, discountAmount: $discountAmount, totalAmount: $totalAmount, totalCost: $totalCost, remainingAmount: $remainingAmount, paymentStatus: $paymentStatus, refundAmount: $refundAmount, refundReason: $refundReason, isVoid: $isVoid, isRefund: $isRefund, notes: $notes, metadata: $metadata, createdAt: $createdAt, updatedAt: $updatedAt, orderItems: $orderItems, payments: $payments, totalPaid: $totalPaid, paymentCount: $paymentCount, splitType: $splitType)';
|
||||
}
|
||||
|
||||
@override
|
||||
@ -919,6 +937,8 @@ class _$OrderDtoImpl extends _OrderDto {
|
||||
other.paymentStatus == paymentStatus) &&
|
||||
(identical(other.refundAmount, refundAmount) ||
|
||||
other.refundAmount == refundAmount) &&
|
||||
(identical(other.refundReason, refundReason) ||
|
||||
other.refundReason == refundReason) &&
|
||||
(identical(other.isVoid, isVoid) || other.isVoid == isVoid) &&
|
||||
(identical(other.isRefund, isRefund) ||
|
||||
other.isRefund == isRefund) &&
|
||||
@ -960,6 +980,7 @@ class _$OrderDtoImpl extends _OrderDto {
|
||||
remainingAmount,
|
||||
paymentStatus,
|
||||
refundAmount,
|
||||
refundReason,
|
||||
isVoid,
|
||||
isRefund,
|
||||
notes,
|
||||
@ -1004,6 +1025,7 @@ abstract class _OrderDto extends OrderDto {
|
||||
@JsonKey(name: "remaining_amount") final int? remainingAmount,
|
||||
@JsonKey(name: "payment_status") final String? paymentStatus,
|
||||
@JsonKey(name: "refund_amount") final int? refundAmount,
|
||||
@JsonKey(name: "refund_reason") final String? refundReason,
|
||||
@JsonKey(name: "is_void") final bool? isVoid,
|
||||
@JsonKey(name: "is_refund") final bool? isRefund,
|
||||
@JsonKey(name: "notes") final String? notes,
|
||||
@ -1067,6 +1089,9 @@ abstract class _OrderDto extends OrderDto {
|
||||
@JsonKey(name: "refund_amount")
|
||||
int? get refundAmount;
|
||||
@override
|
||||
@JsonKey(name: "refund_reason")
|
||||
String? get refundReason;
|
||||
@override
|
||||
@JsonKey(name: "is_void")
|
||||
bool? get isVoid;
|
||||
@override
|
||||
|
||||
@ -43,6 +43,7 @@ _$OrderDtoImpl _$$OrderDtoImplFromJson(Map<String, dynamic> json) =>
|
||||
remainingAmount: (json['remaining_amount'] as num?)?.toInt(),
|
||||
paymentStatus: json['payment_status'] as String?,
|
||||
refundAmount: (json['refund_amount'] as num?)?.toInt(),
|
||||
refundReason: json['refund_reason'] as String?,
|
||||
isVoid: json['is_void'] as bool?,
|
||||
isRefund: json['is_refund'] as bool?,
|
||||
notes: json['notes'] as String?,
|
||||
@ -77,6 +78,7 @@ Map<String, dynamic> _$$OrderDtoImplToJson(_$OrderDtoImpl instance) =>
|
||||
'remaining_amount': instance.remainingAmount,
|
||||
'payment_status': instance.paymentStatus,
|
||||
'refund_amount': instance.refundAmount,
|
||||
'refund_reason': instance.refundReason,
|
||||
'is_void': instance.isVoid,
|
||||
'is_refund': instance.isRefund,
|
||||
'notes': instance.notes,
|
||||
|
||||
@ -198,4 +198,26 @@ class OrderRepository implements IOrderRepository {
|
||||
return left(const OrderFailure.unexpectedError());
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Either<OrderFailure, Unit>> refundOrder({
|
||||
required String id,
|
||||
required String reason,
|
||||
required int refundAmount,
|
||||
}) async {
|
||||
try {
|
||||
final result = await _dataProvider.refundPayment(
|
||||
id: id,
|
||||
reason: reason,
|
||||
refundAmount: refundAmount,
|
||||
);
|
||||
if (result.hasError) {
|
||||
return left(result.error!);
|
||||
}
|
||||
return right(unit);
|
||||
} catch (e) {
|
||||
log('refundOrderError', name: _logName, error: e);
|
||||
return left(const OrderFailure.unexpectedError());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,6 +30,8 @@ import 'package:apskel_pos_flutter_v2/application/payment_method/payment_method_
|
||||
as _i952;
|
||||
import 'package:apskel_pos_flutter_v2/application/product/product_loader/product_loader_bloc.dart'
|
||||
as _i13;
|
||||
import 'package:apskel_pos_flutter_v2/application/refund/refund_form/refund_form_bloc.dart'
|
||||
as _i837;
|
||||
import 'package:apskel_pos_flutter_v2/application/report/report_bloc.dart'
|
||||
as _i257;
|
||||
import 'package:apskel_pos_flutter_v2/application/split_bill/split_bill_form/split_bill_form_bloc.dart'
|
||||
@ -248,6 +250,9 @@ extension GetItInjectableX on _i174.GetIt {
|
||||
gh.factory<_i822.VoidFormBloc>(
|
||||
() => _i822.VoidFormBloc(gh<_i299.IOrderRepository>()),
|
||||
);
|
||||
gh.factory<_i837.RefundFormBloc>(
|
||||
() => _i837.RefundFormBloc(gh<_i299.IOrderRepository>()),
|
||||
);
|
||||
gh.factory<_i683.CustomerLoaderBloc>(
|
||||
() => _i683.CustomerLoaderBloc(gh<_i143.ICustomerRepository>()),
|
||||
);
|
||||
|
||||
@ -89,9 +89,9 @@ class OrderRightPanel extends StatelessWidget {
|
||||
if (state.selectedOrder?.isRefund == false)
|
||||
AppElevatedButton.outlined(
|
||||
onPressed: () {
|
||||
// context.push(RefundPage(
|
||||
// selectedOrder: orderDetail!,
|
||||
// ));
|
||||
context.router.push(
|
||||
RefundRoute(order: state.selectedOrder!),
|
||||
);
|
||||
},
|
||||
label: 'Refund',
|
||||
icon: Icon(Icons.autorenew),
|
||||
|
||||
@ -0,0 +1,68 @@
|
||||
import 'package:auto_route/auto_route.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
import '../../../../../application/order/order_loader/order_loader_bloc.dart';
|
||||
import '../../../../../common/theme/theme.dart';
|
||||
import '../../../../components/error/order_loader_error_state_widget.dart';
|
||||
import '../../../../components/loader/loader_with_text.dart';
|
||||
import 'widgets/refund_success_left_panel.dart';
|
||||
import 'widgets/refund_success_right_panel.dart';
|
||||
|
||||
@RoutePage()
|
||||
class RefundSuccessPage extends StatelessWidget implements AutoRouteWrapper {
|
||||
final String orderId;
|
||||
const RefundSuccessPage({super.key, required this.orderId});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: AppColor.background,
|
||||
body: SafeArea(
|
||||
child: BlocBuilder<OrderLoaderBloc, OrderLoaderState>(
|
||||
builder: (context, state) {
|
||||
if (state.isFetchingById) {
|
||||
return const Center(child: LoaderWithText());
|
||||
}
|
||||
return state.failureOptionGetById.fold(
|
||||
() => Container(
|
||||
padding: const EdgeInsets.all(24.0),
|
||||
child: Row(
|
||||
children: [
|
||||
// Left Panel - Success Message & Order Info
|
||||
Expanded(
|
||||
flex: 35,
|
||||
child: RefundSuccessLeftPanel(order: state.order),
|
||||
),
|
||||
|
||||
const SizedBox(width: 16),
|
||||
|
||||
// Right Panel - Order Details
|
||||
Expanded(
|
||||
flex: 65,
|
||||
child: RefundSuccessRightPanel(order: state.order),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
(f) => OrderLoaderErrorStateWidget(
|
||||
failure: f,
|
||||
onRefresh: () {
|
||||
context.read<OrderLoaderBloc>().add(
|
||||
OrderLoaderEvent.getById(orderId),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget wrappedRoute(BuildContext context) {
|
||||
context.read<OrderLoaderBloc>().add(OrderLoaderEvent.getById(orderId));
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,268 @@
|
||||
import 'package:auto_route/auto_route.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../../../common/extension/extension.dart';
|
||||
import '../../../../../../common/theme/theme.dart';
|
||||
import '../../../../../../domain/order/order.dart';
|
||||
import '../../../../../components/button/button.dart';
|
||||
import '../../../../../components/spaces/space.dart';
|
||||
import '../../../../../router/app_router.gr.dart';
|
||||
|
||||
class RefundSuccessLeftPanel extends StatelessWidget {
|
||||
final Order order;
|
||||
const RefundSuccessLeftPanel({super.key, required this.order});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(24),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.all(32.0),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
colors: [
|
||||
AppColor.primary.withOpacity(0.1),
|
||||
AppColor.primary.withOpacity(0.05),
|
||||
],
|
||||
),
|
||||
borderRadius: const BorderRadius.vertical(
|
||||
top: Radius.circular(24),
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.all(20.0),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
colors: [
|
||||
AppColor.primary,
|
||||
AppColor.primary.withOpacity(0.8),
|
||||
],
|
||||
),
|
||||
shape: BoxShape.circle,
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: AppColor.primary.withOpacity(0.3),
|
||||
blurRadius: 20,
|
||||
offset: const Offset(0, 10),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.check_rounded,
|
||||
size: 48,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
SpaceHeight(16),
|
||||
Text(
|
||||
'Refund Berhasil!',
|
||||
style: AppStyle.h4.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: AppColor.primary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(24.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'Informasi Pesanan',
|
||||
style: AppStyle.lg.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
SpaceHeight(24),
|
||||
_buildInfoRow(
|
||||
icon: Icons.person,
|
||||
label: 'Pemesan',
|
||||
value: order.metadata['customer_name'] ?? "-",
|
||||
),
|
||||
if (order.payments.isNotEmpty) ...[
|
||||
const SpaceHeight(12),
|
||||
_buildInfoRow(
|
||||
icon: Icons.wallet_outlined,
|
||||
label: 'Metode Pembayaran',
|
||||
value: order.payments.first.paymentMethodName,
|
||||
),
|
||||
],
|
||||
if (order.tableNumber != "") ...[
|
||||
const SpaceHeight(12),
|
||||
_buildInfoRow(
|
||||
icon: Icons.table_restaurant_outlined,
|
||||
label: 'No. Meja',
|
||||
value: order.tableNumber,
|
||||
),
|
||||
],
|
||||
const SpaceHeight(12),
|
||||
_buildInfoRow(
|
||||
icon: Icons.access_time_rounded,
|
||||
label: 'Waktu',
|
||||
value: (DateTime.now()).toFormattedDateTime(),
|
||||
),
|
||||
const SpaceHeight(12),
|
||||
Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
colors: [
|
||||
AppColor.primary.withOpacity(0.1),
|
||||
AppColor.primary.withOpacity(0.05),
|
||||
],
|
||||
),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(
|
||||
color: AppColor.primary.withOpacity(0.2),
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
order.refundReason,
|
||||
style: AppStyle.md.copyWith(
|
||||
color: AppColor.primary,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
_buildBottomSection(context),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildBottomSection(BuildContext context) {
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.all(24.0),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topCenter,
|
||||
end: Alignment.bottomCenter,
|
||||
colors: [Colors.grey.shade50, Colors.white],
|
||||
),
|
||||
borderRadius: const BorderRadius.vertical(bottom: Radius.circular(24)),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
// Action Buttons with Modern Design
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: AppElevatedButton.outlined(
|
||||
onPressed: () =>
|
||||
context.router.replaceAll([const MainRoute()]),
|
||||
label: "Kembali",
|
||||
),
|
||||
),
|
||||
const SpaceWidth(16),
|
||||
Expanded(
|
||||
child: AppElevatedButton.filled(
|
||||
onPressed: () {
|
||||
// onPrintRecipt(
|
||||
// context,
|
||||
// order: widget.order,
|
||||
// paymentMethod: widget.paymentMethod,
|
||||
// nominalBayar: widget.paymentMethod == "Cash"
|
||||
// ? widget.nominalBayar
|
||||
// : widget.order.totalAmount ?? 0,
|
||||
// kembalian: widget.nominalBayar -
|
||||
// (widget.order.totalAmount ?? 0),
|
||||
// productQuantity: widget.productQuantity,
|
||||
// );
|
||||
// onPrint(
|
||||
// context,
|
||||
// productQuantity: widget.productQuantity,
|
||||
// order: widget.order,
|
||||
// );
|
||||
},
|
||||
label: 'Cetak Struk',
|
||||
icon: Icon(Icons.print_rounded, color: AppColor.white),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildInfoRow({
|
||||
required IconData icon,
|
||||
required String label,
|
||||
required String value,
|
||||
Color? valueColor,
|
||||
bool showBadge = false,
|
||||
}) {
|
||||
return Row(
|
||||
children: [
|
||||
Icon(icon, size: 18, color: AppColor.primary),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Text(
|
||||
label,
|
||||
style: AppStyle.md.copyWith(color: AppColor.textSecondary),
|
||||
),
|
||||
),
|
||||
if (showBadge && valueColor != null)
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
color: valueColor.withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(Icons.check_circle, size: 14, color: valueColor),
|
||||
const SizedBox(width: 4),
|
||||
Text(
|
||||
value,
|
||||
style: AppStyle.sm.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: valueColor,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
else
|
||||
Text(
|
||||
value,
|
||||
style: AppStyle.md.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: valueColor ?? AppColor.primary,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,352 @@
|
||||
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 RefundSuccessRightPanel extends StatelessWidget {
|
||||
final Order order;
|
||||
const RefundSuccessRightPanel({super.key, required this.order});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(24),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
_header(),
|
||||
Expanded(
|
||||
child: ListView.separated(
|
||||
padding: const EdgeInsets.all(24.0),
|
||||
itemCount: order.orderItems.length,
|
||||
separatorBuilder: (context, index) => const SizedBox(height: 12),
|
||||
itemBuilder: (context, index) {
|
||||
return _buildProductCard(index);
|
||||
},
|
||||
),
|
||||
),
|
||||
_buildSummaryFooter(),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSummaryFooter() {
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.all(24.0),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topCenter,
|
||||
end: Alignment.bottomCenter,
|
||||
colors: [Colors.grey.shade50, Colors.white],
|
||||
),
|
||||
borderRadius: const BorderRadius.vertical(bottom: Radius.circular(24)),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
// Decorative Divider
|
||||
Container(
|
||||
height: 1,
|
||||
margin: const EdgeInsets.only(bottom: 20),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: [
|
||||
Colors.transparent,
|
||||
AppColor.primary.withOpacity(0.3),
|
||||
Colors.transparent,
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// Subtotal Row
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.shopping_cart_outlined,
|
||||
size: 16,
|
||||
color: AppColor.textSecondary,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
'Subtotal (${order.orderItems.length} items)',
|
||||
style: AppStyle.md.copyWith(
|
||||
color: AppColor.textSecondary,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Text(
|
||||
(order.totalAmount).toString().currencyFormatRpV2,
|
||||
style: AppStyle.md.copyWith(fontWeight: FontWeight.w600),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
const SpaceHeight(16),
|
||||
|
||||
// Total Payment Row with Enhanced Styling
|
||||
Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
colors: [
|
||||
AppColor.primary.withOpacity(0.1),
|
||||
AppColor.primary.withOpacity(0.05),
|
||||
],
|
||||
),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(
|
||||
color: AppColor.primary.withOpacity(0.2),
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.all(6),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.primary.withOpacity(0.2),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Icon(
|
||||
Icons.payments_rounded,
|
||||
size: 16,
|
||||
color: AppColor.primary,
|
||||
),
|
||||
),
|
||||
SpaceWidth(12),
|
||||
Text(
|
||||
'Total Refund',
|
||||
style: AppStyle.lg.copyWith(fontWeight: FontWeight.bold),
|
||||
),
|
||||
],
|
||||
),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 12,
|
||||
vertical: 6,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: [
|
||||
AppColor.primary,
|
||||
AppColor.primary.withOpacity(0.8),
|
||||
],
|
||||
),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: AppColor.primary.withOpacity(0.3),
|
||||
blurRadius: 4,
|
||||
offset: const Offset(0, 2),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Text(
|
||||
(order.totalAmount).toString().currencyFormatRpV2,
|
||||
style: AppStyle.xl.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildProductCard(int index) {
|
||||
final item = order.orderItems[index];
|
||||
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(16.0),
|
||||
border: Border.all(color: AppColor.border, width: 1),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
// Enhanced Product Image
|
||||
Container(
|
||||
width: 70,
|
||||
height: 70,
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.primaryWithOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(16.0),
|
||||
),
|
||||
child: Icon(
|
||||
Icons.restaurant_rounded,
|
||||
color: AppColor.primary,
|
||||
size: 28,
|
||||
),
|
||||
),
|
||||
|
||||
const SpaceWidth(16),
|
||||
|
||||
// Product Details
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
item.productName,
|
||||
style: AppStyle.lg.copyWith(fontWeight: FontWeight.bold),
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
const SpaceHeight(6),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 8,
|
||||
vertical: 4,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey.shade100,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Text(
|
||||
item.unitPrice.currencyFormatRpV2,
|
||||
style: AppStyle.md.copyWith(
|
||||
color: AppColor.textSecondary,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
const SpaceWidth(16),
|
||||
|
||||
// Quantity and Total
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 12,
|
||||
vertical: 8,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: [
|
||||
AppColor.primary,
|
||||
AppColor.primary.withOpacity(0.8),
|
||||
],
|
||||
),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Text(
|
||||
'${item.quantity}x',
|
||||
style: AppStyle.md.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SpaceHeight(8),
|
||||
Text(
|
||||
item.totalPrice.toString().currencyFormatRpV2,
|
||||
style: AppStyle.lg.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: AppColor.primary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Container _header() {
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.all(24.0),
|
||||
decoration: BoxDecoration(
|
||||
border: Border(bottom: BorderSide(color: AppColor.border)),
|
||||
borderRadius: const BorderRadius.vertical(top: Radius.circular(24)),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.all(12.0),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: [
|
||||
AppColor.primary.withOpacity(0.2),
|
||||
AppColor.primary.withOpacity(0.1),
|
||||
],
|
||||
),
|
||||
borderRadius: BorderRadius.circular(16.0),
|
||||
),
|
||||
child: Icon(
|
||||
Icons.receipt_long_rounded,
|
||||
color: AppColor.primary,
|
||||
size: 28,
|
||||
),
|
||||
),
|
||||
SpaceWidth(16),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'Detail Pesanan',
|
||||
style: AppStyle.xxl.copyWith(fontWeight: FontWeight.bold),
|
||||
),
|
||||
SpaceHeight(4),
|
||||
Text(
|
||||
'Ringkasan item yang dipesan',
|
||||
style: AppStyle.md.copyWith(color: Colors.grey.shade600),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: [AppColor.primary, AppColor.primary.withOpacity(0.8)],
|
||||
),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: AppColor.primary.withOpacity(0.3),
|
||||
blurRadius: 8,
|
||||
offset: const Offset(0, 4),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Text(
|
||||
'${order.orderItems.length} Items',
|
||||
style: const TextStyle(
|
||||
fontSize: 13,
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
60
lib/presentation/pages/refund/refund_page.dart
Normal file
60
lib/presentation/pages/refund/refund_page.dart
Normal file
@ -0,0 +1,60 @@
|
||||
import 'package:auto_route/auto_route.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
import '../../../application/refund/refund_form/refund_form_bloc.dart';
|
||||
import '../../../common/theme/theme.dart';
|
||||
import '../../../domain/order/order.dart';
|
||||
import '../../../injection.dart';
|
||||
import '../../components/toast/flushbar.dart';
|
||||
import '../../router/app_router.gr.dart';
|
||||
import 'widgets/refund_left_panel.dart';
|
||||
import 'widgets/refund_right_panel.dart';
|
||||
|
||||
@RoutePage()
|
||||
class RefundPage extends StatelessWidget implements AutoRouteWrapper {
|
||||
final Order order;
|
||||
const RefundPage({super.key, required this.order});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocListener<RefundFormBloc, RefundFormState>(
|
||||
listenWhen: (p, c) => p.failureOrRefund != c.failureOrRefund,
|
||||
listener: (context, state) {
|
||||
state.failureOrRefund.fold(
|
||||
() {},
|
||||
(either) => either.fold(
|
||||
(f) => AppFlushbar.showOrderFailureToast(context, f),
|
||||
(data) {
|
||||
if (context.mounted) {
|
||||
context.router.replace(RefundSuccessRoute(orderId: order.id));
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
child: Scaffold(
|
||||
backgroundColor: AppColor.background,
|
||||
body: SafeArea(
|
||||
child: BlocBuilder<RefundFormBloc, RefundFormState>(
|
||||
builder: (context, state) {
|
||||
return Row(
|
||||
children: [
|
||||
Expanded(flex: 2, child: RefundLeftPanel(state: state)),
|
||||
Expanded(flex: 4, child: RefundRightPanel(state: state)),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget wrappedRoute(BuildContext context) => BlocProvider(
|
||||
create: (_) =>
|
||||
getIt<RefundFormBloc>()..add(RefundFormEvent.setOrder(order)),
|
||||
child: this,
|
||||
);
|
||||
}
|
||||
291
lib/presentation/pages/refund/widgets/refund_left_panel.dart
Normal file
291
lib/presentation/pages/refund/widgets/refund_left_panel.dart
Normal file
@ -0,0 +1,291 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../application/refund/refund_form/refund_form_bloc.dart';
|
||||
import '../../../../common/extension/extension.dart';
|
||||
import '../../../../common/theme/theme.dart';
|
||||
import '../../../../domain/order/order.dart';
|
||||
import '../../../components/border/dashed_border.dart';
|
||||
import '../../../components/page/page_title.dart';
|
||||
import '../../../components/spaces/space.dart';
|
||||
|
||||
class RefundLeftPanel extends StatelessWidget {
|
||||
final RefundFormState state;
|
||||
const RefundLeftPanel({super.key, required this.state});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(color: AppColor.white),
|
||||
child: Column(
|
||||
children: [
|
||||
PageTitle(title: 'Refund Pesanan', subtitle: state.order.orderNumber),
|
||||
_buildInfo(),
|
||||
Expanded(
|
||||
child: ListView.builder(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16),
|
||||
itemCount: state.order.orderItems.length,
|
||||
itemBuilder: (context, index) {
|
||||
return _buildOrderItem(state.order.orderItems[index]);
|
||||
},
|
||||
),
|
||||
),
|
||||
_buildFooterSummary(),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildOrderItem(OrderItem item) {
|
||||
return Container(
|
||||
padding: EdgeInsets.symmetric(vertical: 12),
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
item.productName,
|
||||
style: AppStyle.lg.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
color: AppColor.textPrimary,
|
||||
),
|
||||
),
|
||||
if (item.productVariantName.isNotEmpty)
|
||||
Text(
|
||||
item.productVariantName,
|
||||
style: AppStyle.md.copyWith(
|
||||
color: AppColor.textSecondary,
|
||||
fontStyle: FontStyle.italic,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'Qty: ${item.quantity} x Rp ${item.unitPrice.currencyFormatRpV2} ',
|
||||
style: AppStyle.md.copyWith(
|
||||
color: AppColor.textSecondary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Text(
|
||||
item.totalPrice.currencyFormatRpV2,
|
||||
style: AppStyle.lg.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
color: AppColor.textPrimary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
if ((item.paidQuantity) > 1) ...[
|
||||
SpaceHeight(6),
|
||||
Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 10,
|
||||
vertical: 4,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.primary.withOpacity(0.2),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(color: AppColor.primary),
|
||||
),
|
||||
child: RichText(
|
||||
text: TextSpan(
|
||||
children: [
|
||||
TextSpan(
|
||||
text: '${item.paidQuantity} ',
|
||||
style: AppStyle.sm.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
color: AppColor.primary,
|
||||
),
|
||||
),
|
||||
TextSpan(
|
||||
text: 'dari ',
|
||||
style: AppStyle.sm.copyWith(color: AppColor.primary),
|
||||
),
|
||||
TextSpan(
|
||||
text: '${item.quantity} ',
|
||||
style: AppStyle.sm.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
color: AppColor.primary,
|
||||
),
|
||||
),
|
||||
TextSpan(
|
||||
text: 'kuantiti telah dibayar.',
|
||||
style: AppStyle.sm.copyWith(color: AppColor.primary),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Container _buildInfo() {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
decoration: BoxDecoration(
|
||||
border: Border(bottom: BorderSide(color: AppColor.border)),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
_buildInfoRow(
|
||||
icon: Icons.person,
|
||||
label: 'Pemesan',
|
||||
value: state.order.metadata['customer_name'] ?? "-",
|
||||
),
|
||||
const SpaceHeight(4),
|
||||
_buildInfoRow(
|
||||
icon: Icons.restaurant_outlined,
|
||||
label: 'Tipe Pesanan',
|
||||
value: state.order.orderType,
|
||||
),
|
||||
if (state.order.payments.isNotEmpty) ...[
|
||||
const SpaceHeight(4),
|
||||
_buildInfoRow(
|
||||
icon: Icons.wallet_outlined,
|
||||
label: 'Metode Pembayaran',
|
||||
value: state.order.payments.first.paymentMethodName,
|
||||
),
|
||||
],
|
||||
if (state.order.tableNumber != "") ...[
|
||||
const SpaceHeight(4),
|
||||
_buildInfoRow(
|
||||
icon: Icons.table_restaurant_outlined,
|
||||
label: 'No. Meja',
|
||||
value: state.order.tableNumber,
|
||||
),
|
||||
],
|
||||
const SpaceHeight(4),
|
||||
_buildInfoRow(
|
||||
icon: Icons.access_time_rounded,
|
||||
label: 'Waktu',
|
||||
value: (state.order.createdAt).toFormattedDateTime(),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Container _buildFooterSummary() {
|
||||
return Container(
|
||||
padding: EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
border: Border(top: BorderSide(color: AppColor.border)),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
_buildSummaryItem(
|
||||
title: 'Subtotal',
|
||||
value: state.order.subtotal.currencyFormatRpV2,
|
||||
),
|
||||
SpaceHeight(4),
|
||||
_buildSummaryItem(
|
||||
title: 'Pajak',
|
||||
value: state.order.taxAmount.currencyFormatRpV2,
|
||||
),
|
||||
SpaceHeight(4),
|
||||
_buildSummaryItem(
|
||||
title: 'Diskon',
|
||||
value: state.order.discountAmount.currencyFormatRpV2,
|
||||
),
|
||||
SpaceHeight(8),
|
||||
DashedDivider(color: AppColor.border),
|
||||
SpaceHeight(8),
|
||||
_buildSummaryItem(
|
||||
title: 'Total Dibayar',
|
||||
value: state.order.totalAmount.currencyFormatRpV2,
|
||||
isTotal: true,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildInfoRow({
|
||||
required IconData icon,
|
||||
required String label,
|
||||
required String value,
|
||||
Color? valueColor,
|
||||
bool showBadge = false,
|
||||
}) {
|
||||
return Row(
|
||||
children: [
|
||||
Icon(icon, size: 18, color: AppColor.primary),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Text(
|
||||
label,
|
||||
style: AppStyle.md.copyWith(color: AppColor.textPrimary),
|
||||
),
|
||||
),
|
||||
if (showBadge && valueColor != null)
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
color: valueColor.withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(Icons.check_circle, size: 14, color: valueColor),
|
||||
const SizedBox(width: 4),
|
||||
Text(
|
||||
value,
|
||||
style: AppStyle.sm.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: valueColor,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
else
|
||||
Text(
|
||||
value,
|
||||
style: AppStyle.md.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: valueColor ?? AppColor.primary,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Row _buildSummaryItem({
|
||||
required String title,
|
||||
required String value,
|
||||
bool isTotal = false,
|
||||
}) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
title,
|
||||
style: AppStyle.md.copyWith(
|
||||
fontSize: isTotal ? 16 : 14,
|
||||
color: isTotal ? AppColor.primary : AppColor.textSecondary,
|
||||
fontWeight: isTotal ? FontWeight.bold : FontWeight.w500,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
value,
|
||||
style: AppStyle.md.copyWith(
|
||||
fontSize: isTotal ? 16 : 14,
|
||||
color: isTotal ? AppColor.primary : AppColor.textSecondary,
|
||||
fontWeight: isTotal ? FontWeight.bold : FontWeight.w600,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,54 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../common/data/refund_data.dart';
|
||||
import '../../../components/spaces/space.dart';
|
||||
|
||||
class RefundReasonTile extends StatelessWidget {
|
||||
final bool isSelected;
|
||||
final RefundReason reason;
|
||||
final Function() onTap;
|
||||
const RefundReasonTile({
|
||||
super.key,
|
||||
required this.isSelected,
|
||||
required this.reason,
|
||||
required this.onTap,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap: onTap,
|
||||
child: AnimatedContainer(
|
||||
duration: Duration(milliseconds: 300),
|
||||
decoration: BoxDecoration(
|
||||
color: isSelected ? reason.color.withOpacity(0.2) : Colors.grey[100],
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(
|
||||
color: isSelected ? reason.color : Colors.transparent,
|
||||
width: 2,
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(
|
||||
reason.icon,
|
||||
color: isSelected ? reason.color : Colors.grey[600],
|
||||
size: 20,
|
||||
),
|
||||
SpaceHeight(4),
|
||||
Text(
|
||||
reason.value,
|
||||
style: TextStyle(
|
||||
fontSize: 10,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: isSelected ? reason.color : Colors.grey[600],
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
182
lib/presentation/pages/refund/widgets/refund_right_panel.dart
Normal file
182
lib/presentation/pages/refund/widgets/refund_right_panel.dart
Normal file
@ -0,0 +1,182 @@
|
||||
import 'package:auto_route/auto_route.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
import '../../../../application/refund/refund_form/refund_form_bloc.dart';
|
||||
import '../../../../common/data/refund_data.dart';
|
||||
import '../../../../common/extension/extension.dart';
|
||||
import '../../../../common/theme/theme.dart';
|
||||
import '../../../components/border/dashed_border.dart';
|
||||
import '../../../components/button/button.dart';
|
||||
import '../../../components/field/field.dart';
|
||||
import '../../../components/spaces/space.dart';
|
||||
import '../../../components/toast/flushbar.dart';
|
||||
import 'refund_reasong_tile.dart';
|
||||
|
||||
class RefundRightPanel extends StatefulWidget {
|
||||
final RefundFormState state;
|
||||
const RefundRightPanel({super.key, required this.state});
|
||||
|
||||
@override
|
||||
State<RefundRightPanel> createState() => _RefundRightPanelState();
|
||||
}
|
||||
|
||||
class _RefundRightPanelState extends State<RefundRightPanel> {
|
||||
TextEditingController reasonController = TextEditingController();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
reasonController.addListener(() {
|
||||
context.read<RefundFormBloc>().add(
|
||||
RefundFormEvent.reasonChanged(reasonController.text),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: SingleChildScrollView(
|
||||
padding: EdgeInsets.all(16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'Konfigurasi Refund',
|
||||
style: AppStyle.h5.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: AppColor.textPrimary,
|
||||
),
|
||||
),
|
||||
SpaceHeight(16),
|
||||
Container(
|
||||
width: context.deviceWidth,
|
||||
padding: EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.white,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'Pilih Alasan Refund',
|
||||
style: AppStyle.lg.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
color: AppColor.primary,
|
||||
),
|
||||
),
|
||||
SpaceHeight(8),
|
||||
GridView.builder(
|
||||
shrinkWrap: true,
|
||||
physics: NeverScrollableScrollPhysics(),
|
||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 3,
|
||||
crossAxisSpacing: 12,
|
||||
mainAxisSpacing: 12,
|
||||
childAspectRatio: 2.5,
|
||||
),
|
||||
itemCount: refundReasons.length,
|
||||
itemBuilder: (context, index) {
|
||||
final reason = refundReasons[index];
|
||||
final isSelected =
|
||||
widget.state.refundReason == reason;
|
||||
|
||||
return RefundReasonTile(
|
||||
isSelected: isSelected,
|
||||
reason: reason,
|
||||
onTap: () {
|
||||
context.read<RefundFormBloc>().add(
|
||||
RefundFormEvent.refundReasonChanged(reason),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
if (widget.state.refundReason != null &&
|
||||
widget.state.refundReason!.value == 'Lainnya') ...[
|
||||
SpaceHeight(8),
|
||||
AppTextFormField(
|
||||
label: 'Masukkan Alasan',
|
||||
controller: reasonController,
|
||||
showLabel: false,
|
||||
maxLines: 3,
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
_buildBottom(),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildBottom() {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(color: AppColor.white),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'Total Refund',
|
||||
style: AppStyle.lg.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
color: AppColor.primary,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
widget.state.order.totalAmount.currencyFormatRpV2,
|
||||
style: AppStyle.lg.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
color: AppColor.primary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SpaceHeight(8),
|
||||
DashedDivider(color: AppColor.border),
|
||||
SpaceHeight(16),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: AppElevatedButton.outlined(
|
||||
onPressed: () => context.router.maybePop(),
|
||||
label: 'Batal',
|
||||
),
|
||||
),
|
||||
SpaceWidth(16),
|
||||
Expanded(
|
||||
child: AppElevatedButton.filled(
|
||||
onPressed: () {
|
||||
if (widget.state.refundReason == null) {
|
||||
AppFlushbar.showError(context, 'Pilih alasan refund');
|
||||
|
||||
return;
|
||||
}
|
||||
context.read<RefundFormBloc>().add(
|
||||
const RefundFormEvent.submitted(),
|
||||
);
|
||||
},
|
||||
isLoading: widget.state.isSubmitting,
|
||||
label: 'Konfirmasi Refund',
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -45,5 +45,9 @@ class AppRouter extends RootStackRouter {
|
||||
|
||||
// Split Bill
|
||||
AutoRoute(page: SplitBillRoute.page),
|
||||
|
||||
// Refund
|
||||
AutoRoute(page: RefundRoute.page),
|
||||
AutoRoute(page: RefundSuccessRoute.page),
|
||||
];
|
||||
}
|
||||
|
||||
@ -9,8 +9,8 @@
|
||||
// coverage:ignore-file
|
||||
|
||||
// ignore_for_file: no_leading_underscores_for_library_prefixes
|
||||
import 'package:apskel_pos_flutter_v2/common/types/split_type.dart' as _i23;
|
||||
import 'package:apskel_pos_flutter_v2/domain/order/order.dart' as _i22;
|
||||
import 'package:apskel_pos_flutter_v2/common/types/split_type.dart' as _i25;
|
||||
import 'package:apskel_pos_flutter_v2/domain/order/order.dart' as _i24;
|
||||
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'
|
||||
@ -22,109 +22,113 @@ import 'package:apskel_pos_flutter_v2/presentation/pages/main/pages/customer/cus
|
||||
import 'package:apskel_pos_flutter_v2/presentation/pages/main/pages/home/home_page.dart'
|
||||
as _i3;
|
||||
import 'package:apskel_pos_flutter_v2/presentation/pages/main/pages/report/report_page.dart'
|
||||
as _i10;
|
||||
as _i12;
|
||||
import 'package:apskel_pos_flutter_v2/presentation/pages/main/pages/setting/setting_page.dart'
|
||||
as _i11;
|
||||
as _i13;
|
||||
import 'package:apskel_pos_flutter_v2/presentation/pages/main/pages/table/table_page.dart'
|
||||
as _i17;
|
||||
as _i19;
|
||||
import 'package:apskel_pos_flutter_v2/presentation/pages/order/order_page.dart'
|
||||
as _i6;
|
||||
import 'package:apskel_pos_flutter_v2/presentation/pages/order/pages/success_add_item_order/success_add_item_order_page.dart'
|
||||
as _i14;
|
||||
as _i16;
|
||||
import 'package:apskel_pos_flutter_v2/presentation/pages/order/pages/success_order/success_order_page.dart'
|
||||
as _i15;
|
||||
as _i17;
|
||||
import 'package:apskel_pos_flutter_v2/presentation/pages/payment/pages/payment_success/payment_success_page.dart'
|
||||
as _i8;
|
||||
import 'package:apskel_pos_flutter_v2/presentation/pages/payment/pages/payment_success_split_bill/payment_success_split_bill_page.dart'
|
||||
as _i9;
|
||||
import 'package:apskel_pos_flutter_v2/presentation/pages/payment/payment_page.dart'
|
||||
as _i7;
|
||||
import 'package:apskel_pos_flutter_v2/presentation/pages/refund/pages/refund_success/refund_success_page.dart'
|
||||
as _i11;
|
||||
import 'package:apskel_pos_flutter_v2/presentation/pages/refund/refund_page.dart'
|
||||
as _i10;
|
||||
import 'package:apskel_pos_flutter_v2/presentation/pages/splash/splash_page.dart'
|
||||
as _i12;
|
||||
as _i14;
|
||||
import 'package:apskel_pos_flutter_v2/presentation/pages/split_bill/split_bill_page.dart'
|
||||
as _i13;
|
||||
as _i15;
|
||||
import 'package:apskel_pos_flutter_v2/presentation/pages/sync/sync_page.dart'
|
||||
as _i16;
|
||||
import 'package:apskel_pos_flutter_v2/presentation/pages/void/pages/void_success/void_success_page.dart'
|
||||
as _i19;
|
||||
import 'package:apskel_pos_flutter_v2/presentation/pages/void/void_page.dart'
|
||||
as _i18;
|
||||
import 'package:auto_route/auto_route.dart' as _i20;
|
||||
import 'package:flutter/material.dart' as _i21;
|
||||
import 'package:apskel_pos_flutter_v2/presentation/pages/void/pages/void_success/void_success_page.dart'
|
||||
as _i21;
|
||||
import 'package:apskel_pos_flutter_v2/presentation/pages/void/void_page.dart'
|
||||
as _i20;
|
||||
import 'package:auto_route/auto_route.dart' as _i22;
|
||||
import 'package:flutter/material.dart' as _i23;
|
||||
|
||||
/// generated route for
|
||||
/// [_i1.CheckoutPage]
|
||||
class CheckoutRoute extends _i20.PageRouteInfo<void> {
|
||||
const CheckoutRoute({List<_i20.PageRouteInfo>? children})
|
||||
class CheckoutRoute extends _i22.PageRouteInfo<void> {
|
||||
const CheckoutRoute({List<_i22.PageRouteInfo>? children})
|
||||
: super(CheckoutRoute.name, initialChildren: children);
|
||||
|
||||
static const String name = 'CheckoutRoute';
|
||||
|
||||
static _i20.PageInfo page = _i20.PageInfo(
|
||||
static _i22.PageInfo page = _i22.PageInfo(
|
||||
name,
|
||||
builder: (data) {
|
||||
return _i20.WrappedRoute(child: const _i1.CheckoutPage());
|
||||
return _i22.WrappedRoute(child: const _i1.CheckoutPage());
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/// generated route for
|
||||
/// [_i2.CustomerPage]
|
||||
class CustomerRoute extends _i20.PageRouteInfo<void> {
|
||||
const CustomerRoute({List<_i20.PageRouteInfo>? children})
|
||||
class CustomerRoute extends _i22.PageRouteInfo<void> {
|
||||
const CustomerRoute({List<_i22.PageRouteInfo>? children})
|
||||
: super(CustomerRoute.name, initialChildren: children);
|
||||
|
||||
static const String name = 'CustomerRoute';
|
||||
|
||||
static _i20.PageInfo page = _i20.PageInfo(
|
||||
static _i22.PageInfo page = _i22.PageInfo(
|
||||
name,
|
||||
builder: (data) {
|
||||
return _i20.WrappedRoute(child: const _i2.CustomerPage());
|
||||
return _i22.WrappedRoute(child: const _i2.CustomerPage());
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/// generated route for
|
||||
/// [_i3.HomePage]
|
||||
class HomeRoute extends _i20.PageRouteInfo<void> {
|
||||
const HomeRoute({List<_i20.PageRouteInfo>? children})
|
||||
class HomeRoute extends _i22.PageRouteInfo<void> {
|
||||
const HomeRoute({List<_i22.PageRouteInfo>? children})
|
||||
: super(HomeRoute.name, initialChildren: children);
|
||||
|
||||
static const String name = 'HomeRoute';
|
||||
|
||||
static _i20.PageInfo page = _i20.PageInfo(
|
||||
static _i22.PageInfo page = _i22.PageInfo(
|
||||
name,
|
||||
builder: (data) {
|
||||
return _i20.WrappedRoute(child: const _i3.HomePage());
|
||||
return _i22.WrappedRoute(child: const _i3.HomePage());
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/// generated route for
|
||||
/// [_i4.LoginPage]
|
||||
class LoginRoute extends _i20.PageRouteInfo<void> {
|
||||
const LoginRoute({List<_i20.PageRouteInfo>? children})
|
||||
class LoginRoute extends _i22.PageRouteInfo<void> {
|
||||
const LoginRoute({List<_i22.PageRouteInfo>? children})
|
||||
: super(LoginRoute.name, initialChildren: children);
|
||||
|
||||
static const String name = 'LoginRoute';
|
||||
|
||||
static _i20.PageInfo page = _i20.PageInfo(
|
||||
static _i22.PageInfo page = _i22.PageInfo(
|
||||
name,
|
||||
builder: (data) {
|
||||
return _i20.WrappedRoute(child: const _i4.LoginPage());
|
||||
return _i22.WrappedRoute(child: const _i4.LoginPage());
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/// generated route for
|
||||
/// [_i5.MainPage]
|
||||
class MainRoute extends _i20.PageRouteInfo<void> {
|
||||
const MainRoute({List<_i20.PageRouteInfo>? children})
|
||||
class MainRoute extends _i22.PageRouteInfo<void> {
|
||||
const MainRoute({List<_i22.PageRouteInfo>? children})
|
||||
: super(MainRoute.name, initialChildren: children);
|
||||
|
||||
static const String name = 'MainRoute';
|
||||
|
||||
static _i20.PageInfo page = _i20.PageInfo(
|
||||
static _i22.PageInfo page = _i22.PageInfo(
|
||||
name,
|
||||
builder: (data) {
|
||||
return const _i5.MainPage();
|
||||
@ -134,11 +138,11 @@ class MainRoute extends _i20.PageRouteInfo<void> {
|
||||
|
||||
/// generated route for
|
||||
/// [_i6.OrderPage]
|
||||
class OrderRoute extends _i20.PageRouteInfo<OrderRouteArgs> {
|
||||
class OrderRoute extends _i22.PageRouteInfo<OrderRouteArgs> {
|
||||
OrderRoute({
|
||||
_i21.Key? key,
|
||||
_i23.Key? key,
|
||||
required String status,
|
||||
List<_i20.PageRouteInfo>? children,
|
||||
List<_i22.PageRouteInfo>? children,
|
||||
}) : super(
|
||||
OrderRoute.name,
|
||||
args: OrderRouteArgs(key: key, status: status),
|
||||
@ -147,11 +151,11 @@ class OrderRoute extends _i20.PageRouteInfo<OrderRouteArgs> {
|
||||
|
||||
static const String name = 'OrderRoute';
|
||||
|
||||
static _i20.PageInfo page = _i20.PageInfo(
|
||||
static _i22.PageInfo page = _i22.PageInfo(
|
||||
name,
|
||||
builder: (data) {
|
||||
final args = data.argsAs<OrderRouteArgs>();
|
||||
return _i20.WrappedRoute(
|
||||
return _i22.WrappedRoute(
|
||||
child: _i6.OrderPage(key: args.key, status: args.status),
|
||||
);
|
||||
},
|
||||
@ -161,7 +165,7 @@ class OrderRoute extends _i20.PageRouteInfo<OrderRouteArgs> {
|
||||
class OrderRouteArgs {
|
||||
const OrderRouteArgs({this.key, required this.status});
|
||||
|
||||
final _i21.Key? key;
|
||||
final _i23.Key? key;
|
||||
|
||||
final String status;
|
||||
|
||||
@ -173,15 +177,15 @@ class OrderRouteArgs {
|
||||
|
||||
/// generated route for
|
||||
/// [_i7.PaymentPage]
|
||||
class PaymentRoute extends _i20.PageRouteInfo<PaymentRouteArgs> {
|
||||
class PaymentRoute extends _i22.PageRouteInfo<PaymentRouteArgs> {
|
||||
PaymentRoute({
|
||||
_i21.Key? key,
|
||||
required _i22.Order order,
|
||||
_i23.Key? key,
|
||||
required _i24.Order order,
|
||||
bool isSplit = false,
|
||||
_i23.SplitType splitType = _i23.SplitType.unknown,
|
||||
_i25.SplitType splitType = _i25.SplitType.unknown,
|
||||
String? customerId,
|
||||
String? customerName,
|
||||
List<_i20.PageRouteInfo>? children,
|
||||
List<_i22.PageRouteInfo>? children,
|
||||
}) : super(
|
||||
PaymentRoute.name,
|
||||
args: PaymentRouteArgs(
|
||||
@ -197,11 +201,11 @@ class PaymentRoute extends _i20.PageRouteInfo<PaymentRouteArgs> {
|
||||
|
||||
static const String name = 'PaymentRoute';
|
||||
|
||||
static _i20.PageInfo page = _i20.PageInfo(
|
||||
static _i22.PageInfo page = _i22.PageInfo(
|
||||
name,
|
||||
builder: (data) {
|
||||
final args = data.argsAs<PaymentRouteArgs>();
|
||||
return _i20.WrappedRoute(
|
||||
return _i22.WrappedRoute(
|
||||
child: _i7.PaymentPage(
|
||||
key: args.key,
|
||||
order: args.order,
|
||||
@ -220,18 +224,18 @@ class PaymentRouteArgs {
|
||||
this.key,
|
||||
required this.order,
|
||||
this.isSplit = false,
|
||||
this.splitType = _i23.SplitType.unknown,
|
||||
this.splitType = _i25.SplitType.unknown,
|
||||
this.customerId,
|
||||
this.customerName,
|
||||
});
|
||||
|
||||
final _i21.Key? key;
|
||||
final _i23.Key? key;
|
||||
|
||||
final _i22.Order order;
|
||||
final _i24.Order order;
|
||||
|
||||
final bool isSplit;
|
||||
|
||||
final _i23.SplitType splitType;
|
||||
final _i25.SplitType splitType;
|
||||
|
||||
final String? customerId;
|
||||
|
||||
@ -245,11 +249,11 @@ class PaymentRouteArgs {
|
||||
|
||||
/// generated route for
|
||||
/// [_i8.PaymentSuccessPage]
|
||||
class PaymentSuccessRoute extends _i20.PageRouteInfo<PaymentSuccessRouteArgs> {
|
||||
class PaymentSuccessRoute extends _i22.PageRouteInfo<PaymentSuccessRouteArgs> {
|
||||
PaymentSuccessRoute({
|
||||
_i21.Key? key,
|
||||
_i23.Key? key,
|
||||
required String orderId,
|
||||
List<_i20.PageRouteInfo>? children,
|
||||
List<_i22.PageRouteInfo>? children,
|
||||
}) : super(
|
||||
PaymentSuccessRoute.name,
|
||||
args: PaymentSuccessRouteArgs(key: key, orderId: orderId),
|
||||
@ -258,11 +262,11 @@ class PaymentSuccessRoute extends _i20.PageRouteInfo<PaymentSuccessRouteArgs> {
|
||||
|
||||
static const String name = 'PaymentSuccessRoute';
|
||||
|
||||
static _i20.PageInfo page = _i20.PageInfo(
|
||||
static _i22.PageInfo page = _i22.PageInfo(
|
||||
name,
|
||||
builder: (data) {
|
||||
final args = data.argsAs<PaymentSuccessRouteArgs>();
|
||||
return _i20.WrappedRoute(
|
||||
return _i22.WrappedRoute(
|
||||
child: _i8.PaymentSuccessPage(key: args.key, orderId: args.orderId),
|
||||
);
|
||||
},
|
||||
@ -272,7 +276,7 @@ class PaymentSuccessRoute extends _i20.PageRouteInfo<PaymentSuccessRouteArgs> {
|
||||
class PaymentSuccessRouteArgs {
|
||||
const PaymentSuccessRouteArgs({this.key, required this.orderId});
|
||||
|
||||
final _i21.Key? key;
|
||||
final _i23.Key? key;
|
||||
|
||||
final String orderId;
|
||||
|
||||
@ -285,11 +289,11 @@ class PaymentSuccessRouteArgs {
|
||||
/// generated route for
|
||||
/// [_i9.PaymentSuccessSplitBillPage]
|
||||
class PaymentSuccessSplitBillRoute
|
||||
extends _i20.PageRouteInfo<PaymentSuccessSplitBillRouteArgs> {
|
||||
extends _i22.PageRouteInfo<PaymentSuccessSplitBillRouteArgs> {
|
||||
PaymentSuccessSplitBillRoute({
|
||||
_i21.Key? key,
|
||||
_i23.Key? key,
|
||||
required String orderId,
|
||||
List<_i20.PageRouteInfo>? children,
|
||||
List<_i22.PageRouteInfo>? children,
|
||||
}) : super(
|
||||
PaymentSuccessSplitBillRoute.name,
|
||||
args: PaymentSuccessSplitBillRouteArgs(key: key, orderId: orderId),
|
||||
@ -298,11 +302,11 @@ class PaymentSuccessSplitBillRoute
|
||||
|
||||
static const String name = 'PaymentSuccessSplitBillRoute';
|
||||
|
||||
static _i20.PageInfo page = _i20.PageInfo(
|
||||
static _i22.PageInfo page = _i22.PageInfo(
|
||||
name,
|
||||
builder: (data) {
|
||||
final args = data.argsAs<PaymentSuccessSplitBillRouteArgs>();
|
||||
return _i20.WrappedRoute(
|
||||
return _i22.WrappedRoute(
|
||||
child: _i9.PaymentSuccessSplitBillPage(
|
||||
key: args.key,
|
||||
orderId: args.orderId,
|
||||
@ -315,7 +319,7 @@ class PaymentSuccessSplitBillRoute
|
||||
class PaymentSuccessSplitBillRouteArgs {
|
||||
const PaymentSuccessSplitBillRouteArgs({this.key, required this.orderId});
|
||||
|
||||
final _i21.Key? key;
|
||||
final _i23.Key? key;
|
||||
|
||||
final String orderId;
|
||||
|
||||
@ -326,60 +330,138 @@ class PaymentSuccessSplitBillRouteArgs {
|
||||
}
|
||||
|
||||
/// generated route for
|
||||
/// [_i10.ReportPage]
|
||||
class ReportRoute extends _i20.PageRouteInfo<void> {
|
||||
const ReportRoute({List<_i20.PageRouteInfo>? children})
|
||||
/// [_i10.RefundPage]
|
||||
class RefundRoute extends _i22.PageRouteInfo<RefundRouteArgs> {
|
||||
RefundRoute({
|
||||
_i23.Key? key,
|
||||
required _i24.Order order,
|
||||
List<_i22.PageRouteInfo>? children,
|
||||
}) : super(
|
||||
RefundRoute.name,
|
||||
args: RefundRouteArgs(key: key, order: order),
|
||||
initialChildren: children,
|
||||
);
|
||||
|
||||
static const String name = 'RefundRoute';
|
||||
|
||||
static _i22.PageInfo page = _i22.PageInfo(
|
||||
name,
|
||||
builder: (data) {
|
||||
final args = data.argsAs<RefundRouteArgs>();
|
||||
return _i22.WrappedRoute(
|
||||
child: _i10.RefundPage(key: args.key, order: args.order),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
class RefundRouteArgs {
|
||||
const RefundRouteArgs({this.key, required this.order});
|
||||
|
||||
final _i23.Key? key;
|
||||
|
||||
final _i24.Order order;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'RefundRouteArgs{key: $key, order: $order}';
|
||||
}
|
||||
}
|
||||
|
||||
/// generated route for
|
||||
/// [_i11.RefundSuccessPage]
|
||||
class RefundSuccessRoute extends _i22.PageRouteInfo<RefundSuccessRouteArgs> {
|
||||
RefundSuccessRoute({
|
||||
_i23.Key? key,
|
||||
required String orderId,
|
||||
List<_i22.PageRouteInfo>? children,
|
||||
}) : super(
|
||||
RefundSuccessRoute.name,
|
||||
args: RefundSuccessRouteArgs(key: key, orderId: orderId),
|
||||
initialChildren: children,
|
||||
);
|
||||
|
||||
static const String name = 'RefundSuccessRoute';
|
||||
|
||||
static _i22.PageInfo page = _i22.PageInfo(
|
||||
name,
|
||||
builder: (data) {
|
||||
final args = data.argsAs<RefundSuccessRouteArgs>();
|
||||
return _i22.WrappedRoute(
|
||||
child: _i11.RefundSuccessPage(key: args.key, orderId: args.orderId),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
class RefundSuccessRouteArgs {
|
||||
const RefundSuccessRouteArgs({this.key, required this.orderId});
|
||||
|
||||
final _i23.Key? key;
|
||||
|
||||
final String orderId;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'RefundSuccessRouteArgs{key: $key, orderId: $orderId}';
|
||||
}
|
||||
}
|
||||
|
||||
/// generated route for
|
||||
/// [_i12.ReportPage]
|
||||
class ReportRoute extends _i22.PageRouteInfo<void> {
|
||||
const ReportRoute({List<_i22.PageRouteInfo>? children})
|
||||
: super(ReportRoute.name, initialChildren: children);
|
||||
|
||||
static const String name = 'ReportRoute';
|
||||
|
||||
static _i20.PageInfo page = _i20.PageInfo(
|
||||
static _i22.PageInfo page = _i22.PageInfo(
|
||||
name,
|
||||
builder: (data) {
|
||||
return _i20.WrappedRoute(child: const _i10.ReportPage());
|
||||
return _i22.WrappedRoute(child: const _i12.ReportPage());
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/// generated route for
|
||||
/// [_i11.SettingPage]
|
||||
class SettingRoute extends _i20.PageRouteInfo<void> {
|
||||
const SettingRoute({List<_i20.PageRouteInfo>? children})
|
||||
/// [_i13.SettingPage]
|
||||
class SettingRoute extends _i22.PageRouteInfo<void> {
|
||||
const SettingRoute({List<_i22.PageRouteInfo>? children})
|
||||
: super(SettingRoute.name, initialChildren: children);
|
||||
|
||||
static const String name = 'SettingRoute';
|
||||
|
||||
static _i20.PageInfo page = _i20.PageInfo(
|
||||
static _i22.PageInfo page = _i22.PageInfo(
|
||||
name,
|
||||
builder: (data) {
|
||||
return const _i11.SettingPage();
|
||||
return const _i13.SettingPage();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/// generated route for
|
||||
/// [_i12.SplashPage]
|
||||
class SplashRoute extends _i20.PageRouteInfo<void> {
|
||||
const SplashRoute({List<_i20.PageRouteInfo>? children})
|
||||
/// [_i14.SplashPage]
|
||||
class SplashRoute extends _i22.PageRouteInfo<void> {
|
||||
const SplashRoute({List<_i22.PageRouteInfo>? children})
|
||||
: super(SplashRoute.name, initialChildren: children);
|
||||
|
||||
static const String name = 'SplashRoute';
|
||||
|
||||
static _i20.PageInfo page = _i20.PageInfo(
|
||||
static _i22.PageInfo page = _i22.PageInfo(
|
||||
name,
|
||||
builder: (data) {
|
||||
return const _i12.SplashPage();
|
||||
return const _i14.SplashPage();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/// generated route for
|
||||
/// [_i13.SplitBillPage]
|
||||
class SplitBillRoute extends _i20.PageRouteInfo<SplitBillRouteArgs> {
|
||||
/// [_i15.SplitBillPage]
|
||||
class SplitBillRoute extends _i22.PageRouteInfo<SplitBillRouteArgs> {
|
||||
SplitBillRoute({
|
||||
_i21.Key? key,
|
||||
required _i22.Order order,
|
||||
List<_i20.PageRouteInfo>? children,
|
||||
_i23.Key? key,
|
||||
required _i24.Order order,
|
||||
List<_i22.PageRouteInfo>? children,
|
||||
}) : super(
|
||||
SplitBillRoute.name,
|
||||
args: SplitBillRouteArgs(key: key, order: order),
|
||||
@ -388,12 +470,12 @@ class SplitBillRoute extends _i20.PageRouteInfo<SplitBillRouteArgs> {
|
||||
|
||||
static const String name = 'SplitBillRoute';
|
||||
|
||||
static _i20.PageInfo page = _i20.PageInfo(
|
||||
static _i22.PageInfo page = _i22.PageInfo(
|
||||
name,
|
||||
builder: (data) {
|
||||
final args = data.argsAs<SplitBillRouteArgs>();
|
||||
return _i20.WrappedRoute(
|
||||
child: _i13.SplitBillPage(key: args.key, order: args.order),
|
||||
return _i22.WrappedRoute(
|
||||
child: _i15.SplitBillPage(key: args.key, order: args.order),
|
||||
);
|
||||
},
|
||||
);
|
||||
@ -402,9 +484,9 @@ class SplitBillRoute extends _i20.PageRouteInfo<SplitBillRouteArgs> {
|
||||
class SplitBillRouteArgs {
|
||||
const SplitBillRouteArgs({this.key, required this.order});
|
||||
|
||||
final _i21.Key? key;
|
||||
final _i23.Key? key;
|
||||
|
||||
final _i22.Order order;
|
||||
final _i24.Order order;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
@ -413,28 +495,28 @@ class SplitBillRouteArgs {
|
||||
}
|
||||
|
||||
/// generated route for
|
||||
/// [_i14.SuccessAddItemOrderPage]
|
||||
class SuccessAddItemOrderRoute extends _i20.PageRouteInfo<void> {
|
||||
const SuccessAddItemOrderRoute({List<_i20.PageRouteInfo>? children})
|
||||
/// [_i16.SuccessAddItemOrderPage]
|
||||
class SuccessAddItemOrderRoute extends _i22.PageRouteInfo<void> {
|
||||
const SuccessAddItemOrderRoute({List<_i22.PageRouteInfo>? children})
|
||||
: super(SuccessAddItemOrderRoute.name, initialChildren: children);
|
||||
|
||||
static const String name = 'SuccessAddItemOrderRoute';
|
||||
|
||||
static _i20.PageInfo page = _i20.PageInfo(
|
||||
static _i22.PageInfo page = _i22.PageInfo(
|
||||
name,
|
||||
builder: (data) {
|
||||
return const _i14.SuccessAddItemOrderPage();
|
||||
return const _i16.SuccessAddItemOrderPage();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/// generated route for
|
||||
/// [_i15.SuccessOrderPage]
|
||||
class SuccessOrderRoute extends _i20.PageRouteInfo<SuccessOrderRouteArgs> {
|
||||
/// [_i17.SuccessOrderPage]
|
||||
class SuccessOrderRoute extends _i22.PageRouteInfo<SuccessOrderRouteArgs> {
|
||||
SuccessOrderRoute({
|
||||
_i21.Key? key,
|
||||
required _i22.Order order,
|
||||
List<_i20.PageRouteInfo>? children,
|
||||
_i23.Key? key,
|
||||
required _i24.Order order,
|
||||
List<_i22.PageRouteInfo>? children,
|
||||
}) : super(
|
||||
SuccessOrderRoute.name,
|
||||
args: SuccessOrderRouteArgs(key: key, order: order),
|
||||
@ -443,12 +525,12 @@ class SuccessOrderRoute extends _i20.PageRouteInfo<SuccessOrderRouteArgs> {
|
||||
|
||||
static const String name = 'SuccessOrderRoute';
|
||||
|
||||
static _i20.PageInfo page = _i20.PageInfo(
|
||||
static _i22.PageInfo page = _i22.PageInfo(
|
||||
name,
|
||||
builder: (data) {
|
||||
final args = data.argsAs<SuccessOrderRouteArgs>();
|
||||
return _i20.WrappedRoute(
|
||||
child: _i15.SuccessOrderPage(key: args.key, order: args.order),
|
||||
return _i22.WrappedRoute(
|
||||
child: _i17.SuccessOrderPage(key: args.key, order: args.order),
|
||||
);
|
||||
},
|
||||
);
|
||||
@ -457,9 +539,9 @@ class SuccessOrderRoute extends _i20.PageRouteInfo<SuccessOrderRouteArgs> {
|
||||
class SuccessOrderRouteArgs {
|
||||
const SuccessOrderRouteArgs({this.key, required this.order});
|
||||
|
||||
final _i21.Key? key;
|
||||
final _i23.Key? key;
|
||||
|
||||
final _i22.Order order;
|
||||
final _i24.Order order;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
@ -468,44 +550,44 @@ class SuccessOrderRouteArgs {
|
||||
}
|
||||
|
||||
/// generated route for
|
||||
/// [_i16.SyncPage]
|
||||
class SyncRoute extends _i20.PageRouteInfo<void> {
|
||||
const SyncRoute({List<_i20.PageRouteInfo>? children})
|
||||
/// [_i18.SyncPage]
|
||||
class SyncRoute extends _i22.PageRouteInfo<void> {
|
||||
const SyncRoute({List<_i22.PageRouteInfo>? children})
|
||||
: super(SyncRoute.name, initialChildren: children);
|
||||
|
||||
static const String name = 'SyncRoute';
|
||||
|
||||
static _i20.PageInfo page = _i20.PageInfo(
|
||||
static _i22.PageInfo page = _i22.PageInfo(
|
||||
name,
|
||||
builder: (data) {
|
||||
return _i20.WrappedRoute(child: const _i16.SyncPage());
|
||||
return _i22.WrappedRoute(child: const _i18.SyncPage());
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/// generated route for
|
||||
/// [_i17.TablePage]
|
||||
class TableRoute extends _i20.PageRouteInfo<void> {
|
||||
const TableRoute({List<_i20.PageRouteInfo>? children})
|
||||
/// [_i19.TablePage]
|
||||
class TableRoute extends _i22.PageRouteInfo<void> {
|
||||
const TableRoute({List<_i22.PageRouteInfo>? children})
|
||||
: super(TableRoute.name, initialChildren: children);
|
||||
|
||||
static const String name = 'TableRoute';
|
||||
|
||||
static _i20.PageInfo page = _i20.PageInfo(
|
||||
static _i22.PageInfo page = _i22.PageInfo(
|
||||
name,
|
||||
builder: (data) {
|
||||
return _i20.WrappedRoute(child: const _i17.TablePage());
|
||||
return _i22.WrappedRoute(child: const _i19.TablePage());
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/// generated route for
|
||||
/// [_i18.VoidPage]
|
||||
class VoidRoute extends _i20.PageRouteInfo<VoidRouteArgs> {
|
||||
/// [_i20.VoidPage]
|
||||
class VoidRoute extends _i22.PageRouteInfo<VoidRouteArgs> {
|
||||
VoidRoute({
|
||||
_i21.Key? key,
|
||||
required _i22.Order order,
|
||||
List<_i20.PageRouteInfo>? children,
|
||||
_i23.Key? key,
|
||||
required _i24.Order order,
|
||||
List<_i22.PageRouteInfo>? children,
|
||||
}) : super(
|
||||
VoidRoute.name,
|
||||
args: VoidRouteArgs(key: key, order: order),
|
||||
@ -514,12 +596,12 @@ class VoidRoute extends _i20.PageRouteInfo<VoidRouteArgs> {
|
||||
|
||||
static const String name = 'VoidRoute';
|
||||
|
||||
static _i20.PageInfo page = _i20.PageInfo(
|
||||
static _i22.PageInfo page = _i22.PageInfo(
|
||||
name,
|
||||
builder: (data) {
|
||||
final args = data.argsAs<VoidRouteArgs>();
|
||||
return _i20.WrappedRoute(
|
||||
child: _i18.VoidPage(key: args.key, order: args.order),
|
||||
return _i22.WrappedRoute(
|
||||
child: _i20.VoidPage(key: args.key, order: args.order),
|
||||
);
|
||||
},
|
||||
);
|
||||
@ -528,9 +610,9 @@ class VoidRoute extends _i20.PageRouteInfo<VoidRouteArgs> {
|
||||
class VoidRouteArgs {
|
||||
const VoidRouteArgs({this.key, required this.order});
|
||||
|
||||
final _i21.Key? key;
|
||||
final _i23.Key? key;
|
||||
|
||||
final _i22.Order order;
|
||||
final _i24.Order order;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
@ -539,17 +621,17 @@ class VoidRouteArgs {
|
||||
}
|
||||
|
||||
/// generated route for
|
||||
/// [_i19.VoidSuccessPage]
|
||||
class VoidSuccessRoute extends _i20.PageRouteInfo<void> {
|
||||
const VoidSuccessRoute({List<_i20.PageRouteInfo>? children})
|
||||
/// [_i21.VoidSuccessPage]
|
||||
class VoidSuccessRoute extends _i22.PageRouteInfo<void> {
|
||||
const VoidSuccessRoute({List<_i22.PageRouteInfo>? children})
|
||||
: super(VoidSuccessRoute.name, initialChildren: children);
|
||||
|
||||
static const String name = 'VoidSuccessRoute';
|
||||
|
||||
static _i20.PageInfo page = _i20.PageInfo(
|
||||
static _i22.PageInfo page = _i22.PageInfo(
|
||||
name,
|
||||
builder: (data) {
|
||||
return const _i19.VoidSuccessPage();
|
||||
return const _i21.VoidSuccessPage();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user