feat: sync order
This commit is contained in:
parent
3d1ae25bcf
commit
051b64e3a6
@ -3,4 +3,5 @@ class Variables {
|
||||
static const String apiVersion = 'v1';
|
||||
// static const String baseUrl = 'http://192.168.1.202:8000';
|
||||
static const String baseUrl = 'https://enaklo-pos-be.altru.id';
|
||||
static const int defaultLimit = 10;
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@ import 'package:enaklo_pos/core/extensions/int_ext.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import 'package:enaklo_pos/core/utils/helper_pdf_service.dart';
|
||||
import 'package:enaklo_pos/data/models/response/order_remote_datasource.dart';
|
||||
import 'package:enaklo_pos/data/models/response/order_response_model.dart';
|
||||
import 'package:pdf/widgets.dart';
|
||||
import 'package:pdf/pdf.dart';
|
||||
import 'package:pdf/widgets.dart' as pw;
|
||||
@ -13,7 +13,7 @@ import 'package:pdf/widgets.dart' as pw;
|
||||
class TransactionSalesInvoice {
|
||||
static late Font ttf;
|
||||
static Future<File> generate(
|
||||
List<ItemOrder> itemOrders, String searchDateFormatted) async {
|
||||
List<Order> itemOrders, String searchDateFormatted) async {
|
||||
final pdf = Document();
|
||||
// var data = await rootBundle.load("assets/fonts/noto-sans.ttf");
|
||||
// ttf = Font.ttf(data);
|
||||
@ -70,7 +70,7 @@ class TransactionSalesInvoice {
|
||||
),
|
||||
]);
|
||||
|
||||
static Widget buildInvoice(List<ItemOrder> itemOrders) {
|
||||
static Widget buildInvoice(List<Order> itemOrders) {
|
||||
final headers = [
|
||||
'Total',
|
||||
'Sub Total',
|
||||
@ -81,12 +81,13 @@ class TransactionSalesInvoice {
|
||||
];
|
||||
final data = itemOrders.map((item) {
|
||||
return [
|
||||
item.total!.currencyFormatRp,
|
||||
item.subTotal!.currencyFormatRp,
|
||||
item.tax!.currencyFormatRp,
|
||||
int.parse(item.discountAmount!.replaceAll('.00', '')).currencyFormatRp,
|
||||
item.serviceCharge!.currencyFormatRp,
|
||||
item.transactionTime!.toFormattedDate2(),
|
||||
item.totalAmount!.currencyFormatRp,
|
||||
item.subtotal!.currencyFormatRp,
|
||||
item.taxAmount!.currencyFormatRp,
|
||||
int.parse(item.discountAmount!.toString().replaceAll('.00', ''))
|
||||
.currencyFormatRp,
|
||||
0,
|
||||
item.createdAt!.toFormattedDate2(),
|
||||
];
|
||||
}).toList();
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@ import 'package:dio/dio.dart';
|
||||
import 'package:enaklo_pos/core/constants/variables.dart';
|
||||
import 'package:enaklo_pos/core/network/dio_client.dart';
|
||||
import 'package:enaklo_pos/data/datasources/auth_local_datasource.dart';
|
||||
import 'package:enaklo_pos/data/models/response/order_remote_datasource.dart';
|
||||
import 'package:enaklo_pos/data/models/response/order_response_model.dart';
|
||||
import 'package:enaklo_pos/data/models/response/payment_method_response_model.dart';
|
||||
import 'package:enaklo_pos/data/models/response/summary_response_model.dart';
|
||||
import 'package:enaklo_pos/presentation/home/models/order_model.dart';
|
||||
@ -223,4 +223,48 @@ class OrderRemoteDatasource {
|
||||
return const Left('Terjadi kesalahan tak terduga');
|
||||
}
|
||||
}
|
||||
|
||||
Future<Either<String, OrderResponseModel>> getOrder(
|
||||
{int page = 1,
|
||||
int limit = Variables.defaultLimit,
|
||||
String status = 'completed'}) async {
|
||||
try {
|
||||
final authData = await AuthLocalDataSource().getAuthData();
|
||||
final response = await dio.get(
|
||||
'${Variables.baseUrl}/api/v1/orders',
|
||||
queryParameters: {
|
||||
'page': page,
|
||||
'limit': limit,
|
||||
'status': status,
|
||||
'outlet_id': authData.user?.outletId,
|
||||
},
|
||||
options: Options(
|
||||
headers: {
|
||||
'Authorization': 'Bearer ${authData.token}',
|
||||
'Accept': 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
log("📥 HTTP Status Code: ${response.statusCode}");
|
||||
log("📥 Response Body: ${response.data}");
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
log("✅ getOrderByRangeDate API call successful");
|
||||
return Right(OrderResponseModel.fromMap(response.data));
|
||||
} else {
|
||||
log("❌ getOrderByRangeDate API call failed - Status: ${response.statusCode}");
|
||||
return const Left("Failed Load Data");
|
||||
}
|
||||
} on DioException catch (e) {
|
||||
final errorMessage = 'Something went wrong';
|
||||
log("💥 Dio error: ${e.message}");
|
||||
log("💥 Dio response: ${e.response?.data}");
|
||||
return Left(errorMessage);
|
||||
} catch (e) {
|
||||
log("💥 Unexpected error: $e");
|
||||
return Left("Unexpected Error: $e");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,113 +0,0 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class OrderResponseModel {
|
||||
String? status;
|
||||
List<ItemOrder>? data;
|
||||
|
||||
OrderResponseModel({
|
||||
this.status,
|
||||
this.data,
|
||||
});
|
||||
|
||||
factory OrderResponseModel.fromJson(String str) =>
|
||||
OrderResponseModel.fromMap(json.decode(str));
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
factory OrderResponseModel.fromMap(Map<String, dynamic> json) =>
|
||||
OrderResponseModel(
|
||||
status: json["status"],
|
||||
data: json["data"] == null
|
||||
? []
|
||||
: List<ItemOrder>.from(
|
||||
json["data"]!.map((x) => ItemOrder.fromMap(x))),
|
||||
);
|
||||
|
||||
Map<String, dynamic> toMap() => {
|
||||
"status": status,
|
||||
"data":
|
||||
data == null ? [] : List<dynamic>.from(data!.map((x) => x.toMap())),
|
||||
};
|
||||
}
|
||||
|
||||
class ItemOrder {
|
||||
int? id;
|
||||
int? paymentAmount;
|
||||
int? subTotal;
|
||||
int? tax;
|
||||
int? discount;
|
||||
String? discountAmount;
|
||||
int? serviceCharge;
|
||||
int? total;
|
||||
String? paymentMethod;
|
||||
int? totalItem;
|
||||
int? idKasir;
|
||||
String? namaKasir;
|
||||
DateTime? transactionTime;
|
||||
DateTime? createdAt;
|
||||
DateTime? updatedAt;
|
||||
|
||||
ItemOrder({
|
||||
this.id,
|
||||
this.paymentAmount,
|
||||
this.subTotal,
|
||||
this.tax,
|
||||
this.discount,
|
||||
this.discountAmount,
|
||||
this.serviceCharge,
|
||||
this.total,
|
||||
this.paymentMethod,
|
||||
this.totalItem,
|
||||
this.idKasir,
|
||||
this.namaKasir,
|
||||
this.transactionTime,
|
||||
this.createdAt,
|
||||
this.updatedAt,
|
||||
});
|
||||
|
||||
factory ItemOrder.fromJson(String str) => ItemOrder.fromMap(json.decode(str));
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
factory ItemOrder.fromMap(Map<String, dynamic> json) => ItemOrder(
|
||||
id: json["id"],
|
||||
paymentAmount: json["payment_amount"],
|
||||
subTotal: json["sub_total"],
|
||||
tax: json["tax"],
|
||||
discount: json["discount"],
|
||||
discountAmount: json["discount_amount"],
|
||||
serviceCharge: json["service_charge"],
|
||||
total: json["total"],
|
||||
paymentMethod: json["payment_method"]!,
|
||||
totalItem: json["total_item"],
|
||||
idKasir: json["id_kasir"],
|
||||
namaKasir: json["nama_kasir"],
|
||||
transactionTime: json["transaction_time"] == null
|
||||
? null
|
||||
: DateTime.parse(json["transaction_time"]),
|
||||
createdAt: json["created_at"] == null
|
||||
? null
|
||||
: DateTime.parse(json["created_at"]),
|
||||
updatedAt: json["updated_at"] == null
|
||||
? null
|
||||
: DateTime.parse(json["updated_at"]),
|
||||
);
|
||||
|
||||
Map<String, dynamic> toMap() => {
|
||||
"id": id,
|
||||
"payment_amount": paymentAmount,
|
||||
"sub_total": subTotal,
|
||||
"tax": tax,
|
||||
"discount": discount,
|
||||
"discount_amount": discountAmount,
|
||||
"service_charge": serviceCharge,
|
||||
"total": total,
|
||||
"payment_method": paymentMethod,
|
||||
"total_item": totalItem,
|
||||
"id_kasir": idKasir,
|
||||
"nama_kasir": namaKasir,
|
||||
"transaction_time": transactionTime?.toIso8601String(),
|
||||
"created_at": createdAt?.toIso8601String(),
|
||||
"updated_at": updatedAt?.toIso8601String(),
|
||||
};
|
||||
}
|
||||
220
lib/data/models/response/order_response_model.dart
Normal file
220
lib/data/models/response/order_response_model.dart
Normal file
@ -0,0 +1,220 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class OrderResponseModel {
|
||||
final bool? success;
|
||||
final OrderData? data;
|
||||
final dynamic errors;
|
||||
|
||||
OrderResponseModel({
|
||||
this.success,
|
||||
this.data,
|
||||
this.errors,
|
||||
});
|
||||
|
||||
factory OrderResponseModel.fromJson(String str) =>
|
||||
OrderResponseModel.fromMap(json.decode(str));
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
factory OrderResponseModel.fromMap(Map<String, dynamic> json) =>
|
||||
OrderResponseModel(
|
||||
success: json["success"],
|
||||
data: json["data"] == null ? null : OrderData.fromMap(json["data"]),
|
||||
errors: json["errors"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toMap() => {
|
||||
"success": success,
|
||||
"data": data?.toMap(),
|
||||
"errors": errors,
|
||||
};
|
||||
}
|
||||
|
||||
class OrderData {
|
||||
final List<Order>? orders;
|
||||
final int? totalCount;
|
||||
final int? page;
|
||||
final int? limit;
|
||||
final int? totalPages;
|
||||
|
||||
OrderData({
|
||||
this.orders,
|
||||
this.totalCount,
|
||||
this.page,
|
||||
this.limit,
|
||||
this.totalPages,
|
||||
});
|
||||
|
||||
factory OrderData.fromMap(Map<String, dynamic> json) => OrderData(
|
||||
orders: json["orders"] == null
|
||||
? []
|
||||
: List<Order>.from(json["orders"].map((x) => Order.fromMap(x))),
|
||||
totalCount: json["total_count"],
|
||||
page: json["page"],
|
||||
limit: json["limit"],
|
||||
totalPages: json["total_pages"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toMap() => {
|
||||
"orders": orders == null
|
||||
? []
|
||||
: List<dynamic>.from(orders!.map((x) => x.toMap())),
|
||||
"total_count": totalCount,
|
||||
"page": page,
|
||||
"limit": limit,
|
||||
"total_pages": totalPages,
|
||||
};
|
||||
}
|
||||
|
||||
class Order {
|
||||
final String? id;
|
||||
final String? orderNumber;
|
||||
final String? outletId;
|
||||
final String? userId;
|
||||
final String? tableNumber;
|
||||
final String? orderType;
|
||||
final String? status;
|
||||
final int? subtotal;
|
||||
final int? taxAmount;
|
||||
final int? discountAmount;
|
||||
final int? totalAmount;
|
||||
final String? notes;
|
||||
final Map<String, dynamic>? metadata;
|
||||
final DateTime? createdAt;
|
||||
final DateTime? updatedAt;
|
||||
final List<OrderItem>? orderItems;
|
||||
|
||||
Order({
|
||||
this.id,
|
||||
this.orderNumber,
|
||||
this.outletId,
|
||||
this.userId,
|
||||
this.tableNumber,
|
||||
this.orderType,
|
||||
this.status,
|
||||
this.subtotal,
|
||||
this.taxAmount,
|
||||
this.discountAmount,
|
||||
this.totalAmount,
|
||||
this.notes,
|
||||
this.metadata,
|
||||
this.createdAt,
|
||||
this.updatedAt,
|
||||
this.orderItems,
|
||||
});
|
||||
|
||||
factory Order.fromMap(Map<String, dynamic> json) => Order(
|
||||
id: json["id"],
|
||||
orderNumber: json["order_number"],
|
||||
outletId: json["outlet_id"],
|
||||
userId: json["user_id"],
|
||||
tableNumber: json["table_number"],
|
||||
orderType: json["order_type"],
|
||||
status: json["status"],
|
||||
subtotal: json["subtotal"],
|
||||
taxAmount: json["tax_amount"],
|
||||
discountAmount: json["discount_amount"],
|
||||
totalAmount: json["total_amount"],
|
||||
notes: json["notes"],
|
||||
metadata: json["metadata"] ?? {},
|
||||
createdAt: json["created_at"] == null
|
||||
? null
|
||||
: DateTime.parse(json["created_at"]),
|
||||
updatedAt: json["updated_at"] == null
|
||||
? null
|
||||
: DateTime.parse(json["updated_at"]),
|
||||
orderItems: json["order_items"] == null
|
||||
? []
|
||||
: List<OrderItem>.from(
|
||||
json["order_items"].map((x) => OrderItem.fromMap(x))),
|
||||
);
|
||||
|
||||
Map<String, dynamic> toMap() => {
|
||||
"id": id,
|
||||
"order_number": orderNumber,
|
||||
"outlet_id": outletId,
|
||||
"user_id": userId,
|
||||
"table_number": tableNumber,
|
||||
"order_type": orderType,
|
||||
"status": status,
|
||||
"subtotal": subtotal,
|
||||
"tax_amount": taxAmount,
|
||||
"discount_amount": discountAmount,
|
||||
"total_amount": totalAmount,
|
||||
"notes": notes,
|
||||
"metadata": metadata,
|
||||
"created_at": createdAt?.toIso8601String(),
|
||||
"updated_at": updatedAt?.toIso8601String(),
|
||||
"order_items": orderItems == null
|
||||
? []
|
||||
: List<dynamic>.from(orderItems!.map((x) => x.toMap())),
|
||||
};
|
||||
}
|
||||
|
||||
class OrderItem {
|
||||
final String? id;
|
||||
final String? orderId;
|
||||
final String? productId;
|
||||
final String? productName;
|
||||
final String? productVariantId;
|
||||
final int? quantity;
|
||||
final int? unitPrice;
|
||||
final int? totalPrice;
|
||||
final List<dynamic>? modifiers;
|
||||
final String? notes;
|
||||
final String? status;
|
||||
final DateTime? createdAt;
|
||||
final DateTime? updatedAt;
|
||||
|
||||
OrderItem({
|
||||
this.id,
|
||||
this.orderId,
|
||||
this.productId,
|
||||
this.productName,
|
||||
this.productVariantId,
|
||||
this.quantity,
|
||||
this.unitPrice,
|
||||
this.totalPrice,
|
||||
this.modifiers,
|
||||
this.notes,
|
||||
this.status,
|
||||
this.createdAt,
|
||||
this.updatedAt,
|
||||
});
|
||||
|
||||
factory OrderItem.fromMap(Map<String, dynamic> json) => OrderItem(
|
||||
id: json["id"],
|
||||
orderId: json["order_id"],
|
||||
productId: json["product_id"],
|
||||
productName: json["product_name"],
|
||||
productVariantId: json["product_variant_id"],
|
||||
quantity: json["quantity"],
|
||||
unitPrice: json["unit_price"],
|
||||
totalPrice: json["total_price"],
|
||||
modifiers: json["modifiers"] ?? [],
|
||||
notes: json["notes"],
|
||||
status: json["status"],
|
||||
createdAt: json["created_at"] == null
|
||||
? null
|
||||
: DateTime.parse(json["created_at"]),
|
||||
updatedAt: json["updated_at"] == null
|
||||
? null
|
||||
: DateTime.parse(json["updated_at"]),
|
||||
);
|
||||
|
||||
Map<String, dynamic> toMap() => {
|
||||
"id": id,
|
||||
"order_id": orderId,
|
||||
"product_id": productId,
|
||||
"product_name": productName,
|
||||
"product_variant_id": productVariantId,
|
||||
"quantity": quantity,
|
||||
"unit_price": unitPrice,
|
||||
"total_price": totalPrice,
|
||||
"modifiers": modifiers,
|
||||
"notes": notes,
|
||||
"status": status,
|
||||
"created_at": createdAt?.toIso8601String(),
|
||||
"updated_at": updatedAt?.toIso8601String(),
|
||||
};
|
||||
}
|
||||
@ -4,6 +4,7 @@ import 'package:enaklo_pos/data/datasources/outlet_remote_data_source.dart';
|
||||
import 'package:enaklo_pos/presentation/home/bloc/order_form/order_form_bloc.dart';
|
||||
import 'package:enaklo_pos/presentation/home/bloc/outlet_loader/outlet_loader_bloc.dart';
|
||||
import 'package:enaklo_pos/presentation/home/bloc/product_loader/product_loader_bloc.dart';
|
||||
import 'package:enaklo_pos/presentation/sales/blocs/order_loader/order_loader_bloc.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:enaklo_pos/data/datasources/auth_local_datasource.dart';
|
||||
import 'package:enaklo_pos/data/datasources/auth_remote_datasource.dart';
|
||||
@ -227,6 +228,9 @@ class _MyAppState extends State<MyApp> {
|
||||
BlocProvider(
|
||||
create: (context) => OrderFormBloc(OrderRemoteDatasource()),
|
||||
),
|
||||
BlocProvider(
|
||||
create: (context) => OrderLoaderBloc(OrderRemoteDatasource()),
|
||||
),
|
||||
BlocProvider(
|
||||
create: (context) => OutletLoaderBloc(OutletRemoteDataSource()),
|
||||
),
|
||||
|
||||
@ -46,6 +46,8 @@ class _DashboardPageState extends State<DashboardPage> {
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
late StreamSubscription<List<ConnectivityResult>> _connectivitySubscription;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
@ -63,24 +65,19 @@ class _DashboardPageState extends State<DashboardPage> {
|
||||
const SettingsPage(),
|
||||
];
|
||||
// ignore: unused_local_variable
|
||||
StreamSubscription<List<ConnectivityResult>> subscription = Connectivity()
|
||||
_connectivitySubscription = Connectivity()
|
||||
.onConnectivityChanged
|
||||
.listen((List<ConnectivityResult> connectivityResult) {
|
||||
// Received changes in available connectivity types!
|
||||
if (!mounted) return; // <-- Tambahkan ini!
|
||||
if (connectivityResult.contains(ConnectivityResult.mobile)) {
|
||||
// Mobile network available.
|
||||
context
|
||||
.read<OnlineCheckerBloc>()
|
||||
.add(const OnlineCheckerEvent.check(true));
|
||||
} else if (connectivityResult.contains(ConnectivityResult.wifi)) {
|
||||
// Wi-fi is available.
|
||||
context
|
||||
.read<OnlineCheckerBloc>()
|
||||
.add(const OnlineCheckerEvent.check(true));
|
||||
// Note for Android:
|
||||
// When both mobile and Wi-Fi are turned on system will return Wi-Fi only as active network type
|
||||
} else {
|
||||
// Neither mobile network nor Wi-fi available.
|
||||
context
|
||||
.read<OnlineCheckerBloc>()
|
||||
.add(const OnlineCheckerEvent.check(false));
|
||||
@ -88,6 +85,12 @@ class _DashboardPageState extends State<DashboardPage> {
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_connectivitySubscription.cancel(); // <-- Cancel subscription di dispose
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SafeArea(
|
||||
|
||||
@ -37,7 +37,9 @@ class HomeRightTitle extends StatelessWidget {
|
||||
width: 180.0,
|
||||
height: 40,
|
||||
elevation: 0,
|
||||
onPressed: () => context.push(SalesPage()),
|
||||
onPressed: () => context.push(SalesPage(
|
||||
status: 'pending',
|
||||
)),
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
icon: Icon(
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
|
||||
import 'package:enaklo_pos/data/models/response/order_response_model.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:enaklo_pos/data/datasources/order_remote_datasource.dart';
|
||||
import 'package:enaklo_pos/data/models/response/order_remote_datasource.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'transaction_report_event.dart';
|
||||
@ -19,7 +18,8 @@ class TransactionReportBloc
|
||||
event.endDate,
|
||||
);
|
||||
|
||||
result.fold((l) => emit(_Error(l)), (r) => emit(_Loaded(r.data!)));
|
||||
result.fold(
|
||||
(l) => emit(_Error(l)), (r) => emit(_Loaded(r.data!.orders!)));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -342,7 +342,7 @@ mixin _$TransactionReportState {
|
||||
required TResult Function() initial,
|
||||
required TResult Function() loading,
|
||||
required TResult Function(String message) error,
|
||||
required TResult Function(List<ItemOrder> transactionReport) loaded,
|
||||
required TResult Function(List<Order> transactionReport) loaded,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
@ -350,7 +350,7 @@ mixin _$TransactionReportState {
|
||||
TResult? Function()? initial,
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(String message)? error,
|
||||
TResult? Function(List<ItemOrder> transactionReport)? loaded,
|
||||
TResult? Function(List<Order> transactionReport)? loaded,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
@ -358,7 +358,7 @@ mixin _$TransactionReportState {
|
||||
TResult Function()? initial,
|
||||
TResult Function()? loading,
|
||||
TResult Function(String message)? error,
|
||||
TResult Function(List<ItemOrder> transactionReport)? loaded,
|
||||
TResult Function(List<Order> transactionReport)? loaded,
|
||||
required TResult orElse(),
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@ -455,7 +455,7 @@ class _$InitialImpl implements _Initial {
|
||||
required TResult Function() initial,
|
||||
required TResult Function() loading,
|
||||
required TResult Function(String message) error,
|
||||
required TResult Function(List<ItemOrder> transactionReport) loaded,
|
||||
required TResult Function(List<Order> transactionReport) loaded,
|
||||
}) {
|
||||
return initial();
|
||||
}
|
||||
@ -466,7 +466,7 @@ class _$InitialImpl implements _Initial {
|
||||
TResult? Function()? initial,
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(String message)? error,
|
||||
TResult? Function(List<ItemOrder> transactionReport)? loaded,
|
||||
TResult? Function(List<Order> transactionReport)? loaded,
|
||||
}) {
|
||||
return initial?.call();
|
||||
}
|
||||
@ -477,7 +477,7 @@ class _$InitialImpl implements _Initial {
|
||||
TResult Function()? initial,
|
||||
TResult Function()? loading,
|
||||
TResult Function(String message)? error,
|
||||
TResult Function(List<ItemOrder> transactionReport)? loaded,
|
||||
TResult Function(List<Order> transactionReport)? loaded,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (initial != null) {
|
||||
@ -572,7 +572,7 @@ class _$LoadingImpl implements _Loading {
|
||||
required TResult Function() initial,
|
||||
required TResult Function() loading,
|
||||
required TResult Function(String message) error,
|
||||
required TResult Function(List<ItemOrder> transactionReport) loaded,
|
||||
required TResult Function(List<Order> transactionReport) loaded,
|
||||
}) {
|
||||
return loading();
|
||||
}
|
||||
@ -583,7 +583,7 @@ class _$LoadingImpl implements _Loading {
|
||||
TResult? Function()? initial,
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(String message)? error,
|
||||
TResult? Function(List<ItemOrder> transactionReport)? loaded,
|
||||
TResult? Function(List<Order> transactionReport)? loaded,
|
||||
}) {
|
||||
return loading?.call();
|
||||
}
|
||||
@ -594,7 +594,7 @@ class _$LoadingImpl implements _Loading {
|
||||
TResult Function()? initial,
|
||||
TResult Function()? loading,
|
||||
TResult Function(String message)? error,
|
||||
TResult Function(List<ItemOrder> transactionReport)? loaded,
|
||||
TResult Function(List<Order> transactionReport)? loaded,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (loading != null) {
|
||||
@ -716,7 +716,7 @@ class _$ErrorImpl implements _Error {
|
||||
required TResult Function() initial,
|
||||
required TResult Function() loading,
|
||||
required TResult Function(String message) error,
|
||||
required TResult Function(List<ItemOrder> transactionReport) loaded,
|
||||
required TResult Function(List<Order> transactionReport) loaded,
|
||||
}) {
|
||||
return error(message);
|
||||
}
|
||||
@ -727,7 +727,7 @@ class _$ErrorImpl implements _Error {
|
||||
TResult? Function()? initial,
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(String message)? error,
|
||||
TResult? Function(List<ItemOrder> transactionReport)? loaded,
|
||||
TResult? Function(List<Order> transactionReport)? loaded,
|
||||
}) {
|
||||
return error?.call(message);
|
||||
}
|
||||
@ -738,7 +738,7 @@ class _$ErrorImpl implements _Error {
|
||||
TResult Function()? initial,
|
||||
TResult Function()? loading,
|
||||
TResult Function(String message)? error,
|
||||
TResult Function(List<ItemOrder> transactionReport)? loaded,
|
||||
TResult Function(List<Order> transactionReport)? loaded,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (error != null) {
|
||||
@ -803,7 +803,7 @@ abstract class _$$LoadedImplCopyWith<$Res> {
|
||||
_$LoadedImpl value, $Res Function(_$LoadedImpl) then) =
|
||||
__$$LoadedImplCopyWithImpl<$Res>;
|
||||
@useResult
|
||||
$Res call({List<ItemOrder> transactionReport});
|
||||
$Res call({List<Order> transactionReport});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@ -825,7 +825,7 @@ class __$$LoadedImplCopyWithImpl<$Res>
|
||||
null == transactionReport
|
||||
? _value._transactionReport
|
||||
: transactionReport // ignore: cast_nullable_to_non_nullable
|
||||
as List<ItemOrder>,
|
||||
as List<Order>,
|
||||
));
|
||||
}
|
||||
}
|
||||
@ -833,12 +833,12 @@ class __$$LoadedImplCopyWithImpl<$Res>
|
||||
/// @nodoc
|
||||
|
||||
class _$LoadedImpl implements _Loaded {
|
||||
const _$LoadedImpl(final List<ItemOrder> transactionReport)
|
||||
const _$LoadedImpl(final List<Order> transactionReport)
|
||||
: _transactionReport = transactionReport;
|
||||
|
||||
final List<ItemOrder> _transactionReport;
|
||||
final List<Order> _transactionReport;
|
||||
@override
|
||||
List<ItemOrder> get transactionReport {
|
||||
List<Order> get transactionReport {
|
||||
if (_transactionReport is EqualUnmodifiableListView)
|
||||
return _transactionReport;
|
||||
// ignore: implicit_dynamic_type
|
||||
@ -877,7 +877,7 @@ class _$LoadedImpl implements _Loaded {
|
||||
required TResult Function() initial,
|
||||
required TResult Function() loading,
|
||||
required TResult Function(String message) error,
|
||||
required TResult Function(List<ItemOrder> transactionReport) loaded,
|
||||
required TResult Function(List<Order> transactionReport) loaded,
|
||||
}) {
|
||||
return loaded(transactionReport);
|
||||
}
|
||||
@ -888,7 +888,7 @@ class _$LoadedImpl implements _Loaded {
|
||||
TResult? Function()? initial,
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(String message)? error,
|
||||
TResult? Function(List<ItemOrder> transactionReport)? loaded,
|
||||
TResult? Function(List<Order> transactionReport)? loaded,
|
||||
}) {
|
||||
return loaded?.call(transactionReport);
|
||||
}
|
||||
@ -899,7 +899,7 @@ class _$LoadedImpl implements _Loaded {
|
||||
TResult Function()? initial,
|
||||
TResult Function()? loading,
|
||||
TResult Function(String message)? error,
|
||||
TResult Function(List<ItemOrder> transactionReport)? loaded,
|
||||
TResult Function(List<Order> transactionReport)? loaded,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (loaded != null) {
|
||||
@ -947,9 +947,9 @@ class _$LoadedImpl implements _Loaded {
|
||||
}
|
||||
|
||||
abstract class _Loaded implements TransactionReportState {
|
||||
const factory _Loaded(final List<ItemOrder> transactionReport) = _$LoadedImpl;
|
||||
const factory _Loaded(final List<Order> transactionReport) = _$LoadedImpl;
|
||||
|
||||
List<ItemOrder> get transactionReport;
|
||||
List<Order> get transactionReport;
|
||||
|
||||
/// Create a copy of TransactionReportState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
|
||||
@ -5,6 +5,6 @@ class TransactionReportState with _$TransactionReportState {
|
||||
const factory TransactionReportState.initial() = _Initial;
|
||||
const factory TransactionReportState.loading() = _Loading;
|
||||
const factory TransactionReportState.error(String message) = _Error;
|
||||
const factory TransactionReportState.loaded(
|
||||
List<ItemOrder> transactionReport) = _Loaded;
|
||||
const factory TransactionReportState.loaded(List<Order> transactionReport) =
|
||||
_Loaded;
|
||||
}
|
||||
|
||||
@ -2,20 +2,19 @@ import 'dart:developer';
|
||||
|
||||
import 'package:enaklo_pos/core/components/spaces.dart';
|
||||
import 'package:enaklo_pos/core/constants/colors.dart';
|
||||
import 'package:enaklo_pos/core/extensions/date_time_ext.dart';
|
||||
import 'package:enaklo_pos/core/extensions/int_ext.dart';
|
||||
import 'package:enaklo_pos/core/utils/helper_pdf_service.dart';
|
||||
import 'package:enaklo_pos/presentation/report/widgets/report_page_title.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:enaklo_pos/core/utils/permession_handler.dart';
|
||||
import 'package:enaklo_pos/core/utils/transaction_sales_invoice.dart';
|
||||
import 'package:enaklo_pos/data/models/response/order_remote_datasource.dart';
|
||||
import 'package:enaklo_pos/data/models/response/order_response_model.dart';
|
||||
import 'package:horizontal_data_table/horizontal_data_table.dart';
|
||||
|
||||
class TransactionReportWidget extends StatelessWidget {
|
||||
final String title;
|
||||
final String searchDateFormatted;
|
||||
final List<ItemOrder> transactionReport;
|
||||
final List<Order> transactionReport;
|
||||
final List<Widget>? headerWidgets;
|
||||
const TransactionReportWidget({
|
||||
super.key,
|
||||
@ -91,86 +90,88 @@ class TransactionReportWidget extends StatelessWidget {
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Center(
|
||||
child: Text(
|
||||
transactionReport[index].total!.currencyFormatRp,
|
||||
transactionReport[index]
|
||||
.totalAmount!
|
||||
.currencyFormatRp,
|
||||
)),
|
||||
),
|
||||
Container(
|
||||
width: 120,
|
||||
height: 52,
|
||||
padding: const EdgeInsets.fromLTRB(5, 0, 0, 0),
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Center(
|
||||
child: Text(
|
||||
transactionReport[index].subTotal!.currencyFormatRp,
|
||||
)),
|
||||
),
|
||||
Container(
|
||||
width: 100,
|
||||
height: 52,
|
||||
padding: const EdgeInsets.fromLTRB(5, 0, 0, 0),
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Center(
|
||||
child: Text(
|
||||
transactionReport[index].tax!.currencyFormatRp,
|
||||
)),
|
||||
),
|
||||
Container(
|
||||
width: 100,
|
||||
height: 52,
|
||||
padding: const EdgeInsets.fromLTRB(5, 0, 0, 0),
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Center(
|
||||
child: Text(
|
||||
int.parse(transactionReport[index]
|
||||
.discountAmount!
|
||||
.replaceAll('.00', ''))
|
||||
.currencyFormatRp,
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
width: 100,
|
||||
height: 52,
|
||||
padding: const EdgeInsets.fromLTRB(5, 0, 0, 0),
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Center(
|
||||
child: Text(
|
||||
transactionReport[index]
|
||||
.serviceCharge!
|
||||
.currencyFormatRp,
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
width: 100,
|
||||
height: 52,
|
||||
padding: const EdgeInsets.fromLTRB(5, 0, 0, 0),
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Center(
|
||||
child: Text(
|
||||
transactionReport[index].totalItem.toString()),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
width: 150,
|
||||
height: 52,
|
||||
padding: const EdgeInsets.fromLTRB(5, 0, 0, 0),
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Center(
|
||||
child: Text(transactionReport[index].namaKasir!),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
width: 230,
|
||||
height: 52,
|
||||
padding: const EdgeInsets.fromLTRB(5, 0, 0, 0),
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Center(
|
||||
child: Text(transactionReport[index]
|
||||
.transactionTime!
|
||||
.toFormattedDate()),
|
||||
),
|
||||
),
|
||||
// Container(
|
||||
// width: 120,
|
||||
// height: 52,
|
||||
// padding: const EdgeInsets.fromLTRB(5, 0, 0, 0),
|
||||
// alignment: Alignment.centerLeft,
|
||||
// child: Center(
|
||||
// child: Text(
|
||||
// transactionReport[index].subTotal!.currencyFormatRp,
|
||||
// )),
|
||||
// ),
|
||||
// Container(
|
||||
// width: 100,
|
||||
// height: 52,
|
||||
// padding: const EdgeInsets.fromLTRB(5, 0, 0, 0),
|
||||
// alignment: Alignment.centerLeft,
|
||||
// child: Center(
|
||||
// child: Text(
|
||||
// transactionReport[index].tax!.currencyFormatRp,
|
||||
// )),
|
||||
// ),
|
||||
// Container(
|
||||
// width: 100,
|
||||
// height: 52,
|
||||
// padding: const EdgeInsets.fromLTRB(5, 0, 0, 0),
|
||||
// alignment: Alignment.centerLeft,
|
||||
// child: Center(
|
||||
// child: Text(
|
||||
// int.parse(transactionReport[index]
|
||||
// .discountAmount!
|
||||
// .replaceAll('.00', ''))
|
||||
// .currencyFormatRp,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// Container(
|
||||
// width: 100,
|
||||
// height: 52,
|
||||
// padding: const EdgeInsets.fromLTRB(5, 0, 0, 0),
|
||||
// alignment: Alignment.centerLeft,
|
||||
// child: Center(
|
||||
// child: Text(
|
||||
// transactionReport[index]
|
||||
// .serviceCharge!
|
||||
// .currencyFormatRp,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// Container(
|
||||
// width: 100,
|
||||
// height: 52,
|
||||
// padding: const EdgeInsets.fromLTRB(5, 0, 0, 0),
|
||||
// alignment: Alignment.centerLeft,
|
||||
// child: Center(
|
||||
// child: Text(
|
||||
// transactionReport[index].totalItem.toString()),
|
||||
// ),
|
||||
// ),
|
||||
// Container(
|
||||
// width: 150,
|
||||
// height: 52,
|
||||
// padding: const EdgeInsets.fromLTRB(5, 0, 0, 0),
|
||||
// alignment: Alignment.centerLeft,
|
||||
// child: Center(
|
||||
// child: Text(transactionReport[index].namaKasir!),
|
||||
// ),
|
||||
// ),
|
||||
// Container(
|
||||
// width: 230,
|
||||
// height: 52,
|
||||
// padding: const EdgeInsets.fromLTRB(5, 0, 0, 0),
|
||||
// alignment: Alignment.centerLeft,
|
||||
// child: Center(
|
||||
// child: Text(transactionReport[index]
|
||||
// .transactionTime!
|
||||
// .toFormattedDate()),
|
||||
// ),
|
||||
// ),
|
||||
],
|
||||
);
|
||||
},
|
||||
|
||||
@ -0,0 +1,27 @@
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:enaklo_pos/data/datasources/order_remote_datasource.dart';
|
||||
import 'package:enaklo_pos/data/models/response/order_response_model.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'order_loader_event.dart';
|
||||
part 'order_loader_state.dart';
|
||||
part 'order_loader_bloc.freezed.dart';
|
||||
|
||||
class OrderLoaderBloc extends Bloc<OrderLoaderEvent, OrderLoaderState> {
|
||||
final OrderRemoteDatasource _orderRemoteDatasource;
|
||||
OrderLoaderBloc(this._orderRemoteDatasource)
|
||||
: super(OrderLoaderState.initial()) {
|
||||
on<_GetByStatus>((event, emit) async {
|
||||
emit(const _Loading());
|
||||
final result =
|
||||
await _orderRemoteDatasource.getOrder(status: event.status);
|
||||
result.fold(
|
||||
(l) => emit(_Error(l)),
|
||||
(r) => emit(_Loaded(
|
||||
r.data?.orders ?? [],
|
||||
r.data?.totalCount ?? 0,
|
||||
)),
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,863 @@
|
||||
// coverage:ignore-file
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
||||
|
||||
part of 'order_loader_bloc.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
T _$identity<T>(T value) => value;
|
||||
|
||||
final _privateConstructorUsedError = UnsupportedError(
|
||||
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models');
|
||||
|
||||
/// @nodoc
|
||||
mixin _$OrderLoaderEvent {
|
||||
String get status => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function(String status) getByStatus,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function(String status)? getByStatus,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function(String status)? getByStatus,
|
||||
required TResult orElse(),
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_GetByStatus value) getByStatus,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_GetByStatus value)? getByStatus,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_GetByStatus value)? getByStatus,
|
||||
required TResult orElse(),
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of OrderLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$OrderLoaderEventCopyWith<OrderLoaderEvent> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $OrderLoaderEventCopyWith<$Res> {
|
||||
factory $OrderLoaderEventCopyWith(
|
||||
OrderLoaderEvent value, $Res Function(OrderLoaderEvent) then) =
|
||||
_$OrderLoaderEventCopyWithImpl<$Res, OrderLoaderEvent>;
|
||||
@useResult
|
||||
$Res call({String status});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$OrderLoaderEventCopyWithImpl<$Res, $Val extends OrderLoaderEvent>
|
||||
implements $OrderLoaderEventCopyWith<$Res> {
|
||||
_$OrderLoaderEventCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of OrderLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? status = null,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
status: null == status
|
||||
? _value.status
|
||||
: status // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
) as $Val);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$GetByStatusImplCopyWith<$Res>
|
||||
implements $OrderLoaderEventCopyWith<$Res> {
|
||||
factory _$$GetByStatusImplCopyWith(
|
||||
_$GetByStatusImpl value, $Res Function(_$GetByStatusImpl) then) =
|
||||
__$$GetByStatusImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({String status});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$GetByStatusImplCopyWithImpl<$Res>
|
||||
extends _$OrderLoaderEventCopyWithImpl<$Res, _$GetByStatusImpl>
|
||||
implements _$$GetByStatusImplCopyWith<$Res> {
|
||||
__$$GetByStatusImplCopyWithImpl(
|
||||
_$GetByStatusImpl _value, $Res Function(_$GetByStatusImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
/// Create a copy of OrderLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? status = null,
|
||||
}) {
|
||||
return _then(_$GetByStatusImpl(
|
||||
null == status
|
||||
? _value.status
|
||||
: status // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$GetByStatusImpl implements _GetByStatus {
|
||||
const _$GetByStatusImpl(this.status);
|
||||
|
||||
@override
|
||||
final String status;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'OrderLoaderEvent.getByStatus(status: $status)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$GetByStatusImpl &&
|
||||
(identical(other.status, status) || other.status == status));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, status);
|
||||
|
||||
/// Create a copy of OrderLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$GetByStatusImplCopyWith<_$GetByStatusImpl> get copyWith =>
|
||||
__$$GetByStatusImplCopyWithImpl<_$GetByStatusImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function(String status) getByStatus,
|
||||
}) {
|
||||
return getByStatus(status);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function(String status)? getByStatus,
|
||||
}) {
|
||||
return getByStatus?.call(status);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function(String status)? getByStatus,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (getByStatus != null) {
|
||||
return getByStatus(status);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_GetByStatus value) getByStatus,
|
||||
}) {
|
||||
return getByStatus(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_GetByStatus value)? getByStatus,
|
||||
}) {
|
||||
return getByStatus?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_GetByStatus value)? getByStatus,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (getByStatus != null) {
|
||||
return getByStatus(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _GetByStatus implements OrderLoaderEvent {
|
||||
const factory _GetByStatus(final String status) = _$GetByStatusImpl;
|
||||
|
||||
@override
|
||||
String get status;
|
||||
|
||||
/// Create a copy of OrderLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$GetByStatusImplCopyWith<_$GetByStatusImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$OrderLoaderState {
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function() initial,
|
||||
required TResult Function() loading,
|
||||
required TResult Function(List<Order> orders, int totalOrder) loaded,
|
||||
required TResult Function(String message) error,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function()? initial,
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(List<Order> orders, int totalOrder)? loaded,
|
||||
TResult? Function(String message)? error,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function()? initial,
|
||||
TResult Function()? loading,
|
||||
TResult Function(List<Order> orders, int totalOrder)? loaded,
|
||||
TResult Function(String message)? error,
|
||||
required TResult orElse(),
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_Initial value) initial,
|
||||
required TResult Function(_Loading value) loading,
|
||||
required TResult Function(_Loaded value) loaded,
|
||||
required TResult Function(_Error value) error,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_Initial value)? initial,
|
||||
TResult? Function(_Loading value)? loading,
|
||||
TResult? Function(_Loaded value)? loaded,
|
||||
TResult? Function(_Error value)? error,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_Initial value)? initial,
|
||||
TResult Function(_Loading value)? loading,
|
||||
TResult Function(_Loaded value)? loaded,
|
||||
TResult Function(_Error value)? error,
|
||||
required TResult orElse(),
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $OrderLoaderStateCopyWith<$Res> {
|
||||
factory $OrderLoaderStateCopyWith(
|
||||
OrderLoaderState value, $Res Function(OrderLoaderState) then) =
|
||||
_$OrderLoaderStateCopyWithImpl<$Res, OrderLoaderState>;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$OrderLoaderStateCopyWithImpl<$Res, $Val extends OrderLoaderState>
|
||||
implements $OrderLoaderStateCopyWith<$Res> {
|
||||
_$OrderLoaderStateCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of OrderLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$InitialImplCopyWith<$Res> {
|
||||
factory _$$InitialImplCopyWith(
|
||||
_$InitialImpl value, $Res Function(_$InitialImpl) then) =
|
||||
__$$InitialImplCopyWithImpl<$Res>;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$InitialImplCopyWithImpl<$Res>
|
||||
extends _$OrderLoaderStateCopyWithImpl<$Res, _$InitialImpl>
|
||||
implements _$$InitialImplCopyWith<$Res> {
|
||||
__$$InitialImplCopyWithImpl(
|
||||
_$InitialImpl _value, $Res Function(_$InitialImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
/// Create a copy of OrderLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$InitialImpl implements _Initial {
|
||||
const _$InitialImpl();
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'OrderLoaderState.initial()';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType && other is _$InitialImpl);
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => runtimeType.hashCode;
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function() initial,
|
||||
required TResult Function() loading,
|
||||
required TResult Function(List<Order> orders, int totalOrder) loaded,
|
||||
required TResult Function(String message) error,
|
||||
}) {
|
||||
return initial();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function()? initial,
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(List<Order> orders, int totalOrder)? loaded,
|
||||
TResult? Function(String message)? error,
|
||||
}) {
|
||||
return initial?.call();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function()? initial,
|
||||
TResult Function()? loading,
|
||||
TResult Function(List<Order> orders, int totalOrder)? loaded,
|
||||
TResult Function(String message)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (initial != null) {
|
||||
return initial();
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_Initial value) initial,
|
||||
required TResult Function(_Loading value) loading,
|
||||
required TResult Function(_Loaded value) loaded,
|
||||
required TResult Function(_Error value) error,
|
||||
}) {
|
||||
return initial(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_Initial value)? initial,
|
||||
TResult? Function(_Loading value)? loading,
|
||||
TResult? Function(_Loaded value)? loaded,
|
||||
TResult? Function(_Error value)? error,
|
||||
}) {
|
||||
return initial?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_Initial value)? initial,
|
||||
TResult Function(_Loading value)? loading,
|
||||
TResult Function(_Loaded value)? loaded,
|
||||
TResult Function(_Error value)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (initial != null) {
|
||||
return initial(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _Initial implements OrderLoaderState {
|
||||
const factory _Initial() = _$InitialImpl;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$LoadingImplCopyWith<$Res> {
|
||||
factory _$$LoadingImplCopyWith(
|
||||
_$LoadingImpl value, $Res Function(_$LoadingImpl) then) =
|
||||
__$$LoadingImplCopyWithImpl<$Res>;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$LoadingImplCopyWithImpl<$Res>
|
||||
extends _$OrderLoaderStateCopyWithImpl<$Res, _$LoadingImpl>
|
||||
implements _$$LoadingImplCopyWith<$Res> {
|
||||
__$$LoadingImplCopyWithImpl(
|
||||
_$LoadingImpl _value, $Res Function(_$LoadingImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
/// Create a copy of OrderLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$LoadingImpl implements _Loading {
|
||||
const _$LoadingImpl();
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'OrderLoaderState.loading()';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType && other is _$LoadingImpl);
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => runtimeType.hashCode;
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function() initial,
|
||||
required TResult Function() loading,
|
||||
required TResult Function(List<Order> orders, int totalOrder) loaded,
|
||||
required TResult Function(String message) error,
|
||||
}) {
|
||||
return loading();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function()? initial,
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(List<Order> orders, int totalOrder)? loaded,
|
||||
TResult? Function(String message)? error,
|
||||
}) {
|
||||
return loading?.call();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function()? initial,
|
||||
TResult Function()? loading,
|
||||
TResult Function(List<Order> orders, int totalOrder)? loaded,
|
||||
TResult Function(String message)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (loading != null) {
|
||||
return loading();
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_Initial value) initial,
|
||||
required TResult Function(_Loading value) loading,
|
||||
required TResult Function(_Loaded value) loaded,
|
||||
required TResult Function(_Error value) error,
|
||||
}) {
|
||||
return loading(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_Initial value)? initial,
|
||||
TResult? Function(_Loading value)? loading,
|
||||
TResult? Function(_Loaded value)? loaded,
|
||||
TResult? Function(_Error value)? error,
|
||||
}) {
|
||||
return loading?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_Initial value)? initial,
|
||||
TResult Function(_Loading value)? loading,
|
||||
TResult Function(_Loaded value)? loaded,
|
||||
TResult Function(_Error value)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (loading != null) {
|
||||
return loading(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _Loading implements OrderLoaderState {
|
||||
const factory _Loading() = _$LoadingImpl;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$LoadedImplCopyWith<$Res> {
|
||||
factory _$$LoadedImplCopyWith(
|
||||
_$LoadedImpl value, $Res Function(_$LoadedImpl) then) =
|
||||
__$$LoadedImplCopyWithImpl<$Res>;
|
||||
@useResult
|
||||
$Res call({List<Order> orders, int totalOrder});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$LoadedImplCopyWithImpl<$Res>
|
||||
extends _$OrderLoaderStateCopyWithImpl<$Res, _$LoadedImpl>
|
||||
implements _$$LoadedImplCopyWith<$Res> {
|
||||
__$$LoadedImplCopyWithImpl(
|
||||
_$LoadedImpl _value, $Res Function(_$LoadedImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
/// Create a copy of OrderLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? orders = null,
|
||||
Object? totalOrder = null,
|
||||
}) {
|
||||
return _then(_$LoadedImpl(
|
||||
null == orders
|
||||
? _value._orders
|
||||
: orders // ignore: cast_nullable_to_non_nullable
|
||||
as List<Order>,
|
||||
null == totalOrder
|
||||
? _value.totalOrder
|
||||
: totalOrder // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$LoadedImpl implements _Loaded {
|
||||
const _$LoadedImpl(final List<Order> orders, this.totalOrder)
|
||||
: _orders = orders;
|
||||
|
||||
final List<Order> _orders;
|
||||
@override
|
||||
List<Order> get orders {
|
||||
if (_orders is EqualUnmodifiableListView) return _orders;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_orders);
|
||||
}
|
||||
|
||||
@override
|
||||
final int totalOrder;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'OrderLoaderState.loaded(orders: $orders, totalOrder: $totalOrder)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$LoadedImpl &&
|
||||
const DeepCollectionEquality().equals(other._orders, _orders) &&
|
||||
(identical(other.totalOrder, totalOrder) ||
|
||||
other.totalOrder == totalOrder));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(
|
||||
runtimeType, const DeepCollectionEquality().hash(_orders), totalOrder);
|
||||
|
||||
/// Create a copy of OrderLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$LoadedImplCopyWith<_$LoadedImpl> get copyWith =>
|
||||
__$$LoadedImplCopyWithImpl<_$LoadedImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function() initial,
|
||||
required TResult Function() loading,
|
||||
required TResult Function(List<Order> orders, int totalOrder) loaded,
|
||||
required TResult Function(String message) error,
|
||||
}) {
|
||||
return loaded(orders, totalOrder);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function()? initial,
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(List<Order> orders, int totalOrder)? loaded,
|
||||
TResult? Function(String message)? error,
|
||||
}) {
|
||||
return loaded?.call(orders, totalOrder);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function()? initial,
|
||||
TResult Function()? loading,
|
||||
TResult Function(List<Order> orders, int totalOrder)? loaded,
|
||||
TResult Function(String message)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (loaded != null) {
|
||||
return loaded(orders, totalOrder);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_Initial value) initial,
|
||||
required TResult Function(_Loading value) loading,
|
||||
required TResult Function(_Loaded value) loaded,
|
||||
required TResult Function(_Error value) error,
|
||||
}) {
|
||||
return loaded(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_Initial value)? initial,
|
||||
TResult? Function(_Loading value)? loading,
|
||||
TResult? Function(_Loaded value)? loaded,
|
||||
TResult? Function(_Error value)? error,
|
||||
}) {
|
||||
return loaded?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_Initial value)? initial,
|
||||
TResult Function(_Loading value)? loading,
|
||||
TResult Function(_Loaded value)? loaded,
|
||||
TResult Function(_Error value)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (loaded != null) {
|
||||
return loaded(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _Loaded implements OrderLoaderState {
|
||||
const factory _Loaded(final List<Order> orders, final int totalOrder) =
|
||||
_$LoadedImpl;
|
||||
|
||||
List<Order> get orders;
|
||||
int get totalOrder;
|
||||
|
||||
/// Create a copy of OrderLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$LoadedImplCopyWith<_$LoadedImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$ErrorImplCopyWith<$Res> {
|
||||
factory _$$ErrorImplCopyWith(
|
||||
_$ErrorImpl value, $Res Function(_$ErrorImpl) then) =
|
||||
__$$ErrorImplCopyWithImpl<$Res>;
|
||||
@useResult
|
||||
$Res call({String message});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$ErrorImplCopyWithImpl<$Res>
|
||||
extends _$OrderLoaderStateCopyWithImpl<$Res, _$ErrorImpl>
|
||||
implements _$$ErrorImplCopyWith<$Res> {
|
||||
__$$ErrorImplCopyWithImpl(
|
||||
_$ErrorImpl _value, $Res Function(_$ErrorImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
/// Create a copy of OrderLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? message = null,
|
||||
}) {
|
||||
return _then(_$ErrorImpl(
|
||||
null == message
|
||||
? _value.message
|
||||
: message // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$ErrorImpl implements _Error {
|
||||
const _$ErrorImpl(this.message);
|
||||
|
||||
@override
|
||||
final String message;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'OrderLoaderState.error(message: $message)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$ErrorImpl &&
|
||||
(identical(other.message, message) || other.message == message));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, message);
|
||||
|
||||
/// Create a copy of OrderLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$ErrorImplCopyWith<_$ErrorImpl> get copyWith =>
|
||||
__$$ErrorImplCopyWithImpl<_$ErrorImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function() initial,
|
||||
required TResult Function() loading,
|
||||
required TResult Function(List<Order> orders, int totalOrder) loaded,
|
||||
required TResult Function(String message) error,
|
||||
}) {
|
||||
return error(message);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function()? initial,
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(List<Order> orders, int totalOrder)? loaded,
|
||||
TResult? Function(String message)? error,
|
||||
}) {
|
||||
return error?.call(message);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function()? initial,
|
||||
TResult Function()? loading,
|
||||
TResult Function(List<Order> orders, int totalOrder)? loaded,
|
||||
TResult Function(String message)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (error != null) {
|
||||
return error(message);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_Initial value) initial,
|
||||
required TResult Function(_Loading value) loading,
|
||||
required TResult Function(_Loaded value) loaded,
|
||||
required TResult Function(_Error value) error,
|
||||
}) {
|
||||
return error(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_Initial value)? initial,
|
||||
TResult? Function(_Loading value)? loading,
|
||||
TResult? Function(_Loaded value)? loaded,
|
||||
TResult? Function(_Error value)? error,
|
||||
}) {
|
||||
return error?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_Initial value)? initial,
|
||||
TResult Function(_Loading value)? loading,
|
||||
TResult Function(_Loaded value)? loaded,
|
||||
TResult Function(_Error value)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (error != null) {
|
||||
return error(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _Error implements OrderLoaderState {
|
||||
const factory _Error(final String message) = _$ErrorImpl;
|
||||
|
||||
String get message;
|
||||
|
||||
/// Create a copy of OrderLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$ErrorImplCopyWith<_$ErrorImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
@ -0,0 +1,6 @@
|
||||
part of 'order_loader_bloc.dart';
|
||||
|
||||
@freezed
|
||||
class OrderLoaderEvent with _$OrderLoaderEvent {
|
||||
const factory OrderLoaderEvent.getByStatus(String status) = _GetByStatus;
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
part of 'order_loader_bloc.dart';
|
||||
|
||||
@freezed
|
||||
class OrderLoaderState with _$OrderLoaderState {
|
||||
const factory OrderLoaderState.initial() = _Initial;
|
||||
const factory OrderLoaderState.loading() = _Loading;
|
||||
const factory OrderLoaderState.loaded(List<Order> orders, int totalOrder) =
|
||||
_Loaded;
|
||||
const factory OrderLoaderState.error(String message) = _Error;
|
||||
}
|
||||
@ -1,7 +1,9 @@
|
||||
import 'package:enaklo_pos/core/components/buttons.dart';
|
||||
import 'package:enaklo_pos/core/components/spaces.dart';
|
||||
import 'package:enaklo_pos/data/models/response/order_response_model.dart';
|
||||
import 'package:enaklo_pos/presentation/home/models/order_model.dart';
|
||||
import 'package:enaklo_pos/presentation/sales/blocs/day_sales/day_sales_bloc.dart';
|
||||
import 'package:enaklo_pos/presentation/sales/blocs/order_loader/order_loader_bloc.dart';
|
||||
import 'package:enaklo_pos/presentation/sales/widgets/sales_detail.dart';
|
||||
import 'package:enaklo_pos/presentation/sales/widgets/sales_list_order.dart';
|
||||
import 'package:enaklo_pos/presentation/sales/widgets/sales_order_information.dart';
|
||||
@ -15,7 +17,8 @@ import '../widgets/sales_card.dart';
|
||||
import '../widgets/sales_title.dart';
|
||||
|
||||
class SalesPage extends StatefulWidget {
|
||||
const SalesPage({super.key});
|
||||
final String status;
|
||||
const SalesPage({super.key, required this.status});
|
||||
|
||||
@override
|
||||
State<SalesPage> createState() => _SalesPageState();
|
||||
@ -24,7 +27,7 @@ class SalesPage extends StatefulWidget {
|
||||
class _SalesPageState extends State<SalesPage> {
|
||||
DateTime startDate = DateTime.now();
|
||||
DateTime endDate = DateTime.now();
|
||||
OrderModel? orderDetail;
|
||||
Order? orderDetail;
|
||||
|
||||
int _total = 0;
|
||||
String searchQuery = '';
|
||||
@ -32,18 +35,18 @@ class _SalesPageState extends State<SalesPage> {
|
||||
@override
|
||||
void initState() {
|
||||
context
|
||||
.read<DaySalesBloc>()
|
||||
.add(DaySalesEvent.getRangeDateSales(startDate, endDate));
|
||||
.read<OrderLoaderBloc>()
|
||||
.add(OrderLoaderEvent.getByStatus(widget.status));
|
||||
super.initState();
|
||||
}
|
||||
|
||||
List<OrderModel> _filterOrders(List<OrderModel> orders) {
|
||||
List<Order> _filterOrders(List<Order> orders) {
|
||||
if (searchQuery.isEmpty) {
|
||||
return orders;
|
||||
}
|
||||
|
||||
return orders.where((order) {
|
||||
final customerName = order.customerName.toLowerCase();
|
||||
final customerName = order.orderNumber?.toLowerCase() ?? "";
|
||||
final queryLower = searchQuery.toLowerCase();
|
||||
return customerName.contains(queryLower);
|
||||
}).toList();
|
||||
@ -63,6 +66,9 @@ class _SalesPageState extends State<SalesPage> {
|
||||
child: Column(
|
||||
children: [
|
||||
SalesTitle(
|
||||
title: widget.status == 'pending'
|
||||
? "Pending Pesanan"
|
||||
: "Daftar Pesanan",
|
||||
startDate: startDate,
|
||||
endDate: endDate,
|
||||
total: _total,
|
||||
@ -83,13 +89,26 @@ class _SalesPageState extends State<SalesPage> {
|
||||
},
|
||||
),
|
||||
Expanded(
|
||||
child: BlocBuilder<DaySalesBloc, DaySalesState>(
|
||||
child: BlocBuilder<OrderLoaderBloc, OrderLoaderState>(
|
||||
builder: (context, state) {
|
||||
return state.maybeWhen(
|
||||
orElse: () => const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
loaded: (orders) {
|
||||
loading: () => const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
error: (message) => Center(
|
||||
child: Text(
|
||||
message,
|
||||
style: TextStyle(
|
||||
fontSize: 16.0,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
loaded: (orders, totalOrder) {
|
||||
_total = totalOrder;
|
||||
final filtered = _filterOrders(orders);
|
||||
if (filtered.isEmpty) {
|
||||
return Center(
|
||||
@ -102,13 +121,6 @@ class _SalesPageState extends State<SalesPage> {
|
||||
),
|
||||
);
|
||||
} else {
|
||||
WidgetsBinding.instance
|
||||
.addPostFrameCallback((_) {
|
||||
setState(() {
|
||||
_total = filtered.length;
|
||||
});
|
||||
});
|
||||
|
||||
return SingleChildScrollView(
|
||||
child: Column(
|
||||
children: List.generate(
|
||||
@ -162,32 +174,35 @@ class _SalesPageState extends State<SalesPage> {
|
||||
),
|
||||
],
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: SalesOrderInformation(
|
||||
order: orderDetail,
|
||||
Expanded(
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: SalesOrderInformation(
|
||||
order: orderDetail,
|
||||
),
|
||||
),
|
||||
),
|
||||
SpaceWidth(16),
|
||||
Expanded(
|
||||
child: SalesDetail(
|
||||
order: orderDetail,
|
||||
SpaceWidth(16),
|
||||
Expanded(
|
||||
child: SalesDetail(
|
||||
order: orderDetail,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SalesListOrder(
|
||||
order: orderDetail,
|
||||
),
|
||||
SalesPayment(
|
||||
order: orderDetail,
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
SalesListOrder(
|
||||
order: orderDetail,
|
||||
),
|
||||
SalesPayment(
|
||||
order: orderDetail,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
import 'package:enaklo_pos/core/constants/colors.dart';
|
||||
import 'package:enaklo_pos/core/extensions/date_time_ext.dart';
|
||||
import 'package:enaklo_pos/core/extensions/int_ext.dart';
|
||||
import 'package:enaklo_pos/presentation/home/models/order_model.dart';
|
||||
import 'package:enaklo_pos/data/models/response/order_response_model.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class SalesCard extends StatelessWidget {
|
||||
final OrderModel order;
|
||||
final Order order;
|
||||
final bool isActive;
|
||||
|
||||
const SalesCard({
|
||||
@ -29,6 +29,17 @@ class SalesCard extends StatelessWidget {
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: Text(
|
||||
'${order.orderNumber}',
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
@ -44,9 +55,9 @@ class SalesCard extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
order.customerName == ""
|
||||
order.metadata?['customer_name'] == ""
|
||||
? "Anonim"
|
||||
: order.customerName,
|
||||
: order.metadata?['customer_name'],
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
@ -74,7 +85,7 @@ class SalesCard extends StatelessWidget {
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
),
|
||||
child: Text(
|
||||
order.status.toUpperCase(),
|
||||
(order.status ?? "").toUpperCase(),
|
||||
style: TextStyle(
|
||||
color: Colors.green,
|
||||
fontWeight: FontWeight.w600,
|
||||
@ -90,7 +101,7 @@ class SalesCard extends StatelessWidget {
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
order.total.currencyFormatRpV2,
|
||||
(order.totalAmount ?? 0).currencyFormatRpV2,
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
@ -98,7 +109,7 @@ class SalesCard extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
Text(
|
||||
DateTime.parse(order.transactionTime).toFormattedDate2(),
|
||||
(order.createdAt ?? DateTime.now()).toFormattedDate3(),
|
||||
style: TextStyle(
|
||||
color: AppColors.black,
|
||||
),
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
import 'package:enaklo_pos/core/constants/colors.dart';
|
||||
import 'package:enaklo_pos/core/extensions/date_time_ext.dart';
|
||||
import 'package:enaklo_pos/presentation/home/models/order_model.dart';
|
||||
import 'package:enaklo_pos/data/models/response/order_response_model.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class SalesDetail extends StatelessWidget {
|
||||
final OrderModel? order;
|
||||
final Order? order;
|
||||
const SalesDetail({super.key, this.order});
|
||||
|
||||
@override
|
||||
@ -28,20 +28,15 @@ class SalesDetail extends StatelessWidget {
|
||||
),
|
||||
_item(
|
||||
title: 'Pelanggan',
|
||||
value: order?.customerName ?? "-",
|
||||
value: order?.metadata?['customer_name'] ?? "-",
|
||||
),
|
||||
_item(
|
||||
title: 'Waktu',
|
||||
value:
|
||||
DateTime.parse(order?.transactionTime ?? "").toFormattedDate3(),
|
||||
value: (order?.createdAt ?? DateTime.now()).toFormattedDate3(),
|
||||
),
|
||||
_item(
|
||||
title: 'Status',
|
||||
value: order?.paymentStatus ?? "-",
|
||||
),
|
||||
_item(
|
||||
title: 'Jenis Order',
|
||||
value: order?.paymentMethod ?? "-",
|
||||
value: order?.status ?? "-",
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@ -1,10 +1,9 @@
|
||||
import 'package:enaklo_pos/core/constants/colors.dart';
|
||||
import 'package:enaklo_pos/presentation/home/models/order_model.dart';
|
||||
import 'package:enaklo_pos/presentation/home/models/product_quantity.dart';
|
||||
import 'package:enaklo_pos/data/models/response/order_response_model.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class SalesListOrder extends StatelessWidget {
|
||||
final OrderModel? order;
|
||||
final Order? order;
|
||||
const SalesListOrder({super.key, this.order});
|
||||
|
||||
@override
|
||||
@ -37,8 +36,8 @@ class SalesListOrder extends StatelessWidget {
|
||||
),
|
||||
Column(
|
||||
children: List.generate(
|
||||
order?.orderItems.length ?? 0,
|
||||
(index) => _item(order!.orderItems[index]),
|
||||
order?.orderItems?.length ?? 0,
|
||||
(index) => _item(order!.orderItems![index]),
|
||||
).toList(),
|
||||
),
|
||||
],
|
||||
@ -46,7 +45,7 @@ class SalesListOrder extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Padding _item(ProductQuantity product) {
|
||||
Padding _item(OrderItem product) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 16)
|
||||
.copyWith(bottom: 0),
|
||||
@ -56,13 +55,13 @@ class SalesListOrder extends StatelessWidget {
|
||||
Column(
|
||||
children: [
|
||||
Text(
|
||||
product.product.name ?? '',
|
||||
product.productName ?? '',
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
(product.product.price ?? 0) as String,
|
||||
(product.unitPrice ?? 0).toString(),
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
),
|
||||
@ -76,7 +75,7 @@ class SalesListOrder extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
Text(
|
||||
(product.product.price ?? 0) as String,
|
||||
(product.totalPrice ?? 0).toString(),
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
),
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
import 'package:enaklo_pos/core/constants/colors.dart';
|
||||
import 'package:enaklo_pos/core/extensions/date_time_ext.dart';
|
||||
import 'package:enaklo_pos/presentation/home/models/order_model.dart';
|
||||
import 'package:enaklo_pos/data/models/response/order_response_model.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class SalesOrderInformation extends StatelessWidget {
|
||||
final OrderModel? order;
|
||||
final Order? order;
|
||||
const SalesOrderInformation({super.key, this.order});
|
||||
|
||||
@override
|
||||
@ -28,20 +28,19 @@ class SalesOrderInformation extends StatelessWidget {
|
||||
),
|
||||
_item(
|
||||
title: 'No. Order',
|
||||
value: "${order?.id}",
|
||||
value: "${order?.orderNumber}",
|
||||
),
|
||||
_item(
|
||||
title: 'Tanggal',
|
||||
value:
|
||||
DateTime.parse(order?.transactionTime ?? "").toFormattedDate3(),
|
||||
value: (order?.createdAt ?? DateTime.now()).toFormattedDate2(),
|
||||
),
|
||||
_item(
|
||||
title: 'Kasir',
|
||||
value: order?.namaKasir ?? "-",
|
||||
title: 'No. Meja',
|
||||
value: order?.tableNumber ?? "-",
|
||||
),
|
||||
_item(
|
||||
title: 'Jenis Order',
|
||||
value: order?.orderType.value ?? "-",
|
||||
value: order?.orderType ?? "-",
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@ -2,11 +2,11 @@ import 'package:enaklo_pos/core/components/dashed_divider.dart';
|
||||
import 'package:enaklo_pos/core/components/spaces.dart';
|
||||
import 'package:enaklo_pos/core/constants/colors.dart';
|
||||
import 'package:enaklo_pos/core/extensions/int_ext.dart';
|
||||
import 'package:enaklo_pos/presentation/home/models/order_model.dart';
|
||||
import 'package:enaklo_pos/data/models/response/order_response_model.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class SalesPayment extends StatelessWidget {
|
||||
final OrderModel? order;
|
||||
final Order? order;
|
||||
const SalesPayment({super.key, this.order});
|
||||
|
||||
@override
|
||||
@ -34,14 +34,14 @@ class SalesPayment extends StatelessWidget {
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'Subtotal ${order?.totalItem} Produk',
|
||||
'Subtotal ${order?.orderItems?.length} Produk',
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
(order?.subTotal)?.currencyFormatRp ?? "0",
|
||||
(order?.subtotal)?.currencyFormatRp ?? "0",
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
@ -54,13 +54,13 @@ class SalesPayment extends StatelessWidget {
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'Pajak (11%)',
|
||||
'Pajak',
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
(order?.tax)?.currencyFormatRp ?? "0",
|
||||
(order?.taxAmount)?.currencyFormatRp ?? "0",
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
),
|
||||
@ -83,7 +83,7 @@ class SalesPayment extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
Text(
|
||||
(order?.total)?.currencyFormatRp ?? "0",
|
||||
(order?.totalAmount)?.currencyFormatRp ?? "0",
|
||||
style: const TextStyle(
|
||||
color: AppColors.primary,
|
||||
fontSize: 18,
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
import 'package:enaklo_pos/core/constants/colors.dart';
|
||||
import 'package:enaklo_pos/core/extensions/build_context_ext.dart';
|
||||
import 'package:enaklo_pos/presentation/home/models/order_model.dart';
|
||||
import 'package:enaklo_pos/data/models/response/order_response_model.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class SalesRightTitle extends StatelessWidget {
|
||||
final OrderModel? order;
|
||||
final Order? order;
|
||||
final List<Widget>? actionWidget;
|
||||
const SalesRightTitle({super.key, this.order, this.actionWidget});
|
||||
|
||||
@ -27,7 +27,7 @@ class SalesRightTitle extends StatelessWidget {
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
"Detail Pesanan #${order?.id}",
|
||||
"Detail Pesanan #${order?.orderNumber}",
|
||||
style: TextStyle(
|
||||
color: AppColors.black,
|
||||
fontSize: 20,
|
||||
|
||||
@ -6,6 +6,7 @@ import 'package:enaklo_pos/presentation/sales/dialog/filter_dialog.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class SalesTitle extends StatelessWidget {
|
||||
final String title;
|
||||
final DateTime startDate;
|
||||
final DateTime endDate;
|
||||
final int total;
|
||||
@ -18,7 +19,8 @@ class SalesTitle extends StatelessWidget {
|
||||
required this.endDate,
|
||||
required this.onChanged,
|
||||
required this.total,
|
||||
required this.onDateRangeChanged});
|
||||
required this.onDateRangeChanged,
|
||||
required this.title});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -39,18 +41,14 @@ class SalesTitle extends StatelessWidget {
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: () => context.pop(),
|
||||
child: Icon(
|
||||
Icons.arrow_back,
|
||||
color: AppColors.primary,
|
||||
size: 24,
|
||||
),
|
||||
IconButton(
|
||||
onPressed: () => context.pop(),
|
||||
icon: Icon(Icons.arrow_back, color: AppColors.black),
|
||||
),
|
||||
SpaceWidth(16),
|
||||
Expanded(
|
||||
child: Text(
|
||||
"Daftar Pesanan",
|
||||
title,
|
||||
style: TextStyle(
|
||||
color: AppColors.black,
|
||||
fontSize: 20,
|
||||
|
||||
@ -122,7 +122,8 @@ class _SettingsPageState extends State<SettingsPage> {
|
||||
title: 'Riwayat Transaksi',
|
||||
subtitle: 'Lihat riwayat transaksi',
|
||||
icon: Icons.receipt_long_outlined,
|
||||
onTap: () => indexValue(2),
|
||||
onTap: () =>
|
||||
context.push(SalesPage(status: 'completed')),
|
||||
),
|
||||
SettingTile(
|
||||
index: 3,
|
||||
@ -168,7 +169,9 @@ class _SettingsPageState extends State<SettingsPage> {
|
||||
children: [
|
||||
role != null && role! != 'admin' ? SizedBox() : ProductPage(),
|
||||
DiscountPage(),
|
||||
SalesPage(),
|
||||
SalesPage(
|
||||
status: 'completed',
|
||||
),
|
||||
TaxPage(),
|
||||
SyncDataPage(),
|
||||
ProductPage(),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user