Compare commits
No commits in common. "ae4f7b06cedb24d7d9e24afdf379dfe1bbe87dd4" and "092e68615cc1142cc7eb9d2031ea8f536dd37547" have entirely different histories.
ae4f7b06ce
...
092e68615c
@ -535,12 +535,12 @@ class OrderRemoteDatasource {
|
||||
}
|
||||
|
||||
Future<Either<String, bool>> refundPayment({
|
||||
required String orderId,
|
||||
required String paymentId,
|
||||
required String reason,
|
||||
required int refundAmount,
|
||||
}) async {
|
||||
final authData = await AuthLocalDataSource().getAuthData();
|
||||
final url = '${Variables.baseUrl}/api/v1/orders/$orderId/refund';
|
||||
final url = '${Variables.baseUrl}/api/v1/payments/$paymentId/refund';
|
||||
|
||||
try {
|
||||
final response = await dio.post(
|
||||
@ -564,7 +564,7 @@ class OrderRemoteDatasource {
|
||||
return const Left('Gagal refund');
|
||||
}
|
||||
} on DioException catch (e) {
|
||||
final errorMessage = 'Terjadi kesalahan coba lagi nanti';
|
||||
final errorMessage = e.response?.data['message'] ?? 'Kesalahan jaringan';
|
||||
log("💥 Dio error: ${e.message}");
|
||||
log("💥 Dio response: ${e.response?.data}");
|
||||
return Left(errorMessage);
|
||||
|
||||
@ -34,10 +34,10 @@ class _TypeDialogState extends State<TypeDialog> {
|
||||
'type': OrderType.delivery,
|
||||
},
|
||||
{
|
||||
'value': 'free_table',
|
||||
'label': 'Free Table',
|
||||
'icon': Icons.table_bar_outlined,
|
||||
'type': OrderType.freeTable,
|
||||
'value': 'grab',
|
||||
'label': 'Grab',
|
||||
'icon': Icons.two_wheeler,
|
||||
'type': OrderType.grab,
|
||||
},
|
||||
];
|
||||
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
enum OrderType {
|
||||
dineIn('DINE IN'),
|
||||
takeAway('TAKE AWAY'),
|
||||
delivery('DELIVERY'),
|
||||
freeTable('FREE TABLE');
|
||||
grab('GRAB'),
|
||||
delivery('DELIVERY');
|
||||
|
||||
final String value;
|
||||
const OrderType(this.value);
|
||||
|
||||
@ -876,16 +876,7 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
|
||||
SpaceWidth(12),
|
||||
Expanded(
|
||||
child: Button.filled(
|
||||
onPressed: () {
|
||||
if (customerController.text == '') {
|
||||
AppFlushbar.showError(
|
||||
context,
|
||||
'Pilih Pelanggan terlebih dahulu',
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
showDialog(
|
||||
onPressed: () => showDialog(
|
||||
context: context,
|
||||
builder: (dcontext) => SaveDialog(
|
||||
selectedTable: widget.table,
|
||||
@ -894,8 +885,7 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
|
||||
orderType: orderType,
|
||||
customer: selectedCustomer,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
label: 'Simpan',
|
||||
),
|
||||
),
|
||||
@ -924,15 +914,6 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
|
||||
child: state.maybeMap(
|
||||
orElse: () => Button.filled(
|
||||
onPressed: () {
|
||||
if (customerController.text ==
|
||||
'') {
|
||||
AppFlushbar.showError(
|
||||
context,
|
||||
'Pilih Pelanggan terlebih dahulu',
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
context.read<OrderFormBloc>().add(
|
||||
OrderFormEvent.create(
|
||||
items: items,
|
||||
|
||||
@ -6,7 +6,6 @@ import 'package:enaklo_pos/data/models/response/table_model.dart';
|
||||
import 'package:enaklo_pos/presentation/customer/pages/customer_page.dart';
|
||||
import 'package:enaklo_pos/presentation/home/bloc/checkout/checkout_bloc.dart';
|
||||
import 'package:enaklo_pos/presentation/home/dialog/type_dialog.dart';
|
||||
import 'package:enaklo_pos/presentation/home/models/order_type.dart';
|
||||
import 'package:enaklo_pos/presentation/home/pages/dashboard_page.dart';
|
||||
import 'package:enaklo_pos/presentation/sales/pages/sales_page.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@ -116,23 +115,7 @@ class HomeRightTitle extends StatelessWidget {
|
||||
},
|
||||
),
|
||||
),
|
||||
BlocBuilder<CheckoutBloc, CheckoutState>(
|
||||
builder: (context, state) {
|
||||
return state.maybeWhen(
|
||||
orElse: () => const SizedBox.shrink(),
|
||||
loaded: (items,
|
||||
discountModel,
|
||||
discount,
|
||||
discountAmount,
|
||||
tax,
|
||||
serviceCharge,
|
||||
totalQuantity,
|
||||
totalPrice,
|
||||
draftName,
|
||||
orderType) {
|
||||
switch (orderType) {
|
||||
case OrderType.dineIn:
|
||||
return Expanded(
|
||||
Expanded(
|
||||
child: Button.filled(
|
||||
width: 180.0,
|
||||
height: 40,
|
||||
@ -151,21 +134,8 @@ class HomeRightTitle extends StatelessWidget {
|
||||
},
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
label: table == null
|
||||
? 'Pilih Meja'
|
||||
: '${table!.tableName}',
|
||||
label: table == null ? 'Pilih Meja' : '${table!.tableName}',
|
||||
),
|
||||
);
|
||||
case OrderType.takeAway:
|
||||
return const SizedBox.shrink();
|
||||
case OrderType.delivery:
|
||||
return const SizedBox.shrink();
|
||||
default:
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@ -19,7 +19,7 @@ class RefundBloc extends Bloc<RefundEvent, RefundState> {
|
||||
}
|
||||
|
||||
Future<void> _onRefundPayment(
|
||||
String orderId,
|
||||
String paymentId,
|
||||
String reason,
|
||||
int refundAmount,
|
||||
Emitter<RefundState> emit,
|
||||
@ -27,7 +27,7 @@ class RefundBloc extends Bloc<RefundEvent, RefundState> {
|
||||
emit(const RefundState.loading());
|
||||
|
||||
final result = await _orderRemoteDatasource.refundPayment(
|
||||
orderId: orderId,
|
||||
paymentId: paymentId,
|
||||
reason: reason,
|
||||
refundAmount: refundAmount,
|
||||
);
|
||||
|
||||
@ -16,24 +16,24 @@ final _privateConstructorUsedError = UnsupportedError(
|
||||
|
||||
/// @nodoc
|
||||
mixin _$RefundEvent {
|
||||
String get orderId => throw _privateConstructorUsedError;
|
||||
String get paymentId => throw _privateConstructorUsedError;
|
||||
String get reason => throw _privateConstructorUsedError;
|
||||
int get refundAmount => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function(String orderId, String reason, int refundAmount)
|
||||
required TResult Function(String paymentId, String reason, int refundAmount)
|
||||
refundPayment,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function(String orderId, String reason, int refundAmount)?
|
||||
TResult? Function(String paymentId, String reason, int refundAmount)?
|
||||
refundPayment,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function(String orderId, String reason, int refundAmount)?
|
||||
TResult Function(String paymentId, String reason, int refundAmount)?
|
||||
refundPayment,
|
||||
required TResult orElse(),
|
||||
}) =>
|
||||
@ -68,7 +68,7 @@ abstract class $RefundEventCopyWith<$Res> {
|
||||
RefundEvent value, $Res Function(RefundEvent) then) =
|
||||
_$RefundEventCopyWithImpl<$Res, RefundEvent>;
|
||||
@useResult
|
||||
$Res call({String orderId, String reason, int refundAmount});
|
||||
$Res call({String paymentId, String reason, int refundAmount});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@ -86,14 +86,14 @@ class _$RefundEventCopyWithImpl<$Res, $Val extends RefundEvent>
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? orderId = null,
|
||||
Object? paymentId = null,
|
||||
Object? reason = null,
|
||||
Object? refundAmount = null,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
orderId: null == orderId
|
||||
? _value.orderId
|
||||
: orderId // ignore: cast_nullable_to_non_nullable
|
||||
paymentId: null == paymentId
|
||||
? _value.paymentId
|
||||
: paymentId // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
reason: null == reason
|
||||
? _value.reason
|
||||
@ -115,7 +115,7 @@ abstract class _$$RefundPaymentImplCopyWith<$Res>
|
||||
__$$RefundPaymentImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({String orderId, String reason, int refundAmount});
|
||||
$Res call({String paymentId, String reason, int refundAmount});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@ -131,14 +131,14 @@ class __$$RefundPaymentImplCopyWithImpl<$Res>
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? orderId = null,
|
||||
Object? paymentId = null,
|
||||
Object? reason = null,
|
||||
Object? refundAmount = null,
|
||||
}) {
|
||||
return _then(_$RefundPaymentImpl(
|
||||
orderId: null == orderId
|
||||
? _value.orderId
|
||||
: orderId // ignore: cast_nullable_to_non_nullable
|
||||
paymentId: null == paymentId
|
||||
? _value.paymentId
|
||||
: paymentId // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
reason: null == reason
|
||||
? _value.reason
|
||||
@ -156,12 +156,12 @@ class __$$RefundPaymentImplCopyWithImpl<$Res>
|
||||
|
||||
class _$RefundPaymentImpl implements _RefundPayment {
|
||||
const _$RefundPaymentImpl(
|
||||
{required this.orderId,
|
||||
{required this.paymentId,
|
||||
required this.reason,
|
||||
required this.refundAmount});
|
||||
|
||||
@override
|
||||
final String orderId;
|
||||
final String paymentId;
|
||||
@override
|
||||
final String reason;
|
||||
@override
|
||||
@ -169,7 +169,7 @@ class _$RefundPaymentImpl implements _RefundPayment {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'RefundEvent.refundPayment(orderId: $orderId, reason: $reason, refundAmount: $refundAmount)';
|
||||
return 'RefundEvent.refundPayment(paymentId: $paymentId, reason: $reason, refundAmount: $refundAmount)';
|
||||
}
|
||||
|
||||
@override
|
||||
@ -177,14 +177,15 @@ class _$RefundPaymentImpl implements _RefundPayment {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$RefundPaymentImpl &&
|
||||
(identical(other.orderId, orderId) || other.orderId == orderId) &&
|
||||
(identical(other.paymentId, paymentId) ||
|
||||
other.paymentId == paymentId) &&
|
||||
(identical(other.reason, reason) || other.reason == reason) &&
|
||||
(identical(other.refundAmount, refundAmount) ||
|
||||
other.refundAmount == refundAmount));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, orderId, reason, refundAmount);
|
||||
int get hashCode => Object.hash(runtimeType, paymentId, reason, refundAmount);
|
||||
|
||||
/// Create a copy of RefundEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@ -197,30 +198,30 @@ class _$RefundPaymentImpl implements _RefundPayment {
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function(String orderId, String reason, int refundAmount)
|
||||
required TResult Function(String paymentId, String reason, int refundAmount)
|
||||
refundPayment,
|
||||
}) {
|
||||
return refundPayment(orderId, reason, refundAmount);
|
||||
return refundPayment(paymentId, reason, refundAmount);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function(String orderId, String reason, int refundAmount)?
|
||||
TResult? Function(String paymentId, String reason, int refundAmount)?
|
||||
refundPayment,
|
||||
}) {
|
||||
return refundPayment?.call(orderId, reason, refundAmount);
|
||||
return refundPayment?.call(paymentId, reason, refundAmount);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function(String orderId, String reason, int refundAmount)?
|
||||
TResult Function(String paymentId, String reason, int refundAmount)?
|
||||
refundPayment,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (refundPayment != null) {
|
||||
return refundPayment(orderId, reason, refundAmount);
|
||||
return refundPayment(paymentId, reason, refundAmount);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
@ -256,12 +257,12 @@ class _$RefundPaymentImpl implements _RefundPayment {
|
||||
|
||||
abstract class _RefundPayment implements RefundEvent {
|
||||
const factory _RefundPayment(
|
||||
{required final String orderId,
|
||||
{required final String paymentId,
|
||||
required final String reason,
|
||||
required final int refundAmount}) = _$RefundPaymentImpl;
|
||||
|
||||
@override
|
||||
String get orderId;
|
||||
String get paymentId;
|
||||
@override
|
||||
String get reason;
|
||||
@override
|
||||
|
||||
@ -3,7 +3,7 @@ part of 'refund_bloc.dart';
|
||||
@freezed
|
||||
class RefundEvent with _$RefundEvent {
|
||||
const factory RefundEvent.refundPayment({
|
||||
required String orderId,
|
||||
required String paymentId,
|
||||
required String reason,
|
||||
required int refundAmount,
|
||||
}) = _RefundPayment;
|
||||
|
||||
@ -788,7 +788,7 @@ class _RefundPageState extends State<RefundPage> with TickerProviderStateMixin {
|
||||
// Trigger refund event
|
||||
context.read<RefundBloc>().add(
|
||||
RefundEvent.refundPayment(
|
||||
orderId: widget.selectedOrder.id ??
|
||||
paymentId: widget.selectedOrder.id ??
|
||||
'', // Assuming order ID is payment ID
|
||||
reason: reason,
|
||||
refundAmount: refundAmount,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user