Compare commits

...

4 Commits

Author SHA1 Message Date
efrilm
c09822b470 feat: success save order 2025-08-13 23:08:12 +07:00
efrilm
6a9a26f71c fix: success save order 2025-08-13 23:00:11 +07:00
efrilm
b0006ee6bc fix: order and add to order 2025-08-13 22:52:37 +07:00
efrilm
b34428965e fix: bug 2025-08-13 22:11:24 +07:00
14 changed files with 114 additions and 70 deletions

View File

@ -405,7 +405,7 @@ class OrderRemoteDatasource {
} }
} }
Future<Either<String, OrderDetailResponseModel>> addToOrder({ Future<Either<String, bool>> addToOrder({
required String orderId, required String orderId,
required List<OrderItemRequest> orderItems, required List<OrderItemRequest> orderItems,
}) async { }) async {
@ -429,8 +429,7 @@ class OrderRemoteDatasource {
); );
if (response.statusCode == 200) { if (response.statusCode == 200) {
final data = OrderDetailResponseModel.fromMap(response.data); return Right(true);
return Right(data);
} else { } else {
return const Left('Gagal menambahkan pesanan pesanan'); return const Left('Gagal menambahkan pesanan pesanan');
} }
@ -442,7 +441,7 @@ class OrderRemoteDatasource {
return Left(errorMessage); return Left(errorMessage);
} catch (e) { } catch (e) {
log("đź’Ą Unexpected error: $e"); log("đź’Ą Unexpected error: $e");
return const Left('Terjadi kesalahan tak terduga'); return const Left('Terjadi kesalahan, coba lagi nanti.');
} }
} }

View File

@ -59,12 +59,18 @@ class DashboardAnalyticData {
dateFrom: map['date_from'], dateFrom: map['date_from'],
dateTo: map['date_to'], dateTo: map['date_to'],
overview: DashboardOverview.fromMap(map['overview']), overview: DashboardOverview.fromMap(map['overview']),
topProducts: List<TopProduct>.from( topProducts: map['top_products'] == null
map['top_products']?.map((x) => TopProduct.fromMap(x))), ? []
paymentMethods: List<PaymentMethodAnalytic>.from(map['payment_methods'] : List<TopProduct>.from(
?.map((x) => PaymentMethodAnalytic.fromMap(x))), map['top_products']?.map((x) => TopProduct.fromMap(x))),
recentSales: List<RecentSale>.from( paymentMethods: map['payment_methods'] == null
map['recent_sales']?.map((x) => RecentSale.fromMap(x))), ? []
: List<PaymentMethodAnalytic>.from(map['payment_methods']
?.map((x) => PaymentMethodAnalytic.fromMap(x))),
recentSales: map['recent_sales'] == null
? []
: List<RecentSale>.from(
map['recent_sales']?.map((x) => RecentSale.fromMap(x))),
); );
Map<String, dynamic> toMap() => { Map<String, dynamic> toMap() => {

View File

@ -81,7 +81,7 @@ class OrderData {
orders: map["orders"] == null orders: map["orders"] == null
? [] ? []
: List<Order>.from(map['orders']?.map((x) => Order.fromMap(x))), : List<Order>.from(map['orders']?.map((x) => Order.fromMap(x))),
payments: map["orders"] == null payments: map["payments"] == null
? [] ? []
: List<Payment>.from(map['payments']?.map((x) => Payment.fromMap(x))), : List<Payment>.from(map['payments']?.map((x) => Payment.fromMap(x))),
totalCount: map['total_count'], totalCount: map['total_count'],

View File

@ -64,9 +64,12 @@ class PaymentMethodAnalyticData {
dateTo: DateTime.parse(map['date_to']), dateTo: DateTime.parse(map['date_to']),
groupBy: map['group_by'], groupBy: map['group_by'],
summary: PaymentSummary.fromMap(map['summary']), summary: PaymentSummary.fromMap(map['summary']),
data: List<PaymentMethodAnalyticItem>.from( data: map['data'] == null
map['data']?.map((x) => PaymentMethodAnalyticItem.fromMap(x)) ?? [], ? []
), : List<PaymentMethodAnalyticItem>.from(
map['data']?.map((x) => PaymentMethodAnalyticItem.fromMap(x)) ??
[],
),
); );
} }

View File

