print bill
This commit is contained in:
@@ -4,8 +4,10 @@ import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
import '../../../application/order/order_loader/order_loader_bloc.dart';
|
||||
import '../../../application/printer/print_struck/print_struck_bloc.dart';
|
||||
import '../../../common/theme/theme.dart';
|
||||
import '../../../injection.dart';
|
||||
import '../../components/toast/flushbar.dart';
|
||||
import 'widgets/order_left_panel.dart';
|
||||
import 'widgets/order_right_panel.dart';
|
||||
|
||||
@@ -36,6 +38,20 @@ class OrderPage extends StatelessWidget implements AutoRouteWrapper {
|
||||
);
|
||||
},
|
||||
),
|
||||
BlocListener<PrintStruckBloc, PrintStruckState>(
|
||||
listenWhen: (previous, current) =>
|
||||
previous.failureOrPrintStruck != current.failureOrPrintStruck,
|
||||
listener: (context, state) {
|
||||
state.failureOrPrintStruck.fold(() {}, (either) {
|
||||
either.fold(
|
||||
(f) => AppFlushbar.showPrinterFailureToast(context, f),
|
||||
(success) {
|
||||
AppFlushbar.showSuccess(context, "Struck berhasil dicetak");
|
||||
},
|
||||
);
|
||||
});
|
||||
},
|
||||
),
|
||||
],
|
||||
child: SafeArea(
|
||||
child: Scaffold(
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
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 '../../../../application/printer/print_struck/print_struck_bloc.dart';
|
||||
import '../../../../common/theme/theme.dart';
|
||||
import '../../../components/button/button.dart';
|
||||
import '../../../components/spaces/space.dart';
|
||||
@@ -59,26 +61,10 @@ class OrderRightPanel extends StatelessWidget {
|
||||
AppElevatedButton.outlined(
|
||||
onPressed: () {
|
||||
if (state.selectedOrder?.status == 'completed') {
|
||||
// onPrintRecipt(
|
||||
// context,
|
||||
// order: orderDetail!,
|
||||
// paymentMethod:
|
||||
// orderDetail!.payments
|
||||
// ?.map((p) => p.paymentMethodName)
|
||||
// .join(', ') ??
|
||||
// "",
|
||||
// nominalBayar: orderDetail?.totalPaid ?? 0,
|
||||
// kembalian: 0,
|
||||
// productQuantity: orderDetail!.orderItems!
|
||||
// .toProductQuantities(),
|
||||
// );
|
||||
} else {
|
||||
// onPrintBill(
|
||||
// context,
|
||||
// productQuantity: orderDetail!.orderItems!
|
||||
// .toProductQuantities(),
|
||||
// order: orderDetail!,
|
||||
// );
|
||||
context.read<PrintStruckBloc>().add(
|
||||
PrintStruckEvent.receipt(state.selectedOrder!),
|
||||
);
|
||||
}
|
||||
},
|
||||
label: 'Print Bill',
|
||||
|
||||
Reference in New Issue
Block a user