feat: save order

This commit is contained in:
efrilm
2025-08-03 12:26:47 +07:00
parent e1825fe86f
commit 87a62a287a
13 changed files with 1340 additions and 117 deletions
@@ -2,7 +2,10 @@
import 'dart:developer';
import 'package:enaklo_pos/core/components/dashed_divider.dart';
import 'package:enaklo_pos/core/extensions/build_context_ext.dart';
import 'package:enaklo_pos/presentation/home/dialog/save_dialog.dart';
import 'package:enaklo_pos/presentation/home/models/order_type.dart';
import 'package:enaklo_pos/presentation/home/models/product_quantity.dart';
import 'package:enaklo_pos/presentation/home/widgets/confirm_payment_title.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
@@ -116,6 +119,7 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ConfirmPaymentTitle(
isBack: false,
title: 'Konfirmasi',
subtitle: widget.isTable
? 'Orders Table ${widget.table?.tableName}'
@@ -769,48 +773,51 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
const SpaceHeight(20.0),
BlocBuilder<CheckoutBloc, CheckoutState>(
builder: (context, state) {
return Row(
children: [
Button.outlined(
width: 150.0,
onPressed: () {
totalPriceController.text =
uangPas
.toString()
.currencyFormatRpV2;
priceValue = uangPas;
},
label: 'UANG PAS',
),
const SpaceWidth(20.0),
Button.outlined(
width: 150.0,
onPressed: () {
totalPriceController.text =
uangPas2
.toString()
.currencyFormatRpV2;
priceValue = uangPas2;
},
label: uangPas2
.toString()
.currencyFormatRpV2,
),
const SpaceWidth(20.0),
Button.outlined(
width: 150.0,
onPressed: () {
totalPriceController.text =
uangPas3
.toString()
.currencyFormatRpV2;
priceValue = uangPas3;
},
label: uangPas3
.toString()
.currencyFormatRpV2,
),
],
return SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Row(
children: [
Button.outlined(
width: 150.0,
onPressed: () {
totalPriceController.text =
uangPas
.toString()
.currencyFormatRpV2;
priceValue = uangPas;
},
label: 'UANG PAS',
),
const SpaceWidth(20.0),
Button.outlined(
width: 150.0,
onPressed: () {
totalPriceController.text =
uangPas2
.toString()
.currencyFormatRpV2;
priceValue = uangPas2;
},
label: uangPas2
.toString()
.currencyFormatRpV2,
),
const SpaceWidth(20.0),
Button.outlined(
width: 150.0,
onPressed: () {
totalPriceController.text =
uangPas3
.toString()
.currencyFormatRpV2;
priceValue = uangPas3;
},
label: uangPas3
.toString()
.currencyFormatRpV2,
),
],
),
);
},
),
@@ -821,43 +828,83 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
),
),
),
Container(
padding: EdgeInsets.all(16),
decoration: BoxDecoration(
color: AppColors.white,
border: Border(
top: BorderSide(
color: AppColors.background,
width: 1.0,
),
),
),
child: Row(
children: [
Expanded(
child: Button.outlined(
onPressed: () {},
label: 'Batalkan',
BlocBuilder<CheckoutBloc, CheckoutState>(
builder: (context, state) {
final orderType = state.maybeWhen(
orElse: () => OrderType.dineIn,
loaded: (products,
discountModel,
discount,
discountAmount,
tax,
serviceCharge,
totalQuantity,
totalPrice,
draftName,
orderType) =>
orderType,
);
List<ProductQuantity> items = state.maybeWhen(
orElse: () => [],
loaded: (products,
discountModel,
discount,
discountAmount,
tax,
serviceCharge,
totalQuantity,
totalPrice,
draftName,
orderType) =>
products,
);
return Container(
padding: EdgeInsets.all(16),
decoration: BoxDecoration(
color: AppColors.white,
border: Border(
top: BorderSide(
color: AppColors.background,
width: 1.0,
),
),
),
SpaceWidth(12),
Expanded(
child: Button.filled(
onPressed: () => showDialog(
context: context,
builder: (context) => SaveDialog()),
label: 'Simpan',
),
child: Row(
children: [
Expanded(
child: Button.outlined(
onPressed: () => context.pop(),
label: 'Batalkan',
),
),
SpaceWidth(12),
Expanded(
child: Button.filled(
onPressed: () => showDialog(
context: context,
builder: (context) => SaveDialog(
selectedTable: widget.table,
customerName:
customerController.text,
items: items,
orderType: orderType,
)),
label: 'Simpan',
),
),
SpaceWidth(12),
Expanded(
child: Button.filled(
onPressed: () {},
label: 'Bayar',
),
),
],
),
SpaceWidth(12),
Expanded(
child: Button.filled(
onPressed: () {},
label: 'Bayar',
),
),
],
),
);
},
),
],
),
+2 -1
View File
@@ -490,7 +490,8 @@ class _HomePageState extends State<HomePage> {
elevation: 1,
onPressed: () {
context.push(ConfirmPaymentPage(
isTable: widget.isTable,
isTable:
widget.table == null ? false : true,
table: widget.table,
));
},