@ -52,9 +52,11 @@ class ProductAnalyticData {
outletId: map['outlet_id'], outletId: map['outlet_id'],
dateFrom: DateTime.parse(map['date_from']), dateFrom: DateTime.parse(map['date_from']),
dateTo: DateTime.parse(map['date_to']), dateTo: DateTime.parse(map['date_to']),
data: List<ProductAnalyticItem>.from( data: map['data'] == null
map['data'].map((x) => ProductAnalyticItem.fromMap(x)), ? []
), : List<ProductAnalyticItem>.from(
map['data'].map((x) => ProductAnalyticItem.fromMap(x)),
),
); );
Map<String, dynamic> toMap() => { Map<String, dynamic> toMap() => {

View File

@ -77,8 +77,8 @@ class OrderFormBloc extends Bloc<OrderFormEvent, OrderFormState> {
customerName: event.customerName, customerName: event.customerName,
notes: '', notes: '',
orderType: event.orderType.name, orderType: event.orderType.name,
tableId: event.table.id, tableId: event.table?.id ?? "",
tableNumber: event.table.tableName, tableNumber: event.table?.tableName ?? "",
outletId: userData.user?.outletId, outletId: userData.user?.outletId,
customerId: event.customer?.id ?? '', customerId: event.customer?.id ?? '',
orderItems: event.items orderItems: event.items
@ -131,11 +131,11 @@ class OrderFormBloc extends Bloc<OrderFormEvent, OrderFormState> {
result.fold( result.fold(
(error) => emit(_Error(error)), (error) => emit(_Error(error)),
(success) => emit(_Success(success.data!)), (success) => emit(_SuccessMsg()),
); );
} catch (e) { } catch (e) {
log("Error in AddOrderItemsBloc: $e"); log("Error in AddOrderItemsBloc: $e");
emit(_Error("Failed to add order items: $e")); emit(_Error("Ada kesalahan. Coba lagi nanti"));
} }
}, },
); );

View File

