229 lines
8.7 KiB
Dart
229 lines
8.7 KiB
Dart
import 'package:enaklo_pos/core/components/components.dart';
|
|
import 'package:enaklo_pos/core/components/dashed_divider.dart';
|
|
import 'package:enaklo_pos/core/constants/colors.dart';
|
|
import 'package:enaklo_pos/core/extensions/build_context_ext.dart';
|
|
import 'package:enaklo_pos/core/extensions/date_time_ext.dart';
|
|
import 'package:enaklo_pos/core/extensions/string_ext.dart';
|
|
import 'package:enaklo_pos/core/function/app_function.dart';
|
|
import 'package:enaklo_pos/presentation/home/models/product_quantity.dart';
|
|
import 'package:enaklo_pos/presentation/home/pages/dashboard_page.dart';
|
|
import 'package:enaklo_pos/presentation/sales/blocs/order_loader/order_loader_bloc.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
|
|
class SuccessSaveOrderPage extends StatefulWidget {
|
|
final List<ProductQuantity> productQuantity;
|
|
final String orderId;
|
|
const SuccessSaveOrderPage({
|
|
super.key,
|
|
required this.orderId,
|
|
required this.productQuantity,
|
|
});
|
|
|
|
@override
|
|
State<SuccessSaveOrderPage> createState() => _SuccessSaveOrderPageState();
|
|
}
|
|
|
|
class _SuccessSaveOrderPageState extends State<SuccessSaveOrderPage> {
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
context
|
|
.read<OrderLoaderBloc>()
|
|
.add(OrderLoaderEvent.getById(widget.orderId));
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
backgroundColor: AppColors.background,
|
|
body: Center(
|
|
child: Container(
|
|
width: context.deviceWidth * 0.4,
|
|
height: context.deviceHeight * 0.8,
|
|
decoration: BoxDecoration(
|
|
color: AppColors.white,
|
|
borderRadius: const BorderRadius.all(Radius.circular(12.0)),
|
|
),
|
|
child: BlocBuilder<OrderLoaderBloc, OrderLoaderState>(
|
|
builder: (context, state) {
|
|
return state.maybeWhen(
|
|
orElse: () => Center(
|
|
child: CircularProgressIndicator(),
|
|
),
|
|
loading: () => Center(
|
|
child: CircularProgressIndicator(),
|
|
),
|
|
error: (message) => Center(
|
|
child: Text(message),
|
|
),
|
|
loadedDetail: (orderx) => Column(
|
|
children: [
|
|
Padding(
|
|
padding: const EdgeInsets.all(16.0),
|
|
child: Column(
|
|
children: [
|
|
Text(
|
|
'Pesanan!',
|
|
style: const TextStyle(
|
|
fontSize: 18, fontWeight: FontWeight.bold),
|
|
),
|
|
Text('Pesanan Berhasil disimpan',
|
|
style: const TextStyle(fontSize: 14)),
|
|
],
|
|
),
|
|
),
|
|
DashedDivider(
|
|
color: AppColors.grey,
|
|
),
|
|
SpaceHeight(24),
|
|
Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
|
child: Text(
|
|
orderx.metadata?['customer_name'] ?? "-",
|
|
style: const TextStyle(
|
|
fontSize: 24,
|
|
fontWeight: FontWeight.bold,
|
|
color: AppColors.primary,
|
|
),
|
|
textAlign: TextAlign.center,
|
|
maxLines: 2,
|
|
overflow: TextOverflow.ellipsis,
|
|
),
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.all(16.0).copyWith(top: 24),
|
|
child: Column(
|
|
children: [
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Text(
|
|
'No. Pesanan',
|
|
),
|
|
Text(
|
|
orderx.orderNumber ?? "-",
|
|
style: const TextStyle(
|
|
fontWeight: FontWeight.bold),
|
|
),
|
|
],
|
|
),
|
|
SpaceHeight(4),
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Text(
|
|
'No. Meja',
|
|
),
|
|
Text(
|
|
orderx.tableNumber ?? "-",
|
|
style: const TextStyle(
|
|
fontWeight: FontWeight.bold),
|
|
),
|
|
],
|
|
),
|
|
SpaceHeight(4),
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Text(
|
|
'Waktu',
|
|
),
|
|
Text(
|
|
(orderx.createdAt ?? DateTime.now())
|
|
.toFormattedDate3(),
|
|
style: const TextStyle(
|
|
fontWeight: FontWeight.bold),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
Spacer(),
|
|
DashedDivider(
|
|
color: AppColors.grey,
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.all(16.0),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Text(
|
|
'Status Pembayaran',
|
|
),
|
|
Text(
|
|
'Belum Bayar',
|
|
style: const TextStyle(
|
|
fontWeight: FontWeight.bold, color: Colors.red),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
DashedDivider(
|
|
color: AppColors.grey,
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.all(16.0),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Text(
|
|
'Total Pembayaran',
|
|
),
|
|
Text(
|
|
(orderx.totalAmount ?? 0)
|
|
.toString()
|
|
.currencyFormatRpV2,
|
|
style: const TextStyle(fontWeight: FontWeight.bold),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
DashedDivider(
|
|
color: AppColors.grey,
|
|
),
|
|
Spacer(),
|
|
Padding(
|
|
padding: const EdgeInsets.all(16.0),
|
|
child: Row(
|
|
children: [
|
|
Expanded(
|
|
child: Button.outlined(
|
|
onPressed: () => context.push(DashboardPage()),
|
|
label: 'Kembali',
|
|
height: 44,
|
|
),
|
|
),
|
|
SpaceWidth(12),
|
|
Expanded(
|
|
child: Button.filled(
|
|
onPressed: () async {
|
|
onPrint(
|
|
context,
|
|
productQuantity: widget.productQuantity,
|
|
order: orderx,
|
|
);
|
|
},
|
|
label: 'Cetak',
|
|
icon: Icon(
|
|
Icons.print,
|
|
color: AppColors.white,
|
|
),
|
|
height: 44,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
},
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|