This commit is contained in:
efrilm
2025-11-01 16:17:45 +07:00
parent ef23839761
commit 069c2296de
24 changed files with 2670 additions and 133 deletions
@@ -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),
),
);
},
);
}
}
@@ -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;
}
@@ -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;
}
@@ -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(),
);
}