@ -27,7 +27,7 @@ mixin _$OrderFormEvent {
String customerName, String customerName,
Customer? customer, Customer? customer,
OrderType orderType, OrderType orderType,
TableModel table, TableModel? table,
PaymentMethod paymentMethod) PaymentMethod paymentMethod)
createWithPayment, createWithPayment,
required TResult Function(List<ProductQuantity> items, String orderId) required TResult Function(List<ProductQuantity> items, String orderId)
@ -53,7 +53,7 @@ mixin _$OrderFormEvent {
String customerName, String customerName,
Customer? customer, Customer? customer,
OrderType orderType, OrderType orderType,
TableModel table, TableModel? table,
PaymentMethod paymentMethod)? PaymentMethod paymentMethod)?
createWithPayment, createWithPayment,
TResult? Function(List<ProductQuantity> items, String orderId)? addToOrder, TResult? Function(List<ProductQuantity> items, String orderId)? addToOrder,
@ -76,7 +76,7 @@ mixin _$OrderFormEvent {
String customerName, String customerName,
Customer? customer, Customer? customer,
OrderType orderType, OrderType orderType,
TableModel table, TableModel? table,
PaymentMethod paymentMethod)? PaymentMethod paymentMethod)?
createWithPayment, createWithPayment,
TResult Function(List<ProductQuantity> items, String orderId)? addToOrder, TResult Function(List<ProductQuantity> items, String orderId)? addToOrder,
@ -226,7 +226,7 @@ class _$StartedImpl implements _Started {
String customerName, String customerName,
Customer? customer, Customer? customer,
OrderType orderType, OrderType orderType,
TableModel table, TableModel? table,
PaymentMethod paymentMethod) PaymentMethod paymentMethod)
createWithPayment, createWithPayment,
required TResult Function(List<ProductQuantity> items, String orderId) required TResult Function(List<ProductQuantity> items, String orderId)
@ -255,7 +255,7 @@ class _$StartedImpl implements _Started {
String customerName, String customerName,
Customer? customer, Customer? customer,
OrderType orderType, OrderType orderType,
TableModel table, TableModel? table,
PaymentMethod paymentMethod)? PaymentMethod paymentMethod)?
createWithPayment, createWithPayment,
TResult? Function(List<ProductQuantity> items, String orderId)? addToOrder, TResult? Function(List<ProductQuantity> items, String orderId)? addToOrder,
@ -281,7 +281,7 @@ class _$StartedImpl implements _Started {
String customerName, String customerName,
Customer? customer, Customer? customer,
OrderType orderType, OrderType orderType,
TableModel table, TableModel? table,
PaymentMethod paymentMethod)? PaymentMethod paymentMethod)?
createWithPayment, createWithPayment,
TResult Function(List<ProductQuantity> items, String orderId)? addToOrder, TResult Function(List<ProductQuantity> items, String orderId)? addToOrder,
@ -496,7 +496,7 @@ class _$CreateImpl implements _Create {
String customerName, String customerName,
Customer? customer, Customer? customer,
OrderType orderType, OrderType orderType,
TableModel table, TableModel? table,
PaymentMethod paymentMethod) PaymentMethod paymentMethod)
createWithPayment, createWithPayment,
required TResult Function(List<ProductQuantity> items, String orderId) required TResult Function(List<ProductQuantity> items, String orderId)
@ -525,7 +525,7 @@ class _$CreateImpl implements _Create {
String customerName, String customerName,
Customer? customer, Customer? customer,
OrderType orderType, OrderType orderType,
TableModel table, TableModel? table,
PaymentMethod paymentMethod)? PaymentMethod paymentMethod)?
createWithPayment, createWithPayment,
TResult? Function(List<ProductQuantity> items, String orderId)? addToOrder, TResult? Function(List<ProductQuantity> items, String orderId)? addToOrder,
@ -551,7 +551,7 @@ class _$CreateImpl implements _Create {
String customerName, String customerName,
Customer? customer, Customer? customer,
OrderType orderType, OrderType orderType,
TableModel table, TableModel? table,
PaymentMethod paymentMethod)? PaymentMethod paymentMethod)?
createWithPayment, createWithPayment,
TResult Function(List<ProductQuantity> items, String orderId)? addToOrder, TResult Function(List<ProductQuantity> items, String orderId)? addToOrder,
@ -652,7 +652,7 @@ abstract class _$$CreateWithPaymentMethodImplCopyWith<$Res> {
String customerName, String customerName,
Customer? customer, Customer? customer,
OrderType orderType, OrderType orderType,
TableModel table, TableModel? table,
PaymentMethod paymentMethod}); PaymentMethod paymentMethod});
} }
@ -674,7 +674,7 @@ class __$$CreateWithPaymentMethodImplCopyWithImpl<$Res>
Object? customerName = null, Object? customerName = null,
Object? customer = freezed, Object? customer = freezed,
Object? orderType = null, Object? orderType = null,
Object? table = null, Object? table = freezed,
Object? paymentMethod = null, Object? paymentMethod = null,
}) { }) {
return _then(_$CreateWithPaymentMethodImpl( return _then(_$CreateWithPaymentMethodImpl(
@ -694,10 +694,10 @@ class __$$CreateWithPaymentMethodImplCopyWithImpl<$Res>
? _value.orderType ? _value.orderType
: orderType // ignore: cast_nullable_to_non_nullable : orderType // ignore: cast_nullable_to_non_nullable
as OrderType, as OrderType,
table: null == table table: freezed == table
? _value.table ? _value.table
: table // ignore: cast_nullable_to_non_nullable : table // ignore: cast_nullable_to_non_nullable
as TableModel, as TableModel?,
paymentMethod: null == paymentMethod paymentMethod: null == paymentMethod
? _value.paymentMethod ? _value.paymentMethod
: paymentMethod // ignore: cast_nullable_to_non_nullable : paymentMethod // ignore: cast_nullable_to_non_nullable
@ -733,7 +733,7 @@ class _$CreateWithPaymentMethodImpl implements _CreateWithPaymentMethod {
@override @override
final OrderType orderType; final OrderType orderType;
@override @override
final TableModel table; final TableModel? table;
@override @override
final PaymentMethod paymentMethod; final PaymentMethod paymentMethod;
@ -790,7 +790,7 @@ class _$CreateWithPaymentMethodImpl implements _CreateWithPaymentMethod {
String customerName, String customerName,
Customer? customer, Customer? customer,
OrderType orderType, OrderType orderType,
TableModel table, TableModel? table,
PaymentMethod paymentMethod) PaymentMethod paymentMethod)
createWithPayment, createWithPayment,
required TResult Function(List<ProductQuantity> items, String orderId) required TResult Function(List<ProductQuantity> items, String orderId)
@ -820,7 +820,7 @@ class _$CreateWithPaymentMethodImpl implements _CreateWithPaymentMethod {
String customerName, String customerName,
Customer? customer, Customer? customer,
OrderType orderType, OrderType orderType,
TableModel table, TableModel? table,
PaymentMethod paymentMethod)? PaymentMethod paymentMethod)?
createWithPayment, createWithPayment,
TResult? Function(List<ProductQuantity> items, String orderId)? addToOrder, TResult? Function(List<ProductQuantity> items, String orderId)? addToOrder,
@ -847,7 +847,7 @@ class _$CreateWithPaymentMethodImpl implements _CreateWithPaymentMethod {
String customerName, String customerName,
Customer? customer, Customer? customer,
OrderType orderType, OrderType orderType,
TableModel table, TableModel? table,
PaymentMethod paymentMethod)? PaymentMethod paymentMethod)?
createWithPayment, createWithPayment,
TResult Function(List<ProductQuantity> items, String orderId)? addToOrder, TResult Function(List<ProductQuantity> items, String orderId)? addToOrder,
@ -922,7 +922,7 @@ abstract class _CreateWithPaymentMethod implements OrderFormEvent {
required final String customerName, required final String customerName,
required final Customer? customer, required final Customer? customer,
required final OrderType orderType, required final OrderType orderType,
required final TableModel table, required final TableModel? table,
required final PaymentMethod paymentMethod}) = required final PaymentMethod paymentMethod}) =
_$CreateWithPaymentMethodImpl; _$CreateWithPaymentMethodImpl;
@ -930,7 +930,7 @@ abstract class _CreateWithPaymentMethod implements OrderFormEvent {
String get customerName; String get customerName;
Customer? get customer; Customer? get customer;
OrderType get orderType; OrderType get orderType;
TableModel get table; TableModel? get table;
PaymentMethod get paymentMethod; PaymentMethod get paymentMethod;
/// Create a copy of OrderFormEvent /// Create a copy of OrderFormEvent
@ -1034,7 +1034,7 @@ class _$AddToOrderImpl implements _AddToOrder {
String customerName, String customerName,
Customer? customer, Customer? customer,
OrderType orderType, OrderType orderType,
TableModel table, TableModel? table,
PaymentMethod paymentMethod) PaymentMethod paymentMethod)
createWithPayment, createWithPayment,
required TResult Function(List<ProductQuantity> items, String orderId) required TResult Function(List<ProductQuantity> items, String orderId)
@ -1063,7 +1063,7 @@ class _$AddToOrderImpl implements _AddToOrder {
String customerName, String customerName,
Customer? customer, Customer? customer,
OrderType orderType, OrderType orderType,
TableModel table, TableModel? table,
PaymentMethod paymentMethod)? PaymentMethod paymentMethod)?
createWithPayment, createWithPayment,
TResult? Function(List<ProductQuantity> items, String orderId)? addToOrder, TResult? Function(List<ProductQuantity> items, String orderId)? addToOrder,
@ -1089,7 +1089,7 @@ class _$AddToOrderImpl implements _AddToOrder {
String customerName, String customerName,
Customer? customer, Customer? customer,
OrderType orderType, OrderType orderType,
TableModel table, TableModel? table,
PaymentMethod paymentMethod)? PaymentMethod paymentMethod)?
createWithPayment, createWithPayment,
TResult Function(List<ProductQuantity> items, String orderId)? addToOrder, TResult Function(List<ProductQuantity> items, String orderId)? addToOrder,
@ -1276,7 +1276,7 @@ class _$RefundImpl implements _Refund {
String customerName, String customerName,
Customer? customer, Customer? customer,
OrderType orderType, OrderType orderType,
TableModel table, TableModel? table,
PaymentMethod paymentMethod) PaymentMethod paymentMethod)
createWithPayment, createWithPayment,
required TResult Function(List<ProductQuantity> items, String orderId) required TResult Function(List<ProductQuantity> items, String orderId)
@ -1305,7 +1305,7 @@ class _$RefundImpl implements _Refund {
String customerName, String customerName,
Customer? customer, Customer? customer,
OrderType orderType, OrderType orderType,
TableModel table, TableModel? table,
PaymentMethod paymentMethod)? PaymentMethod paymentMethod)?
createWithPayment, createWithPayment,
TResult? Function(List<ProductQuantity> items, String orderId)? addToOrder, TResult? Function(List<ProductQuantity> items, String orderId)? addToOrder,
@ -1331,7 +1331,7 @@ class _$RefundImpl implements _Refund {
String customerName, String customerName,
Customer? customer, Customer? customer,
OrderType orderType, OrderType orderType,
TableModel table, TableModel? table,
PaymentMethod paymentMethod)? PaymentMethod paymentMethod)?
createWithPayment, createWithPayment,
TResult Function(List<ProductQuantity> items, String orderId)? addToOrder, TResult Function(List<ProductQuantity> items, String orderId)? addToOrder,
@ -1520,7 +1520,7 @@ class _$VoidOrderImpl implements _VoidOrder {
String customerName, String customerName,
Customer? customer, Customer? customer,
OrderType orderType, OrderType orderType,
TableModel table, TableModel? table,
PaymentMethod paymentMethod) PaymentMethod paymentMethod)
createWithPayment, createWithPayment,
required TResult Function(List<ProductQuantity> items, String orderId) required TResult Function(List<ProductQuantity> items, String orderId)
@ -1549,7 +1549,7 @@ class _$VoidOrderImpl implements _VoidOrder {
String customerName, String customerName,
Customer? customer, Customer? customer,
OrderType orderType, OrderType orderType,
TableModel table, TableModel? table,
PaymentMethod paymentMethod)? PaymentMethod paymentMethod)?
createWithPayment, createWithPayment,
TResult? Function(List<ProductQuantity> items, String orderId)? addToOrder, TResult? Function(List<ProductQuantity> items, String orderId)? addToOrder,
@ -1575,7 +1575,7 @@ class _$VoidOrderImpl implements _VoidOrder {
String customerName, String customerName,
Customer? customer, Customer? customer,
OrderType orderType, OrderType orderType,
TableModel table, TableModel? table,
PaymentMethod paymentMethod)? PaymentMethod paymentMethod)?
createWithPayment, createWithPayment,
TResult Function(List<ProductQuantity> items, String orderId)? addToOrder, TResult Function(List<ProductQuantity> items, String orderId)? addToOrder,
@ -1737,7 +1737,7 @@ class _$ToggleItemImpl implements _ToggleItem {
String customerName, String customerName,
Customer? customer, Customer? customer,
OrderType orderType, OrderType orderType,
TableModel table, TableModel? table,
PaymentMethod paymentMethod) PaymentMethod paymentMethod)
createWithPayment, createWithPayment,
required TResult Function(List<ProductQuantity> items, String orderId) required TResult Function(List<ProductQuantity> items, String orderId)
@ -1766,7 +1766,7 @@ class _$ToggleItemImpl implements _ToggleItem {
String customerName, String customerName,
Customer? customer, Customer? customer,
OrderType orderType, OrderType orderType,
TableModel table, TableModel? table,
PaymentMethod paymentMethod)? PaymentMethod paymentMethod)?
createWithPayment, createWithPayment,
TResult? Function(List<ProductQuantity> items, String orderId)? addToOrder, TResult? Function(List<ProductQuantity> items, String orderId)? addToOrder,
@ -1792,7 +1792,7 @@ class _$ToggleItemImpl implements _ToggleItem {
String customerName, String customerName,
Customer? customer, Customer? customer,
OrderType orderType, OrderType orderType,
TableModel table, TableModel? table,
PaymentMethod paymentMethod)? PaymentMethod paymentMethod)?
createWithPayment, createWithPayment,
TResult Function(List<ProductQuantity> items, String orderId)? addToOrder, TResult Function(List<ProductQuantity> items, String orderId)? addToOrder,
@ -1951,7 +1951,7 @@ class _$ToggleSelectAllImpl implements _ToggleSelectAll {
String customerName, String customerName,
Customer? customer, Customer? customer,
OrderType orderType, OrderType orderType,
TableModel table, TableModel? table,
PaymentMethod paymentMethod) PaymentMethod paymentMethod)
createWithPayment, createWithPayment,
required TResult Function(List<ProductQuantity> items, String orderId) required TResult Function(List<ProductQuantity> items, String orderId)
@ -1980,7 +1980,7 @@ class _$ToggleSelectAllImpl implements _ToggleSelectAll {
String customerName, String customerName,
Customer? customer, Customer? customer,
OrderType orderType, OrderType orderType,
TableModel table, TableModel? table,
PaymentMethod paymentMethod)? PaymentMethod paymentMethod)?
createWithPayment, createWithPayment,
TResult? Function(List<ProductQuantity> items, String orderId)? addToOrder, TResult? Function(List<ProductQuantity> items, String orderId)? addToOrder,
@ -2006,7 +2006,7 @@ class _$ToggleSelectAllImpl implements _ToggleSelectAll {
String customerName, String customerName,
Customer? customer, Customer? customer,
OrderType orderType, OrderType orderType,
TableModel table, TableModel? table,
PaymentMethod paymentMethod)? PaymentMethod paymentMethod)?
createWithPayment, createWithPayment,
TResult Function(List<ProductQuantity> items, String orderId)? addToOrder, TResult Function(List<ProductQuantity> items, String orderId)? addToOrder,

