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