View File

@ -15,7 +15,7 @@ class OrderFormEvent with _$OrderFormEvent {
required String customerName, required String customerName,
required Customer? customer, required Customer? customer,
required OrderType orderType, required OrderType orderType,
required TableModel table, required TableModel? table,
required PaymentMethod paymentMethod, required PaymentMethod paymentMethod,
}) = _CreateWithPaymentMethod; }) = _CreateWithPaymentMethod;
const factory OrderFormEvent.addToOrder({ const factory OrderFormEvent.addToOrder({

View File

@ -289,7 +289,7 @@ class _PaymentAddOrderDialogState extends State<PaymentAddOrderDialog> {
listener: (context, state) { listener: (context, state) {
state.maybeWhen( state.maybeWhen(
orElse: () {}, orElse: () {},
success: (data) { successMsg: () {
context.pop(); context.pop();
context.pushReplacement( context.pushReplacement(
SuccessSaveOrderPage( SuccessSaveOrderPage(

View File

@ -45,7 +45,6 @@ class OrderRequestModel {
Map<String, dynamic> data = { Map<String, dynamic> data = {
"outlet_id": outletId, "outlet_id": outletId,
"table_number": tableNumber, "table_number": tableNumber,
"table_id": tableId,
"order_type": orderType, "order_type": orderType,
"notes": notes, "notes": notes,
"order_items": orderItems == null "order_items": orderItems == null
@ -58,6 +57,10 @@ class OrderRequestModel {
data["customer_id"] = customerId; data["customer_id"] = customerId;
} }
if (tableId != null && tableId != "") {
data["table_id"] = tableId;
}
return data; return data;
} }
} }

View File

@ -355,7 +355,10 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
(previousValue, element) => (previousValue, element) =>
previousValue + previousValue +
(element.product.price! * (element.product.price! *
element.quantity), element.quantity) +
(element.variant
?.priceModifier ??
0),
)); ));
return Text( return Text(
price.currencyFormatRp, price.currencyFormatRp,
@ -500,7 +503,9 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
(previousValue, element) => (previousValue, element) =>
previousValue + previousValue +
(element.product.price! * (element.product.price! *
element.quantity), element.quantity) +
(element.variant?.priceModifier ??
0),
), ),
); );
@ -1065,12 +1070,15 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
} }
context.read<OrderFormBloc>().add( context.read<OrderFormBloc>().add(
OrderFormEvent.create( OrderFormEvent
.createWithPayment(
items: items, items: items,
customerName: customerName:
customerController customerController
.text, .text,
orderType: orderType, orderType: orderType,
paymentMethod:
selectedPaymentMethod!,
table: widget.table, table: widget.table,
customer: customer:
selectedCustomer, selectedCustomer,

View File

@ -429,8 +429,10 @@ class _HomePageState extends State<HomePage> {
} }
return products return products
.map((e) => .map((e) =>
e.product.price! * (e.product.price! *
e.quantity) e.quantity) +
(e.variant?.priceModifier ??
0))
.reduce((value, element) => .reduce((value, element) =>
value + element); value + element);
}); });

View File

@ -538,7 +538,8 @@ class _SuccessOrderPageState extends State<SuccessOrderPage>
Widget _buildProductCard(int index) { Widget _buildProductCard(int index) {
final item = widget.productQuantity[index]; final item = widget.productQuantity[index];
final totalPrice = (item.product.price ?? 0) * item.quantity; final totalPrice = (item.product.price ?? 0) * item.quantity +
(item.variant?.priceModifier ?? 0);
return TweenAnimationBuilder<double>( return TweenAnimationBuilder<double>(
tween: Tween<double>(begin: 0.0, end: 1.0), tween: Tween<double>(begin: 0.0, end: 1.0),
@ -634,7 +635,8 @@ class _SuccessOrderPageState extends State<SuccessOrderPage>
borderRadius: BorderRadius.circular(8), borderRadius: BorderRadius.circular(8),
), ),
child: Text( child: Text(
(item.product.price ?? 0) ((item.product.price ?? 0) +
(item.variant?.priceModifier ?? 0))
.toString() .toString()
.currencyFormatRpV2, .currencyFormatRpV2,
style: TextStyle( style: TextStyle(

View File

@ -24,12 +24,27 @@ class SuccessSaveOrderPage extends StatefulWidget {
} }
class _SuccessSaveOrderPageState extends State<SuccessSaveOrderPage> { class _SuccessSaveOrderPageState extends State<SuccessSaveOrderPage> {
int totalPrice = 0;
getPrice() {
setState(() {
totalPrice = widget.productQuantity.fold(
0,
(previousValue, element) =>
previousValue +
(element.product.price! * element.quantity) +
(element.variant?.priceModifier ?? 0),
);
});
}
@override @override
void initState() { void initState() {
super.initState(); super.initState();
context context
.read<OrderLoaderBloc>() .read<OrderLoaderBloc>()
.add(OrderLoaderEvent.getById(widget.orderId)); .add(OrderLoaderEvent.getById(widget.orderId));
getPrice();
} }
@override @override
@ -380,7 +395,8 @@ class _SuccessSaveOrderPageState extends State<SuccessSaveOrderPage> {
Widget _buildProductCard(int index) { Widget _buildProductCard(int index) {
final item = widget.productQuantity[index]; final item = widget.productQuantity[index];
final totalPrice = (item.product.price ?? 0) * item.quantity; final totalPrice = (item.product.price ?? 0) * item.quantity +
(item.variant?.priceModifier ?? 0);
return Container( return Container(
padding: const EdgeInsets.all(16.0), padding: const EdgeInsets.all(16.0),
@ -464,7 +480,10 @@ class _SuccessSaveOrderPageState extends State<SuccessSaveOrderPage> {
borderRadius: BorderRadius.circular(8), borderRadius: BorderRadius.circular(8),
), ),
child: Text( child: Text(
(item.product.price ?? 0).toString().currencyFormatRpV2, ((item.product.price ?? 0) +
(item.variant?.priceModifier ?? 0))
.toString()
.currencyFormatRpV2,
style: TextStyle( style: TextStyle(
fontSize: 14, fontSize: 14,
color: Colors.grey.shade700, color: Colors.grey.shade700,
@ -707,7 +726,7 @@ class _SuccessSaveOrderPageState extends State<SuccessSaveOrderPage> {
), ),
), ),
Text( Text(
(order.totalAmount ?? 0).toString().currencyFormatRpV2, totalPrice.toString().currencyFormatRpV2,
style: const TextStyle( style: const TextStyle(
fontSize: 24, fontSize: 24,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
@ -876,7 +895,7 @@ class _SuccessSaveOrderPageState extends State<SuccessSaveOrderPage> {
], ],
), ),
Text( Text(
(order.totalAmount ?? 0).toString().currencyFormatRpV2, totalPrice.toString().currencyFormatRpV2,
style: const TextStyle( style: const TextStyle(
fontSize: 14, fontSize: 14,
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
@ -954,7 +973,7 @@ class _SuccessSaveOrderPageState extends State<SuccessSaveOrderPage> {
], ],
), ),
child: Text( child: Text(
(order.totalAmount ?? 0).toString().currencyFormatRpV2, totalPrice.toString().currencyFormatRpV2,
style: const TextStyle( style: const TextStyle(
fontSize: 18, fontSize: 18,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,