Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5d73f82017 | ||
|
|
1d52f22f5f | ||
|
|
f87309af3f | ||
|
|
96d0b91984 | ||
|
|
e20dc53fb8 | ||
|
|
c09822b470 | ||
|
|
6a9a26f71c | ||
|
|
b0006ee6bc | ||
|
|
b34428965e | ||
|
|
670a0b6414 | ||
|
|
b7ab9c6939 | ||
|
|
6b5af82307 | ||
|
|
2848678cdc | ||
|
|
f05347c90d | ||
|
|
94725964ea | ||
|
|
2eceb0bc0c | ||
|
|
e19d788f47 | ||
|
|
3a07d2e7cc | ||
|
|
2c8b1333d8 | ||
|
|
b1a1303a40 | ||
|
|
de22251440 | ||
|
|
203eda75e4 | ||
|
|
49fef5afb2 | ||
|
|
e3da008a9a | ||
|
|
b5ad20eb8b | ||
|
|
fbd59964c3 | ||
|
|
5a260ca3a1 | ||
|
|
ffe076e120 | ||
|
|
9d78c9dcce | ||
|
|
d0e1f9a5b6 | ||
|
|
ab2a59930c | ||
|
|
fe92082ceb | ||
|
|
5575596bfc | ||
|
|
8022fa6b32 | ||
|
|
811ae06e58 | ||
|
|
2cf5ce7ae8 | ||
|
|
1cd2b1778b | ||
|
|
7d1c3d1bd6 |
@@ -23,7 +23,7 @@ if (flutterVersionName == null) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
namespace "com.example.enaklo_pos"
|
namespace "com.appscale.pos"
|
||||||
compileSdkVersion 35
|
compileSdkVersion 35
|
||||||
ndkVersion flutter.ndkVersion
|
ndkVersion flutter.ndkVersion
|
||||||
|
|
||||||
@@ -42,10 +42,10 @@ android {
|
|||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
|
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
|
||||||
applicationId "com.example.enaklo_pos"
|
applicationId "com.appscale.pos"
|
||||||
// You can update the following values to match your application needs.
|
// You can update the following values to match your application needs.
|
||||||
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
|
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
|
||||||
minSdkVersion 21
|
minSdkVersion flutter.minSdkVersion
|
||||||
targetSdkVersion 35
|
targetSdkVersion 35
|
||||||
versionCode flutterVersionCode.toInteger()
|
versionCode flutterVersionCode.toInteger()
|
||||||
versionName flutterVersionName
|
versionName flutterVersionName
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.example.enaklo_pos
|
package com.appscale.pos
|
||||||
|
|
||||||
import io.flutter.embedding.android.FlutterActivity
|
import io.flutter.embedding.android.FlutterActivity
|
||||||
|
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 5.6 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 9.4 KiB |
|
Before Width: | Height: | Size: 8.8 KiB After Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 38 KiB |
|
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 57 KiB |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 5.6 KiB |
|
Before Width: | Height: | Size: 983 B After Width: | Height: | Size: 3.1 KiB |
|
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 8.3 KiB |
|
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 7.4 KiB After Width: | Height: | Size: 19 KiB |
@@ -0,0 +1,10 @@
|
|||||||
|
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<g clip-path="url(#clip0_17_4760)">
|
||||||
|
<path d="M9 13.75C6.66 13.75 2 14.92 2 17.25V19H16V17.25C16 14.92 11.34 13.75 9 13.75ZM4.34 17C5.18 16.42 7.21 15.75 9 15.75C10.79 15.75 12.82 16.42 13.66 17H4.34ZM9 12C10.93 12 12.5 10.43 12.5 8.5C12.5 6.57 10.93 5 9 5C7.07 5 5.5 6.57 5.5 8.5C5.5 10.43 7.07 12 9 12ZM9 7C9.83 7 10.5 7.67 10.5 8.5C10.5 9.33 9.83 10 9 10C8.17 10 7.5 9.33 7.5 8.5C7.5 7.67 8.17 7 9 7ZM16.04 13.81C17.2 14.65 18 15.77 18 17.25V19H22V17.25C22 15.23 18.5 14.08 16.04 13.81ZM15 12C16.93 12 18.5 10.43 18.5 8.5C18.5 6.57 16.93 5 15 5C14.46 5 13.96 5.13 13.5 5.35C14.13 6.24 14.5 7.33 14.5 8.5C14.5 9.67 14.13 10.76 13.5 11.65C13.96 11.87 14.46 12 15 12Z" fill="white"/>
|
||||||
|
</g>
|
||||||
|
<defs>
|
||||||
|
<clipPath id="clip0_17_4760">
|
||||||
|
<rect width="24" height="24" fill="white"/>
|
||||||
|
</clipPath>
|
||||||
|
</defs>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 892 B |
|
Before Width: | Height: | Size: 88 KiB |
|
Before Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 79 KiB |
|
Before Width: | Height: | Size: 120 KiB After Width: | Height: | Size: 150 KiB |
|
Before Width: | Height: | Size: 320 B After Width: | Height: | Size: 666 B |
|
Before Width: | Height: | Size: 804 B After Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 3.8 KiB |
|
Before Width: | Height: | Size: 492 B After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 3.7 KiB |
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 6.4 KiB |
|
Before Width: | Height: | Size: 804 B After Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 5.8 KiB |
|
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 9.8 KiB |
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 7.8 KiB |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 3.6 KiB |
|
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 9.1 KiB |
|
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 9.8 KiB |
|
Before Width: | Height: | Size: 6.7 KiB After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 5.0 KiB |
|
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 5.4 KiB |
|
Before Width: | Height: | Size: 5.1 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 5.9 KiB After Width: | Height: | Size: 15 KiB |
@@ -3,15 +3,15 @@
|
|||||||
flutter_launcher_icons:
|
flutter_launcher_icons:
|
||||||
android: "launcher_icon"
|
android: "launcher_icon"
|
||||||
ios: true
|
ios: true
|
||||||
image_path: "assets/logo/ic_launcher.png"
|
image_path: "assets/logo/logo.png"
|
||||||
remove_alpha_ios: true
|
remove_alpha_ios: true
|
||||||
min_sdk_android: 21 # android min sdk min:16, default 21
|
min_sdk_android: 21 # android min sdk min:16, default 21
|
||||||
adaptive_icon_background: "#ffffff"
|
adaptive_icon_background: "#ffffff"
|
||||||
adaptive_icon_foreground: "assets/logo/ic_launcher.png"
|
adaptive_icon_foreground: "assets/logo/logo.png"
|
||||||
web:
|
web:
|
||||||
generate: true
|
generate: true
|
||||||
image_path: "assets/logo/ic_launcher.png"
|
image_path: "assets/logo/logo.png"
|
||||||
windows:
|
windows:
|
||||||
generate: true
|
generate: true
|
||||||
image_path: "assets/logo/ic_launcher.png"
|
image_path: "assets/logo/logo.png"
|
||||||
icon_size: 48
|
icon_size: 48
|
||||||
|
|||||||
@@ -101,6 +101,9 @@ class $AssetsIconsGen {
|
|||||||
/// File path: assets/icons/payments.svg
|
/// File path: assets/icons/payments.svg
|
||||||
SvgGenImage get payments => const SvgGenImage('assets/icons/payments.svg');
|
SvgGenImage get payments => const SvgGenImage('assets/icons/payments.svg');
|
||||||
|
|
||||||
|
/// File path: assets/icons/people.svg
|
||||||
|
SvgGenImage get people => const SvgGenImage('assets/icons/people.svg');
|
||||||
|
|
||||||
/// File path: assets/icons/print.svg
|
/// File path: assets/icons/print.svg
|
||||||
SvgGenImage get print => const SvgGenImage('assets/icons/print.svg');
|
SvgGenImage get print => const SvgGenImage('assets/icons/print.svg');
|
||||||
|
|
||||||
@@ -152,6 +155,7 @@ class $AssetsIconsGen {
|
|||||||
orders,
|
orders,
|
||||||
pajak,
|
pajak,
|
||||||
payments,
|
payments,
|
||||||
|
people,
|
||||||
print,
|
print,
|
||||||
qrCode,
|
qrCode,
|
||||||
report,
|
report,
|
||||||
@@ -300,12 +304,8 @@ class $AssetsImagesGen {
|
|||||||
class $AssetsLogoGen {
|
class $AssetsLogoGen {
|
||||||
const $AssetsLogoGen();
|
const $AssetsLogoGen();
|
||||||
|
|
||||||
/// File path: assets/logo/ic_launcher.png
|
/// File path: assets/logo/logo.png
|
||||||
AssetGenImage get icLauncher =>
|
AssetGenImage get logo => const AssetGenImage('assets/logo/logo.png');
|
||||||
const AssetGenImage('assets/logo/ic_launcher.png');
|
|
||||||
|
|
||||||
/// File path: assets/logo/logo.jpeg
|
|
||||||
AssetGenImage get logo => const AssetGenImage('assets/logo/logo.jpeg');
|
|
||||||
|
|
||||||
/// File path: assets/logo/logo2.png
|
/// File path: assets/logo/logo2.png
|
||||||
AssetGenImage get logo2 => const AssetGenImage('assets/logo/logo2.png');
|
AssetGenImage get logo2 => const AssetGenImage('assets/logo/logo2.png');
|
||||||
@@ -330,17 +330,8 @@ class $AssetsLogoGen {
|
|||||||
AssetGenImage get mylogo => const AssetGenImage('assets/logo/mylogo.png');
|
AssetGenImage get mylogo => const AssetGenImage('assets/logo/mylogo.png');
|
||||||
|
|
||||||
/// List of all assets
|
/// List of all assets
|
||||||
List<AssetGenImage> get values => [
|
List<AssetGenImage> get values =>
|
||||||
icLauncher,
|
[logo, logo2, logo3, logo4, logo5, logo6, logoAppIcon, mylogo];
|
||||||
logo,
|
|
||||||
logo2,
|
|
||||||
logo3,
|
|
||||||
logo4,
|
|
||||||
logo5,
|
|
||||||
logo6,
|
|
||||||
logoAppIcon,
|
|
||||||
mylogo
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class Assets {
|
class Assets {
|
||||||
|
|||||||
@@ -1,18 +1,28 @@
|
|||||||
import 'dart:developer';
|
import 'dart:developer';
|
||||||
|
import 'dart:typed_data';
|
||||||
|
|
||||||
|
import 'package:barcode_image/barcode_image.dart';
|
||||||
import 'package:enaklo_pos/core/extensions/string_ext.dart';
|
import 'package:enaklo_pos/core/extensions/string_ext.dart';
|
||||||
import 'package:enaklo_pos/core/utils/printer_service.dart';
|
import 'package:enaklo_pos/core/utils/printer_service.dart';
|
||||||
import 'package:enaklo_pos/data/dataoutputs/print_dataoutputs.dart';
|
import 'package:enaklo_pos/data/dataoutputs/print_dataoutputs.dart';
|
||||||
|
import 'package:enaklo_pos/data/datasources/auth_local_datasource.dart';
|
||||||
|
import 'package:enaklo_pos/data/datasources/outlet_local_datasource.dart';
|
||||||
import 'package:enaklo_pos/data/datasources/product_local_datasource.dart';
|
import 'package:enaklo_pos/data/datasources/product_local_datasource.dart';
|
||||||
|
import 'package:enaklo_pos/data/datasources/settings_local_datasource.dart';
|
||||||
import 'package:enaklo_pos/data/models/response/order_response_model.dart';
|
import 'package:enaklo_pos/data/models/response/order_response_model.dart';
|
||||||
|
import 'package:enaklo_pos/data/type/bussines_type.dart';
|
||||||
import 'package:enaklo_pos/presentation/home/models/product_quantity.dart';
|
import 'package:enaklo_pos/presentation/home/models/product_quantity.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:barcode/barcode.dart';
|
||||||
|
import 'package:image/image.dart' as img;
|
||||||
|
|
||||||
Future<void> onPrint(
|
Future<void> onPrint(
|
||||||
BuildContext context, {
|
BuildContext context, {
|
||||||
required List<ProductQuantity> productQuantity,
|
required List<ProductQuantity> productQuantity,
|
||||||
required Order order,
|
required Order order,
|
||||||
}) async {
|
}) async {
|
||||||
|
final outlet = await OutletLocalDatasource().get();
|
||||||
|
if (outlet.businessType == BusinessType.restaurant) {
|
||||||
final checkerPrinter =
|
final checkerPrinter =
|
||||||
await ProductLocalDatasource.instance.getPrinterByCode('checker');
|
await ProductLocalDatasource.instance.getPrinterByCode('checker');
|
||||||
final kitchenPrinter =
|
final kitchenPrinter =
|
||||||
@@ -20,20 +30,16 @@ Future<void> onPrint(
|
|||||||
final barPrinter =
|
final barPrinter =
|
||||||
await ProductLocalDatasource.instance.getPrinterByCode('bar');
|
await ProductLocalDatasource.instance.getPrinterByCode('bar');
|
||||||
|
|
||||||
log("Checker printer: ${checkerPrinter?.toMap()}");
|
final authData = await AuthLocalDataSource().getAuthData();
|
||||||
log("Kitchen printer: ${kitchenPrinter?.toMap()}");
|
|
||||||
log("Bar printer: ${barPrinter?.toMap()}");
|
|
||||||
|
|
||||||
// Checker printer
|
// Checker printer
|
||||||
if (checkerPrinter != null) {
|
if (checkerPrinter != null) {
|
||||||
try {
|
try {
|
||||||
final printValue = await PrintDataoutputs.instance.printChecker(
|
final printValue = await PrintDataoutputs.instance.printChecker(
|
||||||
productQuantity
|
productQuantity,
|
||||||
.where((e) => e.product.printerType == "checker")
|
|
||||||
.toList(),
|
|
||||||
order.tableNumber ?? "",
|
order.tableNumber ?? "",
|
||||||
order.orderNumber ?? "",
|
order.orderNumber ?? "",
|
||||||
'kasir',
|
authData.user?.name ?? "",
|
||||||
checkerPrinter.paper.toIntegerFromText,
|
checkerPrinter.paper.toIntegerFromText,
|
||||||
order.orderType ?? "",
|
order.orderType ?? "",
|
||||||
);
|
);
|
||||||
@@ -53,12 +59,10 @@ Future<void> onPrint(
|
|||||||
if (kitchenPrinter != null) {
|
if (kitchenPrinter != null) {
|
||||||
try {
|
try {
|
||||||
final printValue = await PrintDataoutputs.instance.printKitchen(
|
final printValue = await PrintDataoutputs.instance.printKitchen(
|
||||||
productQuantity
|
productQuantity,
|
||||||
.where((e) => e.product.printerType == "kitchen")
|
|
||||||
.toList(),
|
|
||||||
order.tableNumber!,
|
order.tableNumber!,
|
||||||
order.orderNumber ?? "",
|
order.orderNumber ?? "",
|
||||||
'kasir',
|
authData.user?.name ?? "",
|
||||||
kitchenPrinter.paper.toIntegerFromText,
|
kitchenPrinter.paper.toIntegerFromText,
|
||||||
order.orderType ?? "",
|
order.orderType ?? "",
|
||||||
);
|
);
|
||||||
@@ -77,15 +81,16 @@ Future<void> onPrint(
|
|||||||
if (barPrinter != null) {
|
if (barPrinter != null) {
|
||||||
try {
|
try {
|
||||||
final printValue = await PrintDataoutputs.instance.printBar(
|
final printValue = await PrintDataoutputs.instance.printBar(
|
||||||
productQuantity.where((e) => e.product.printerType == "bar").toList(),
|
productQuantity,
|
||||||
order.tableNumber ?? "",
|
order.tableNumber ?? "",
|
||||||
order.orderNumber ?? "",
|
order.orderNumber ?? "",
|
||||||
'kasir',
|
authData.user?.name ?? "",
|
||||||
barPrinter.paper.toIntegerFromText,
|
barPrinter.paper.toIntegerFromText,
|
||||||
order.orderType ?? "",
|
order.orderType ?? "",
|
||||||
);
|
);
|
||||||
|
|
||||||
await PrinterService().printWithPrinter(barPrinter, printValue, context);
|
await PrinterService()
|
||||||
|
.printWithPrinter(barPrinter, printValue, context);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log("Error printing bar order: $e");
|
log("Error printing bar order: $e");
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
@@ -94,3 +99,85 @@ Future<void> onPrint(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (outlet.businessType == BusinessType.ticketing) {
|
||||||
|
final ticketPrinter =
|
||||||
|
await ProductLocalDatasource.instance.getPrinterByCode('ticket');
|
||||||
|
|
||||||
|
final barcode = await generateBarcodeAsUint8List(order.orderNumber ?? "");
|
||||||
|
|
||||||
|
if (ticketPrinter != null) {
|
||||||
|
try {
|
||||||
|
final printValue = await PrintDataoutputs.instance.printTicket(
|
||||||
|
order.totalAmount ?? 0,
|
||||||
|
barcode,
|
||||||
|
ticketPrinter.paper.toIntegerFromText,
|
||||||
|
);
|
||||||
|
|
||||||
|
await PrinterService()
|
||||||
|
// ignore: use_build_context_synchronously
|
||||||
|
.printWithPrinter(ticketPrinter, printValue, context);
|
||||||
|
} catch (e) {
|
||||||
|
log("Error printing ticket: $e");
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
SnackBar(content: Text('Error printing ticket: $e')),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> onPrintRecipt(
|
||||||
|
context, {
|
||||||
|
required Order order,
|
||||||
|
required String paymentMethod,
|
||||||
|
required int nominalBayar,
|
||||||
|
required int kembalian,
|
||||||
|
}) async {
|
||||||
|
final receiptPrinter =
|
||||||
|
await ProductLocalDatasource.instance.getPrinterByCode('receipt');
|
||||||
|
final authData = await AuthLocalDataSource().getAuthData();
|
||||||
|
final settings = await SettingsLocalDatasource().getTax();
|
||||||
|
final outlet = await OutletLocalDatasource().get();
|
||||||
|
|
||||||
|
if (receiptPrinter != null) {
|
||||||
|
try {
|
||||||
|
final printValue = await PrintDataoutputs.instance.printOrderV4(
|
||||||
|
order,
|
||||||
|
authData.user?.name ?? "",
|
||||||
|
paymentMethod,
|
||||||
|
nominalBayar,
|
||||||
|
kembalian,
|
||||||
|
settings.value,
|
||||||
|
receiptPrinter.paper.toIntegerFromText,
|
||||||
|
order.orderType ?? "",
|
||||||
|
outlet,
|
||||||
|
);
|
||||||
|
await PrinterService()
|
||||||
|
.printWithPrinter(receiptPrinter, printValue, context);
|
||||||
|
} catch (e) {
|
||||||
|
log("Error printing receipt order: $e");
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
SnackBar(content: Text('Error printing receipt order: $e')),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<Uint8List> generateBarcodeAsUint8List(String data) async {
|
||||||
|
// 1. Buat barcode instance (code128, qrCode, dll)
|
||||||
|
final barcode = Barcode.code128();
|
||||||
|
|
||||||
|
// 2. Siapkan canvas image dari package `image`
|
||||||
|
final image = img.Image(width: 600, height: 200);
|
||||||
|
|
||||||
|
// 3. Gambar barcode ke canvas menggunakan barcode_image
|
||||||
|
drawBarcode(
|
||||||
|
image,
|
||||||
|
barcode,
|
||||||
|
data,
|
||||||
|
);
|
||||||
|
|
||||||
|
// 4. Encode image ke Uint8List PNG
|
||||||
|
return Uint8List.fromList(img.encodePng(image));
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
// lib/core/network/dio_client.dart
|
|
||||||
import 'package:awesome_dio_interceptor/awesome_dio_interceptor.dart';
|
import 'package:awesome_dio_interceptor/awesome_dio_interceptor.dart';
|
||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
|
import 'package:enaklo_pos/core/extensions/build_context_ext.dart';
|
||||||
|
import 'package:enaklo_pos/presentation/auth/login_page.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
class DioClient {
|
class DioClient {
|
||||||
static final Dio _dio = Dio(BaseOptions(
|
static final Dio _dio = Dio(BaseOptions(
|
||||||
@@ -10,6 +13,7 @@ class DioClient {
|
|||||||
'Accept': 'application/json',
|
'Accept': 'application/json',
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
|
..interceptors.add(AuthInterceptor())
|
||||||
..interceptors.add(
|
..interceptors.add(
|
||||||
AwesomeDioInterceptor(
|
AwesomeDioInterceptor(
|
||||||
logRequestTimeout: true,
|
logRequestTimeout: true,
|
||||||
@@ -20,3 +24,158 @@ class DioClient {
|
|||||||
|
|
||||||
static Dio get instance => _dio;
|
static Dio get instance => _dio;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class AuthInterceptor extends Interceptor {
|
||||||
|
static final GlobalKey<NavigatorState> navigatorKey =
|
||||||
|
GlobalKey<NavigatorState>();
|
||||||
|
|
||||||
|
@override
|
||||||
|
void onRequest(
|
||||||
|
RequestOptions options, RequestInterceptorHandler handler) async {
|
||||||
|
// Add token to request headers
|
||||||
|
final prefs = await SharedPreferences.getInstance();
|
||||||
|
final token = prefs.getString('auth_token');
|
||||||
|
|
||||||
|
if (token != null) {
|
||||||
|
options.headers['Authorization'] = 'Bearer $token';
|
||||||
|
}
|
||||||
|
|
||||||
|
handler.next(options);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void onResponse(Response response, ResponseInterceptorHandler handler) {
|
||||||
|
handler.next(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void onError(DioException err, ErrorInterceptorHandler handler) async {
|
||||||
|
// Check if error is 401 (Unauthorized) - token expired
|
||||||
|
if (err.response?.statusCode == 401) {
|
||||||
|
await _handleTokenExpired();
|
||||||
|
}
|
||||||
|
|
||||||
|
handler.next(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _handleTokenExpired() async {
|
||||||
|
// Clear stored token
|
||||||
|
final prefs = await SharedPreferences.getInstance();
|
||||||
|
await prefs.remove('auth_token');
|
||||||
|
await prefs.remove('refresh_token');
|
||||||
|
await prefs.clear(); // Optional: clear all user data
|
||||||
|
|
||||||
|
// Navigate to login page
|
||||||
|
final context = navigatorKey.currentContext;
|
||||||
|
if (context != null) {
|
||||||
|
// Option 1: Navigate and remove all previous routes
|
||||||
|
context.pushReplacement(LoginPage());
|
||||||
|
|
||||||
|
// Option 2: If using GoRouter, uncomment below:
|
||||||
|
// GoRouter.of(context).go('/login');
|
||||||
|
|
||||||
|
// Option 3: If using custom routing, uncomment below:
|
||||||
|
// Navigator.of(context).pushAndRemoveUntil(
|
||||||
|
// MaterialPageRoute(builder: (context) => LoginPage()),
|
||||||
|
// (route) => false,
|
||||||
|
// );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Alternative: Dengan Refresh Token Logic
|
||||||
|
class AuthInterceptorWithRefresh extends Interceptor {
|
||||||
|
static final GlobalKey<NavigatorState> navigatorKey =
|
||||||
|
GlobalKey<NavigatorState>();
|
||||||
|
|
||||||
|
@override
|
||||||
|
void onRequest(
|
||||||
|
RequestOptions options, RequestInterceptorHandler handler) async {
|
||||||
|
final prefs = await SharedPreferences.getInstance();
|
||||||
|
final token = prefs.getString('auth_token');
|
||||||
|
|
||||||
|
if (token != null) {
|
||||||
|
options.headers['Authorization'] = 'Bearer $token';
|
||||||
|
}
|
||||||
|
|
||||||
|
handler.next(options);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void onError(DioException err, ErrorInterceptorHandler handler) async {
|
||||||
|
if (err.response?.statusCode == 401) {
|
||||||
|
// Try refresh token first
|
||||||
|
final success = await _tryRefreshToken();
|
||||||
|
|
||||||
|
if (success) {
|
||||||
|
// Retry the original request
|
||||||
|
final response = await _retryRequest(err.requestOptions);
|
||||||
|
handler.resolve(response);
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
// Refresh failed, redirect to login
|
||||||
|
await _handleTokenExpired();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
handler.next(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<bool> _tryRefreshToken() async {
|
||||||
|
try {
|
||||||
|
final prefs = await SharedPreferences.getInstance();
|
||||||
|
final refreshToken = prefs.getString('refresh_token');
|
||||||
|
|
||||||
|
if (refreshToken == null) return false;
|
||||||
|
|
||||||
|
final response = await Dio().post(
|
||||||
|
'YOUR_REFRESH_TOKEN_ENDPOINT',
|
||||||
|
data: {'refresh_token': refreshToken},
|
||||||
|
);
|
||||||
|
|
||||||
|
if (response.statusCode == 200) {
|
||||||
|
final newToken = response.data['access_token'];
|
||||||
|
final newRefreshToken = response.data['refresh_token'];
|
||||||
|
|
||||||
|
await prefs.setString('auth_token', newToken);
|
||||||
|
await prefs.setString('refresh_token', newRefreshToken);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
print('Refresh token failed: $e');
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<Response> _retryRequest(RequestOptions options) async {
|
||||||
|
final prefs = await SharedPreferences.getInstance();
|
||||||
|
final token = prefs.getString('auth_token');
|
||||||
|
|
||||||
|
options.headers['Authorization'] = 'Bearer $token';
|
||||||
|
|
||||||
|
return await DioClient.instance.request(
|
||||||
|
options.path,
|
||||||
|
options: Options(
|
||||||
|
method: options.method,
|
||||||
|
headers: options.headers,
|
||||||
|
),
|
||||||
|
data: options.data,
|
||||||
|
queryParameters: options.queryParameters,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _handleTokenExpired() async {
|
||||||
|
final prefs = await SharedPreferences.getInstance();
|
||||||
|
await prefs.clear();
|
||||||
|
|
||||||
|
final context = navigatorKey.currentContext;
|
||||||
|
if (context != null) {
|
||||||
|
Navigator.of(context).pushNamedAndRemoveUntil(
|
||||||
|
'/login',
|
||||||
|
(route) => false,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
|
|
||||||
|
import 'package:enaklo_pos/data/models/response/order_response_model.dart';
|
||||||
|
import 'package:enaklo_pos/presentation/home/models/outlet_model.dart';
|
||||||
import 'package:esc_pos_utils_plus/esc_pos_utils_plus.dart';
|
import 'package:esc_pos_utils_plus/esc_pos_utils_plus.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:enaklo_pos/core/extensions/int_ext.dart';
|
import 'package:enaklo_pos/core/extensions/int_ext.dart';
|
||||||
@@ -739,6 +741,267 @@ class PrintDataoutputs {
|
|||||||
return bytes;
|
return bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<List<int>> printOrderV4(
|
||||||
|
Order order,
|
||||||
|
String chashierName,
|
||||||
|
String paymentMethod,
|
||||||
|
int nominalBayar,
|
||||||
|
int kembalian,
|
||||||
|
int taxPercentage,
|
||||||
|
int paper,
|
||||||
|
String orderType,
|
||||||
|
Outlet outlet,
|
||||||
|
) async {
|
||||||
|
List<int> bytes = [];
|
||||||
|
|
||||||
|
final profile = await CapabilityProfile.load();
|
||||||
|
final generator =
|
||||||
|
Generator(paper == 58 ? PaperSize.mm58 : PaperSize.mm80, profile);
|
||||||
|
|
||||||
|
bytes += generator.reset();
|
||||||
|
|
||||||
|
bytes += generator.text(outlet.name ?? "",
|
||||||
|
styles: const PosStyles(
|
||||||
|
bold: true,
|
||||||
|
align: PosAlign.center,
|
||||||
|
height: PosTextSize.size1,
|
||||||
|
width: PosTextSize.size1,
|
||||||
|
));
|
||||||
|
|
||||||
|
bytes += generator.text(outlet.address ?? "",
|
||||||
|
styles: const PosStyles(bold: false, align: PosAlign.center));
|
||||||
|
bytes += generator.text(outlet.phoneNumber ?? "",
|
||||||
|
styles: const PosStyles(bold: false, align: PosAlign.center));
|
||||||
|
|
||||||
|
bytes += generator.text(
|
||||||
|
paper == 80
|
||||||
|
? '------------------------------------------------'
|
||||||
|
: '--------------------------------',
|
||||||
|
styles: const PosStyles(bold: false, align: PosAlign.center));
|
||||||
|
|
||||||
|
bytes += generator.row([
|
||||||
|
PosColumn(
|
||||||
|
text: DateFormat('dd MMM yyyy').format(DateTime.now()),
|
||||||
|
width: 6,
|
||||||
|
styles: const PosStyles(align: PosAlign.left),
|
||||||
|
),
|
||||||
|
PosColumn(
|
||||||
|
text: DateFormat('HH:mm').format(DateTime.now()),
|
||||||
|
width: 6,
|
||||||
|
styles: const PosStyles(align: PosAlign.right),
|
||||||
|
),
|
||||||
|
]);
|
||||||
|
bytes += generator.row([
|
||||||
|
PosColumn(
|
||||||
|
text: 'Receipt Number',
|
||||||
|
width: 6,
|
||||||
|
styles: const PosStyles(align: PosAlign.left),
|
||||||
|
),
|
||||||
|
PosColumn(
|
||||||
|
text: 'JF-${DateFormat('yyyyMMddhhmm').format(DateTime.now())}',
|
||||||
|
width: 6,
|
||||||
|
styles: const PosStyles(align: PosAlign.right),
|
||||||
|
),
|
||||||
|
]);
|
||||||
|
|
||||||
|
bytes += generator.row([
|
||||||
|
PosColumn(
|
||||||
|
text: 'Order ID',
|
||||||
|
width: 6,
|
||||||
|
styles: const PosStyles(align: PosAlign.left),
|
||||||
|
),
|
||||||
|
PosColumn(
|
||||||
|
text: Random().nextInt(100000).toString(),
|
||||||
|
width: 6,
|
||||||
|
styles: const PosStyles(align: PosAlign.right),
|
||||||
|
),
|
||||||
|
]);
|
||||||
|
bytes += generator.row([
|
||||||
|
PosColumn(
|
||||||
|
text: 'Bill Name',
|
||||||
|
width: 6,
|
||||||
|
styles: const PosStyles(align: PosAlign.left),
|
||||||
|
),
|
||||||
|
PosColumn(
|
||||||
|
text: order.metadata?['customer_name'] ?? '',
|
||||||
|
width: 6,
|
||||||
|
styles: const PosStyles(align: PosAlign.right),
|
||||||
|
),
|
||||||
|
]);
|
||||||
|
bytes += generator.row([
|
||||||
|
PosColumn(
|
||||||
|
text: 'Collected By',
|
||||||
|
width: 6,
|
||||||
|
styles: const PosStyles(align: PosAlign.left),
|
||||||
|
),
|
||||||
|
PosColumn(
|
||||||
|
text: chashierName,
|
||||||
|
width: 6,
|
||||||
|
styles: const PosStyles(align: PosAlign.right),
|
||||||
|
),
|
||||||
|
]);
|
||||||
|
bytes += generator.row([
|
||||||
|
PosColumn(
|
||||||
|
text: 'Pembayaran',
|
||||||
|
width: 8,
|
||||||
|
styles: const PosStyles(align: PosAlign.left),
|
||||||
|
),
|
||||||
|
PosColumn(
|
||||||
|
text: paymentMethod,
|
||||||
|
width: 4,
|
||||||
|
styles: const PosStyles(align: PosAlign.right),
|
||||||
|
),
|
||||||
|
]);
|
||||||
|
|
||||||
|
bytes += generator.text(
|
||||||
|
paper == 80
|
||||||
|
? '------------------------------------------------'
|
||||||
|
: '--------------------------------',
|
||||||
|
styles: const PosStyles(bold: false, align: PosAlign.center));
|
||||||
|
bytes += generator.text(orderType,
|
||||||
|
styles: const PosStyles(bold: true, align: PosAlign.center));
|
||||||
|
bytes += generator.text(
|
||||||
|
paper == 80
|
||||||
|
? '------------------------------------------------'
|
||||||
|
: '--------------------------------',
|
||||||
|
styles: const PosStyles(bold: false, align: PosAlign.center));
|
||||||
|
for (final product
|
||||||
|
in (order.orderItems?.where((item) => item.status != 'cancelled') ??
|
||||||
|
<OrderItem>[])) {
|
||||||
|
bytes += generator.row([
|
||||||
|
PosColumn(
|
||||||
|
text: '${product.quantity} x ${product.productName}',
|
||||||
|
width: 8,
|
||||||
|
styles: const PosStyles(bold: true, align: PosAlign.left),
|
||||||
|
),
|
||||||
|
PosColumn(
|
||||||
|
text: (product.totalPrice ?? 0).currencyFormatRpV2,
|
||||||
|
width: 4,
|
||||||
|
styles: const PosStyles(bold: true, align: PosAlign.right),
|
||||||
|
),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
bytes += generator.text(
|
||||||
|
paper == 80
|
||||||
|
? '------------------------------------------------'
|
||||||
|
: '--------------------------------',
|
||||||
|
styles: const PosStyles(bold: false, align: PosAlign.center));
|
||||||
|
|
||||||
|
bytes += generator.row([
|
||||||
|
PosColumn(
|
||||||
|
text: 'Subtotal ${order.orderItems?.length ?? "0"} Product',
|
||||||
|
width: 6,
|
||||||
|
styles: const PosStyles(align: PosAlign.left),
|
||||||
|
),
|
||||||
|
PosColumn(
|
||||||
|
text: (order.subtotal ?? 0).currencyFormatRpV2,
|
||||||
|
width: 6,
|
||||||
|
styles: const PosStyles(align: PosAlign.right),
|
||||||
|
),
|
||||||
|
]);
|
||||||
|
|
||||||
|
bytes += generator.row([
|
||||||
|
PosColumn(
|
||||||
|
text: 'Discount',
|
||||||
|
width: 6,
|
||||||
|
styles: const PosStyles(align: PosAlign.left),
|
||||||
|
),
|
||||||
|
PosColumn(
|
||||||
|
text: (order.discountAmount ?? 0).currencyFormatRpV2,
|
||||||
|
width: 6,
|
||||||
|
styles: const PosStyles(align: PosAlign.right),
|
||||||
|
),
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Only show tax if it's greater than 0
|
||||||
|
if ((order.taxAmount ?? 0) > 0) {
|
||||||
|
bytes += generator.row([
|
||||||
|
PosColumn(
|
||||||
|
text: 'Tax PB1 ($taxPercentage%)',
|
||||||
|
width: 6,
|
||||||
|
styles: const PosStyles(align: PosAlign.left),
|
||||||
|
),
|
||||||
|
PosColumn(
|
||||||
|
text: (order.taxAmount ?? 0).currencyFormatRpV2,
|
||||||
|
width: 6,
|
||||||
|
styles: const PosStyles(align: PosAlign.right),
|
||||||
|
),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only show service charge if it's greater than 0
|
||||||
|
// if (serviceCharge > 0) {
|
||||||
|
// bytes += generator.row([
|
||||||
|
// PosColumn(
|
||||||
|
// text: 'Service Charge($serviceChargePercentage%)',
|
||||||
|
// width: 6,
|
||||||
|
// styles: const PosStyles(align: PosAlign.left),
|
||||||
|
// ),
|
||||||
|
// PosColumn(
|
||||||
|
// text: serviceCharge.currencyFormatRpV2,
|
||||||
|
// width: 6,
|
||||||
|
// styles: const PosStyles(align: PosAlign.right),
|
||||||
|
// ),
|
||||||
|
// ]);
|
||||||
|
// }
|
||||||
|
bytes += generator.text(
|
||||||
|
paper == 80
|
||||||
|
? '------------------------------------------------'
|
||||||
|
: '--------------------------------',
|
||||||
|
styles: const PosStyles(bold: false, align: PosAlign.center));
|
||||||
|
bytes += generator.row([
|
||||||
|
PosColumn(
|
||||||
|
text: 'Total',
|
||||||
|
width: 6,
|
||||||
|
styles: const PosStyles(bold: true, align: PosAlign.left),
|
||||||
|
),
|
||||||
|
PosColumn(
|
||||||
|
text: '${order.totalAmount ?? ""}'.currencyFormatRpV2,
|
||||||
|
width: 6,
|
||||||
|
styles: const PosStyles(bold: true, align: PosAlign.right),
|
||||||
|
),
|
||||||
|
]);
|
||||||
|
bytes += generator.row([
|
||||||
|
PosColumn(
|
||||||
|
text: 'Dibayar',
|
||||||
|
width: 6,
|
||||||
|
styles: const PosStyles(align: PosAlign.left),
|
||||||
|
),
|
||||||
|
PosColumn(
|
||||||
|
text: nominalBayar.currencyFormatRpV2,
|
||||||
|
width: 6,
|
||||||
|
styles: const PosStyles(align: PosAlign.right),
|
||||||
|
),
|
||||||
|
]);
|
||||||
|
bytes += generator.row([
|
||||||
|
PosColumn(
|
||||||
|
text: 'Kembali',
|
||||||
|
width: 6,
|
||||||
|
styles: const PosStyles(align: PosAlign.left),
|
||||||
|
),
|
||||||
|
PosColumn(
|
||||||
|
text: kembalian.currencyFormatRpV2,
|
||||||
|
width: 6,
|
||||||
|
styles: const PosStyles(align: PosAlign.right),
|
||||||
|
),
|
||||||
|
]);
|
||||||
|
bytes += generator.text(
|
||||||
|
paper == 80
|
||||||
|
? '------------------------------------------------'
|
||||||
|
: '--------------------------------',
|
||||||
|
styles: const PosStyles(bold: false, align: PosAlign.center));
|
||||||
|
// bytes += generator.text('Notes',
|
||||||
|
// styles: const PosStyles(bold: false, align: PosAlign.center));
|
||||||
|
// bytes += generator.text('Pass Wifi: fic14jilid2',
|
||||||
|
// styles: const PosStyles(bold: false, align: PosAlign.center));
|
||||||
|
// //terima kasih
|
||||||
|
// bytes += generator.text('Terima Kasih',
|
||||||
|
// styles: const PosStyles(bold: true, align: PosAlign.center));
|
||||||
|
paper == 80 ? bytes += generator.feed(3) : bytes += generator.feed(1);
|
||||||
|
bytes += generator.cut();
|
||||||
|
return bytes;
|
||||||
|
}
|
||||||
|
|
||||||
Future<List<int>> printQRIS(
|
Future<List<int>> printQRIS(
|
||||||
int totalPrice, Uint8List imageQris, int paper) async {
|
int totalPrice, Uint8List imageQris, int paper) async {
|
||||||
List<int> bytes = [];
|
List<int> bytes = [];
|
||||||
@@ -1140,4 +1403,39 @@ class PrintDataoutputs {
|
|||||||
|
|
||||||
return bytes;
|
return bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<List<int>> printTicket(
|
||||||
|
int totalPrice, Uint8List imageQris, int paper) async {
|
||||||
|
List<int> bytes = [];
|
||||||
|
|
||||||
|
final profile = await CapabilityProfile.load();
|
||||||
|
final generator =
|
||||||
|
Generator(paper == 58 ? PaperSize.mm58 : PaperSize.mm80, profile);
|
||||||
|
|
||||||
|
final img.Image? orginalImage = img.decodeImage(imageQris);
|
||||||
|
bytes += generator.reset();
|
||||||
|
|
||||||
|
// final Uint8List bytesData = data.buffer.asUint8List();
|
||||||
|
// final img.Image? orginalImage = img.decodeImage(bytesData);
|
||||||
|
// bytes += generator.reset();
|
||||||
|
|
||||||
|
bytes += generator.text('Scan Ticket',
|
||||||
|
styles: const PosStyles(bold: false, align: PosAlign.center));
|
||||||
|
bytes += generator.feed(2);
|
||||||
|
if (orginalImage != null) {
|
||||||
|
final img.Image grayscalledImage = img.grayscale(orginalImage);
|
||||||
|
final img.Image resizedImage =
|
||||||
|
img.copyResize(grayscalledImage, width: 240);
|
||||||
|
bytes += generator.imageRaster(resizedImage, align: PosAlign.center);
|
||||||
|
bytes += generator.feed(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
bytes += generator.text('Price : ${totalPrice.currencyFormatRp}',
|
||||||
|
styles: const PosStyles(bold: false, align: PosAlign.center));
|
||||||
|
|
||||||
|
bytes += generator.feed(4);
|
||||||
|
bytes += generator.cut();
|
||||||
|
|
||||||
|
return bytes;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -220,7 +220,8 @@ class OrderRemoteDatasource {
|
|||||||
return const Left('Gagal membuat pesanan');
|
return const Left('Gagal membuat pesanan');
|
||||||
}
|
}
|
||||||
} on DioException catch (e) {
|
} on DioException catch (e) {
|
||||||
final errorMessage = e.response?.data['message'] ?? 'Kesalahan jaringan';
|
final errorMessage =
|
||||||
|
e.response?.data['message'] ?? 'Terjadi kesalahan, coba lagi nanti.';
|
||||||
log("đź’Ą Dio error: ${e.message}");
|
log("đź’Ą Dio error: ${e.message}");
|
||||||
log("đź’Ą Dio response: ${e.response?.data}");
|
log("đź’Ą Dio response: ${e.response?.data}");
|
||||||
return Left(errorMessage);
|
return Left(errorMessage);
|
||||||
@@ -254,7 +255,8 @@ class OrderRemoteDatasource {
|
|||||||
return const Left('Gagal membuat pembayaran');
|
return const Left('Gagal membuat pembayaran');
|
||||||
}
|
}
|
||||||
} on DioException catch (e) {
|
} on DioException catch (e) {
|
||||||
final errorMessage = e.response?.data['message'] ?? 'Kesalahan jaringan';
|
final errorMessage =
|
||||||
|
e.response?.data['message'] ?? 'Terjadi kesalahan, coba lagi nanti.';
|
||||||
log("đź’Ą Dio error: ${e.message}");
|
log("đź’Ą Dio error: ${e.message}");
|
||||||
log("đź’Ą Dio response: ${e.response?.data}");
|
log("đź’Ą Dio response: ${e.response?.data}");
|
||||||
return Left(errorMessage);
|
return Left(errorMessage);
|
||||||
@@ -270,18 +272,26 @@ class OrderRemoteDatasource {
|
|||||||
String status = 'completed',
|
String status = 'completed',
|
||||||
required DateTime dateFrom,
|
required DateTime dateFrom,
|
||||||
required DateTime dateTo,
|
required DateTime dateTo,
|
||||||
|
String? search,
|
||||||
}) async {
|
}) async {
|
||||||
try {
|
try {
|
||||||
final authData = await AuthLocalDataSource().getAuthData();
|
final authData = await AuthLocalDataSource().getAuthData();
|
||||||
final response = await dio.get(
|
|
||||||
'${Variables.baseUrl}/api/v1/orders',
|
Map<String, dynamic> params = {
|
||||||
queryParameters: {
|
|
||||||
'page': page,
|
'page': page,
|
||||||
'limit': limit,
|
'limit': limit,
|
||||||
'status': status,
|
'status': status,
|
||||||
'date_from': DateFormat('dd-MM-yyyy').format(dateFrom),
|
'date_from': DateFormat('dd-MM-yyyy').format(dateFrom),
|
||||||
'date_to': DateFormat('dd-MM-yyyy').format(dateTo),
|
'date_to': DateFormat('dd-MM-yyyy').format(dateTo),
|
||||||
},
|
};
|
||||||
|
|
||||||
|
if (search != null && search.isNotEmpty) {
|
||||||
|
params['search'] = search;
|
||||||
|
}
|
||||||
|
|
||||||
|
final response = await dio.get(
|
||||||
|
'${Variables.baseUrl}/api/v1/orders',
|
||||||
|
queryParameters: params,
|
||||||
options: Options(
|
options: Options(
|
||||||
headers: {
|
headers: {
|
||||||
'Authorization': 'Bearer ${authData.token}',
|
'Authorization': 'Bearer ${authData.token}',
|
||||||
@@ -384,7 +394,8 @@ class OrderRemoteDatasource {
|
|||||||
return const Left('Gagal membuat pesanan');
|
return const Left('Gagal membuat pesanan');
|
||||||
}
|
}
|
||||||
} on DioException catch (e) {
|
} on DioException catch (e) {
|
||||||
final errorMessage = e.response?.data['message'] ?? 'Kesalahan jaringan';
|
final errorMessage =
|
||||||
|
e.response?.data['message'] ?? 'Terjadi kesalahan, coba lagi nanti.';
|
||||||
log("đź’Ą Dio error: ${e.message}");
|
log("đź’Ą Dio error: ${e.message}");
|
||||||
log("đź’Ą Dio response: ${e.response?.data}");
|
log("đź’Ą Dio response: ${e.response?.data}");
|
||||||
return Left(errorMessage);
|
return Left(errorMessage);
|
||||||
@@ -394,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 {
|
||||||
@@ -418,19 +429,19 @@ 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');
|
||||||
}
|
}
|
||||||
} on DioException catch (e) {
|
} on DioException catch (e) {
|
||||||
final errorMessage = e.response?.data['message'] ?? 'Kesalahan jaringan';
|
final errorMessage =
|
||||||
|
e.response?.data['message'] ?? 'Terjadi kesalahan, coba lagi nanti.';
|
||||||
log("đź’Ą Dio error: ${e.message}");
|
log("đź’Ą Dio error: ${e.message}");
|
||||||
log("đź’Ą Dio response: ${e.response?.data}");
|
log("đź’Ą Dio response: ${e.response?.data}");
|
||||||
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.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -476,7 +487,8 @@ class OrderRemoteDatasource {
|
|||||||
return const Left('Gagal refund');
|
return const Left('Gagal refund');
|
||||||
}
|
}
|
||||||
} on DioException catch (e) {
|
} on DioException catch (e) {
|
||||||
final errorMessage = e.response?.data['message'] ?? 'Kesalahan jaringan';
|
final errorMessage =
|
||||||
|
e.response?.data['message'] ?? 'Terjadi kesalahan, coba lagi nanti.';
|
||||||
log("đź’Ą Dio error: ${e.message}");
|
log("đź’Ą Dio error: ${e.message}");
|
||||||
log("đź’Ą Dio response: ${e.response?.data}");
|
log("đź’Ą Dio response: ${e.response?.data}");
|
||||||
return Left(errorMessage);
|
return Left(errorMessage);
|
||||||
@@ -524,7 +536,8 @@ class OrderRemoteDatasource {
|
|||||||
return const Left('Gagal refund');
|
return const Left('Gagal refund');
|
||||||
}
|
}
|
||||||
} on DioException catch (e) {
|
} on DioException catch (e) {
|
||||||
final errorMessage = e.response?.data['message'] ?? 'Kesalahan jaringan';
|
final errorMessage =
|
||||||
|
e.response?.data['message'] ?? 'Terjadi kesalahan, coba lagi nanti.';
|
||||||
log("đź’Ą Dio error: ${e.message}");
|
log("đź’Ą Dio error: ${e.message}");
|
||||||
log("đź’Ą Dio response: ${e.response?.data}");
|
log("đź’Ą Dio response: ${e.response?.data}");
|
||||||
return Left(errorMessage);
|
return Left(errorMessage);
|
||||||
@@ -573,4 +586,39 @@ class OrderRemoteDatasource {
|
|||||||
return const Left('Terjadi kesalahan tak terduga');
|
return const Left('Terjadi kesalahan tak terduga');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<Either<String, PaymentSuccessResponseModel>> createPaymentSplitBill(
|
||||||
|
PaymentSplitBillRequest request) async {
|
||||||
|
final authData = await AuthLocalDataSource().getAuthData();
|
||||||
|
final url = '${Variables.baseUrl}/api/v1/orders/split-bill';
|
||||||
|
|
||||||
|
try {
|
||||||
|
final response = await dio.post(
|
||||||
|
url,
|
||||||
|
data: request.toMap(),
|
||||||
|
options: Options(
|
||||||
|
headers: {
|
||||||
|
'Authorization': 'Bearer ${authData.token}',
|
||||||
|
'Accept': 'application/json',
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
if (response.statusCode == 200) {
|
||||||
|
return Right(PaymentSuccessResponseModel.fromMap(response.data));
|
||||||
|
} else {
|
||||||
|
return const Left('Gagal membuat pembayaran');
|
||||||
|
}
|
||||||
|
} on DioException catch (e) {
|
||||||
|
final errorMessage =
|
||||||
|
e.response?.data['message'] ?? 'Terjadi kesalahan, coba lagi nanti.';
|
||||||
|
log("đź’Ą Dio error: ${e.message}");
|
||||||
|
log("đź’Ą Dio response: ${e.response?.data}");
|
||||||
|
return Left(errorMessage);
|
||||||
|
} catch (e) {
|
||||||
|
log("đź’Ą Unexpected error: $e");
|
||||||
|
return const Left('Terjadi kesalahan tak terduga');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
import 'dart:developer';
|
||||||
|
|
||||||
|
import 'package:enaklo_pos/presentation/home/models/outlet_model.dart';
|
||||||
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
|
class OutletLocalDatasource {
|
||||||
|
Future<void> save(Outlet outlet) async {
|
||||||
|
try {
|
||||||
|
final prefs = await SharedPreferences.getInstance();
|
||||||
|
await prefs.setString('outlet', outlet.toJson());
|
||||||
|
log('Outlet Local Data: ${outlet.toJson()}');
|
||||||
|
} catch (e) {
|
||||||
|
log('Error saving outlet: $e');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> remove() async {
|
||||||
|
final prefs = await SharedPreferences.getInstance();
|
||||||
|
await prefs.remove('outlet');
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<Outlet> get() async {
|
||||||
|
final prefs = await SharedPreferences.getInstance();
|
||||||
|
final outlet = prefs.getString('outlet');
|
||||||
|
|
||||||
|
log('Outlet Local Data: $outlet');
|
||||||
|
|
||||||
|
return Outlet.fromJson(outlet!);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,7 +2,10 @@ import 'dart:developer';
|
|||||||
import 'package:dartz/dartz.dart';
|
import 'package:dartz/dartz.dart';
|
||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
import 'package:enaklo_pos/core/network/dio_client.dart';
|
import 'package:enaklo_pos/core/network/dio_client.dart';
|
||||||
|
import 'package:enaklo_pos/data/datasources/outlet_local_datasource.dart';
|
||||||
|
import 'package:enaklo_pos/data/datasources/settings_local_datasource.dart';
|
||||||
import 'package:enaklo_pos/presentation/home/models/outlet_model.dart';
|
import 'package:enaklo_pos/presentation/home/models/outlet_model.dart';
|
||||||
|
import 'package:enaklo_pos/presentation/setting/models/tax_model.dart';
|
||||||
import '../../core/constants/variables.dart';
|
import '../../core/constants/variables.dart';
|
||||||
import 'auth_local_datasource.dart';
|
import 'auth_local_datasource.dart';
|
||||||
|
|
||||||
@@ -12,6 +15,7 @@ class OutletRemoteDataSource {
|
|||||||
Future<Either<String, OutletResponse>> getOutlets() async {
|
Future<Either<String, OutletResponse>> getOutlets() async {
|
||||||
try {
|
try {
|
||||||
final authData = await AuthLocalDataSource().getAuthData();
|
final authData = await AuthLocalDataSource().getAuthData();
|
||||||
|
|
||||||
final url = '${Variables.baseUrl}/api/v1/outlets/list';
|
final url = '${Variables.baseUrl}/api/v1/outlets/list';
|
||||||
|
|
||||||
final response = await dio.get(
|
final response = await dio.get(
|
||||||
@@ -28,7 +32,8 @@ class OutletRemoteDataSource {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
return Right(OutletResponse.fromMap(response.data));
|
final data = OutletResponse.fromMap(response.data);
|
||||||
|
return Right(data);
|
||||||
} else {
|
} else {
|
||||||
return const Left('Failed to get outlets');
|
return const Left('Failed to get outlets');
|
||||||
}
|
}
|
||||||
@@ -66,7 +71,17 @@ class OutletRemoteDataSource {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
return Right(OutletDetailResponse.fromMap(response.data));
|
final data = OutletDetailResponse.fromMap(response.data);
|
||||||
|
await SettingsLocalDatasource().saveTax(
|
||||||
|
TaxModel(
|
||||||
|
name: 'PB1',
|
||||||
|
type: TaxType.pajak,
|
||||||
|
value: data.data?.taxRate ?? 0,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
await OutletLocalDatasource().save(data.data!);
|
||||||
|
return Right(data);
|
||||||
} else {
|
} else {
|
||||||
return const Left('Failed to get outlets');
|
return const Left('Failed to get outlets');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ class ProductRemoteDatasource {
|
|||||||
int page = 1,
|
int page = 1,
|
||||||
int limit = Variables.defaultLimit,
|
int limit = Variables.defaultLimit,
|
||||||
String? categoryId,
|
String? categoryId,
|
||||||
|
String? search,
|
||||||
}) async {
|
}) async {
|
||||||
try {
|
try {
|
||||||
final authData = await AuthLocalDataSource().getAuthData();
|
final authData = await AuthLocalDataSource().getAuthData();
|
||||||
@@ -31,6 +32,10 @@ class ProductRemoteDatasource {
|
|||||||
queryParameters['category_id'] = categoryId;
|
queryParameters['category_id'] = categoryId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (search != null && search.isNotEmpty) {
|
||||||
|
queryParameters['search'] = search;
|
||||||
|
}
|
||||||
|
|
||||||
final response = await dio.get(
|
final response = await dio.get(
|
||||||
url,
|
url,
|
||||||
queryParameters: queryParameters,
|
queryParameters: queryParameters,
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ class TableRemoteDataSource {
|
|||||||
|
|
||||||
Future<Either<String, TableResponseModel>> getTable({
|
Future<Either<String, TableResponseModel>> getTable({
|
||||||
int page = 1,
|
int page = 1,
|
||||||
int limit = 10,
|
int limit = 50,
|
||||||
String? status,
|
String? status,
|
||||||
}) async {
|
}) async {
|
||||||
try {
|
try {
|
||||||
@@ -131,4 +131,40 @@ class TableRemoteDataSource {
|
|||||||
return const Left('Unexpected error occurred');
|
return const Left('Unexpected error occurred');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<Either<String, bool>> transferTable({
|
||||||
|
required String fromTableId,
|
||||||
|
required String toTableId,
|
||||||
|
}) async {
|
||||||
|
try {
|
||||||
|
final authData = await AuthLocalDataSource().getAuthData();
|
||||||
|
final url = '${Variables.baseUrl}/api/v1/tables/transfer';
|
||||||
|
|
||||||
|
final response = await dio.put(
|
||||||
|
url,
|
||||||
|
data: {
|
||||||
|
"from_table": fromTableId,
|
||||||
|
"to_table": toTableId,
|
||||||
|
},
|
||||||
|
options: Options(
|
||||||
|
headers: {
|
||||||
|
'Authorization': 'Bearer ${authData.token}',
|
||||||
|
'Accept': 'application/json',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
if (response.statusCode == 200 || response.statusCode == 201) {
|
||||||
|
return Right(true);
|
||||||
|
} else {
|
||||||
|
return const Left('Failed to create table');
|
||||||
|
}
|
||||||
|
} on DioException catch (e) {
|
||||||
|
log("Dio error: ${e.message}");
|
||||||
|
return Left(e.response?.data['message'] ?? 'Gagal membuat table');
|
||||||
|
} catch (e) {
|
||||||
|
log("Unexpected error: $e");
|
||||||
|
return const Left('Unexpected error occurred');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,3 +78,60 @@ class PaymentOrderItemModel {
|
|||||||
"amount": amount,
|
"amount": amount,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class PaymentSplitBillRequest {
|
||||||
|
final String orderId;
|
||||||
|
final String paymentMethodId;
|
||||||
|
final String customerId;
|
||||||
|
final String type; // e.g., "AMOUNT" or "ITEM"
|
||||||
|
final int amount;
|
||||||
|
final List<SplitItem> items;
|
||||||
|
|
||||||
|
PaymentSplitBillRequest({
|
||||||
|
required this.orderId,
|
||||||
|
required this.paymentMethodId,
|
||||||
|
required this.customerId,
|
||||||
|
required this.type,
|
||||||
|
required this.amount,
|
||||||
|
required this.items,
|
||||||
|
});
|
||||||
|
|
||||||
|
Map<String, dynamic> toMap() {
|
||||||
|
Map<String, dynamic> data = {
|
||||||
|
'order_id': orderId,
|
||||||
|
'payment_method_id': paymentMethodId,
|
||||||
|
'type': type,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (customerId.isNotEmpty) {
|
||||||
|
data['customer_id'] = customerId;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type == "AMOUNT") {
|
||||||
|
data['amount'] = amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type == "ITEM") {
|
||||||
|
data['items'] = items.map((e) => e.toJson()).toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class SplitItem {
|
||||||
|
final String orderItemId;
|
||||||
|
final int quantity;
|
||||||
|
|
||||||
|
SplitItem({
|
||||||
|
required this.orderItemId,
|
||||||
|
required this.quantity,
|
||||||
|
});
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
return {
|
||||||
|
'order_item_id': orderItemId,
|
||||||
|
'quantity': quantity,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -59,11 +59,17 @@ 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
|
||||||
|
? []
|
||||||
|
: List<TopProduct>.from(
|
||||||
map['top_products']?.map((x) => TopProduct.fromMap(x))),
|
map['top_products']?.map((x) => TopProduct.fromMap(x))),
|
||||||
paymentMethods: List<PaymentMethodAnalytic>.from(map['payment_methods']
|
paymentMethods: map['payment_methods'] == null
|
||||||
|
? []
|
||||||
|
: List<PaymentMethodAnalytic>.from(map['payment_methods']
|
||||||
?.map((x) => PaymentMethodAnalytic.fromMap(x))),
|
?.map((x) => PaymentMethodAnalytic.fromMap(x))),
|
||||||
recentSales: List<RecentSale>.from(
|
recentSales: map['recent_sales'] == null
|
||||||
|
? []
|
||||||
|
: List<RecentSale>.from(
|
||||||
map['recent_sales']?.map((x) => RecentSale.fromMap(x))),
|
map['recent_sales']?.map((x) => RecentSale.fromMap(x))),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -1,35 +1,5 @@
|
|||||||
import 'dart:convert';
|
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 OrderDetailResponseModel {
|
class OrderDetailResponseModel {
|
||||||
final bool? success;
|
final bool? success;
|
||||||
final Order? data;
|
final Order? data;
|
||||||
@@ -60,41 +30,78 @@ class OrderDetailResponseModel {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class OrderResponseModel {
|
||||||
|
final bool? success;
|
||||||
|
final OrderData? data;
|
||||||
|
|
||||||
|
OrderResponseModel({
|
||||||
|
this.success,
|
||||||
|
this.data,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory OrderResponseModel.fromJson(String str) =>
|
||||||
|
OrderResponseModel.fromMap(json.decode(str));
|
||||||
|
|
||||||
|
String toJson() => json.encode(toMap());
|
||||||
|
|
||||||
|
factory OrderResponseModel.fromMap(Map<String, dynamic> map) {
|
||||||
|
return OrderResponseModel(
|
||||||
|
success: map['success'] ?? false,
|
||||||
|
data: OrderData.fromMap(map['data']),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toMap() {
|
||||||
|
return {
|
||||||
|
'success': success,
|
||||||
|
'data': data?.toMap(),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class OrderData {
|
class OrderData {
|
||||||
final List<Order>? orders;
|
final List<Order>? orders;
|
||||||
|
final List<Payment>? payments;
|
||||||
final int? totalCount;
|
final int? totalCount;
|
||||||
final int? page;
|
final int? page;
|
||||||
final int? limit;
|
final int? limit;
|
||||||
final int? totalPages;
|
final int? totalPages;
|
||||||
|
|
||||||
OrderData({
|
OrderData({
|
||||||
this.orders,
|
required this.orders,
|
||||||
this.totalCount,
|
required this.payments,
|
||||||
this.page,
|
required this.totalCount,
|
||||||
this.limit,
|
required this.page,
|
||||||
this.totalPages,
|
required this.limit,
|
||||||
|
required this.totalPages,
|
||||||
});
|
});
|
||||||
|
|
||||||
factory OrderData.fromMap(Map<String, dynamic> json) => OrderData(
|
factory OrderData.fromMap(Map<String, dynamic> map) {
|
||||||
orders: json["orders"] == null
|
return OrderData(
|
||||||
|
orders: map["orders"] == null
|
||||||
? []
|
? []
|
||||||
: List<Order>.from(json["orders"].map((x) => Order.fromMap(x))),
|
: List<Order>.from(map['orders']?.map((x) => Order.fromMap(x))),
|
||||||
totalCount: json["total_count"],
|
payments: map["payments"] == null
|
||||||
page: json["page"],
|
? []
|
||||||
limit: json["limit"],
|
: List<Payment>.from(map['payments']?.map((x) => Payment.fromMap(x))),
|
||||||
totalPages: json["total_pages"],
|
totalCount: map['total_count'],
|
||||||
|
page: map['page'],
|
||||||
|
limit: map['limit'],
|
||||||
|
totalPages: map['total_pages'],
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Map<String, dynamic> toMap() => {
|
Map<String, dynamic> toMap() {
|
||||||
"orders": orders == null
|
return {
|
||||||
? []
|
'orders': orders?.map((x) => x.toMap()).toList(),
|
||||||
: List<dynamic>.from(orders!.map((x) => x.toMap())),
|
'payments': payments?.map((x) => x.toMap()).toList(),
|
||||||
"total_count": totalCount,
|
'total_count': totalCount,
|
||||||
"page": page,
|
'page': page,
|
||||||
"limit": limit,
|
'limit': limit,
|
||||||
"total_pages": totalPages,
|
'total_pages': totalPages,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class Order {
|
class Order {
|
||||||
final String? id;
|
final String? id;
|
||||||
@@ -108,11 +115,21 @@ class Order {
|
|||||||
final int? taxAmount;
|
final int? taxAmount;
|
||||||
final int? discountAmount;
|
final int? discountAmount;
|
||||||
final int? totalAmount;
|
final int? totalAmount;
|
||||||
|
final int? totalCost;
|
||||||
|
final int? remainingAmount;
|
||||||
|
final String? paymentStatus;
|
||||||
|
final int? refundAmount;
|
||||||
|
final bool? isVoid;
|
||||||
|
final bool? isRefund;
|
||||||
final String? notes;
|
final String? notes;
|
||||||
final Map<String, dynamic>? metadata;
|
final Map<String, dynamic>? metadata;
|
||||||
final DateTime? createdAt;
|
final DateTime? createdAt;
|
||||||
final DateTime? updatedAt;
|
final DateTime? updatedAt;
|
||||||
final List<OrderItem>? orderItems;
|
final List<OrderItem>? orderItems;
|
||||||
|
final List<Payment>? payments;
|
||||||
|
final int? totalPaid;
|
||||||
|
final int? paymentCount;
|
||||||
|
final String? splitType;
|
||||||
|
|
||||||
Order({
|
Order({
|
||||||
this.id,
|
this.id,
|
||||||
@@ -126,76 +143,108 @@ class Order {
|
|||||||
this.taxAmount,
|
this.taxAmount,
|
||||||
this.discountAmount,
|
this.discountAmount,
|
||||||
this.totalAmount,
|
this.totalAmount,
|
||||||
|
this.totalCost,
|
||||||
|
this.remainingAmount,
|
||||||
|
this.paymentStatus,
|
||||||
|
this.refundAmount,
|
||||||
|
this.isVoid,
|
||||||
|
this.isRefund,
|
||||||
this.notes,
|
this.notes,
|
||||||
this.metadata,
|
this.metadata,
|
||||||
this.createdAt,
|
this.createdAt,
|
||||||
this.updatedAt,
|
this.updatedAt,
|
||||||
this.orderItems,
|
this.orderItems,
|
||||||
|
this.payments,
|
||||||
|
this.totalPaid,
|
||||||
|
this.paymentCount,
|
||||||
|
this.splitType,
|
||||||
});
|
});
|
||||||
|
|
||||||
factory Order.fromMap(Map<String, dynamic> json) => Order(
|
factory Order.fromMap(Map<String, dynamic> map) {
|
||||||
id: json["id"],
|
return Order(
|
||||||
orderNumber: json["order_number"],
|
id: map['id'],
|
||||||
outletId: json["outlet_id"],
|
orderNumber: map['order_number'],
|
||||||
userId: json["user_id"],
|
outletId: map['outlet_id'],
|
||||||
tableNumber: json["table_number"],
|
userId: map['user_id'],
|
||||||
orderType: json["order_type"],
|
tableNumber: map['table_number'],
|
||||||
status: json["status"],
|
orderType: map['order_type'],
|
||||||
subtotal: json["subtotal"],
|
status: map['status'],
|
||||||
taxAmount: json["tax_amount"],
|
subtotal: map['subtotal'],
|
||||||
discountAmount: json["discount_amount"],
|
taxAmount: map['tax_amount'],
|
||||||
totalAmount: json["total_amount"],
|
discountAmount: map['discount_amount'],
|
||||||
notes: json["notes"],
|
totalAmount: map['total_amount'],
|
||||||
metadata: json["metadata"] ?? {},
|
totalCost: map['total_cost'],
|
||||||
createdAt: json["created_at"] == null
|
remainingAmount: map['remaining_amount'],
|
||||||
? null
|
paymentStatus: map['payment_status'],
|
||||||
: DateTime.parse(json["created_at"]),
|
refundAmount: map['refund_amount'],
|
||||||
updatedAt: json["updated_at"] == null
|
isVoid: map['is_void'],
|
||||||
? null
|
isRefund: map['is_refund'],
|
||||||
: DateTime.parse(json["updated_at"]),
|
notes: map['notes'],
|
||||||
orderItems: json["order_items"] == null
|
metadata: map['metadata'] ?? {},
|
||||||
|
createdAt: DateTime.parse(map['created_at']),
|
||||||
|
updatedAt: DateTime.parse(map['updated_at']),
|
||||||
|
orderItems: map["order_items"] == null
|
||||||
? []
|
? []
|
||||||
: List<OrderItem>.from(
|
: List<OrderItem>.from(
|
||||||
json["order_items"].map((x) => OrderItem.fromMap(x))),
|
map['order_items'].map((x) => OrderItem.fromMap(x))),
|
||||||
);
|
payments: map["payments"] == null
|
||||||
|
|
||||||
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())),
|
: List<Payment>.from(map['payments'].map((x) => Payment.fromMap(x))),
|
||||||
|
totalPaid: map['total_paid'],
|
||||||
|
paymentCount: map['payment_count'],
|
||||||
|
splitType: map['split_type'] ?? "",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toMap() {
|
||||||
|
return {
|
||||||
|
'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,
|
||||||
|
'total_cost': totalCost,
|
||||||
|
'remaining_amount': remainingAmount,
|
||||||
|
'payment_status': paymentStatus,
|
||||||
|
'refund_amount': refundAmount,
|
||||||
|
'is_void': isVoid,
|
||||||
|
'is_refund': isRefund,
|
||||||
|
'notes': notes,
|
||||||
|
'metadata': metadata,
|
||||||
|
'created_at': createdAt?.toIso8601String(),
|
||||||
|
'updated_at': updatedAt?.toIso8601String(),
|
||||||
|
'order_items': orderItems?.map((x) => x.toMap()).toList(),
|
||||||
|
'payments': payments?.map((x) => x.toMap()).toList(),
|
||||||
|
'total_paid': totalPaid,
|
||||||
|
'payment_count': paymentCount,
|
||||||
|
'split_type': splitType,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class OrderItem {
|
class OrderItem {
|
||||||
final String? id;
|
String? id;
|
||||||
final String? orderId;
|
String? orderId;
|
||||||
final String? productId;
|
String? productId;
|
||||||
final String? productName;
|
String? productName;
|
||||||
final String? productVariantId;
|
String? productVariantId;
|
||||||
final String? productVariantName;
|
String? productVariantName;
|
||||||
final int? quantity;
|
int? quantity;
|
||||||
final int? unitPrice;
|
int? unitPrice;
|
||||||
final int? totalPrice;
|
int? totalPrice;
|
||||||
final List<dynamic>? modifiers;
|
List<dynamic>? modifiers;
|
||||||
final String? notes;
|
String? notes;
|
||||||
final String? status;
|
String? status;
|
||||||
final DateTime? createdAt;
|
DateTime? createdAt;
|
||||||
final DateTime? updatedAt;
|
DateTime? updatedAt;
|
||||||
|
String? printerType;
|
||||||
|
int? paidQuantity;
|
||||||
|
|
||||||
OrderItem({
|
OrderItem({
|
||||||
this.id,
|
this.id,
|
||||||
@@ -212,43 +261,122 @@ class OrderItem {
|
|||||||
this.status,
|
this.status,
|
||||||
this.createdAt,
|
this.createdAt,
|
||||||
this.updatedAt,
|
this.updatedAt,
|
||||||
|
this.printerType,
|
||||||
|
this.paidQuantity,
|
||||||
});
|
});
|
||||||
|
|
||||||
factory OrderItem.fromMap(Map<String, dynamic> json) => OrderItem(
|
factory OrderItem.fromMap(Map<String, dynamic> map) {
|
||||||
id: json["id"],
|
return OrderItem(
|
||||||
orderId: json["order_id"],
|
id: map['id'],
|
||||||
productId: json["product_id"],
|
orderId: map['order_id'],
|
||||||
productName: json["product_name"],
|
productId: map['product_id'],
|
||||||
productVariantId: json["product_variant_id"],
|
productName: map['product_name'],
|
||||||
productVariantName: json["product_variant_name"],
|
productVariantId: map['product_variant_id'],
|
||||||
quantity: json["quantity"],
|
productVariantName: map['product_variant_name'],
|
||||||
unitPrice: json["unit_price"],
|
quantity: map['quantity'],
|
||||||
totalPrice: json["total_price"],
|
unitPrice: map['unit_price'],
|
||||||
modifiers: json["modifiers"] ?? [],
|
totalPrice: map['total_price'],
|
||||||
notes: json["notes"],
|
modifiers:
|
||||||
status: json["status"],
|
map['modifiers'] == null ? [] : List<dynamic>.from(map['modifiers']),
|
||||||
createdAt: json["created_at"] == null
|
notes: map['notes'],
|
||||||
? null
|
status: map['status'],
|
||||||
: DateTime.parse(json["created_at"]),
|
createdAt: DateTime.parse(map['created_at']),
|
||||||
updatedAt: json["updated_at"] == null
|
updatedAt: DateTime.parse(map['updated_at']),
|
||||||
? null
|
printerType: map['printer_type'],
|
||||||
: DateTime.parse(json["updated_at"]),
|
paidQuantity: map['paid_quantity'],
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Map<String, dynamic> toMap() => {
|
Map<String, dynamic> toMap() {
|
||||||
"id": id,
|
return {
|
||||||
"order_id": orderId,
|
'id': id,
|
||||||
"product_id": productId,
|
'order_id': orderId,
|
||||||
"product_name": productName,
|
'product_id': productId,
|
||||||
"product_variant_id": productVariantId,
|
'product_name': productName,
|
||||||
"product_variant_name": productVariantName,
|
'product_variant_id': productVariantId,
|
||||||
"quantity": quantity,
|
'product_variant_name': productVariantName,
|
||||||
"unit_price": unitPrice,
|
'quantity': quantity,
|
||||||
"total_price": totalPrice,
|
'unit_price': unitPrice,
|
||||||
"modifiers": modifiers,
|
'total_price': totalPrice,
|
||||||
"notes": notes,
|
'modifiers': modifiers,
|
||||||
"status": status,
|
'notes': notes,
|
||||||
"created_at": createdAt?.toIso8601String(),
|
'status': status,
|
||||||
"updated_at": updatedAt?.toIso8601String(),
|
'created_at': createdAt?.toIso8601String(),
|
||||||
|
'updated_at': updatedAt?.toIso8601String(),
|
||||||
|
'printer_type': printerType,
|
||||||
|
'paid_quantity': paidQuantity,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Payment {
|
||||||
|
final String? id;
|
||||||
|
final String? orderId;
|
||||||
|
final String? paymentMethodId;
|
||||||
|
final String? paymentMethodName;
|
||||||
|
final String? paymentMethodType;
|
||||||
|
final int? amount;
|
||||||
|
final String? status;
|
||||||
|
final int? splitNumber;
|
||||||
|
final int? splitTotal;
|
||||||
|
final String? splitDescription;
|
||||||
|
final int? refundAmount;
|
||||||
|
final Map<String, dynamic>? metadata;
|
||||||
|
final DateTime? createdAt;
|
||||||
|
final DateTime? updatedAt;
|
||||||
|
|
||||||
|
Payment({
|
||||||
|
this.id,
|
||||||
|
this.orderId,
|
||||||
|
this.paymentMethodId,
|
||||||
|
this.paymentMethodName,
|
||||||
|
this.paymentMethodType,
|
||||||
|
this.amount,
|
||||||
|
this.status,
|
||||||
|
this.splitNumber,
|
||||||
|
this.splitTotal,
|
||||||
|
this.splitDescription,
|
||||||
|
this.refundAmount,
|
||||||
|
this.metadata,
|
||||||
|
this.createdAt,
|
||||||
|
this.updatedAt,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory Payment.fromMap(Map<String, dynamic> map) {
|
||||||
|
return Payment(
|
||||||
|
id: map['id'],
|
||||||
|
orderId: map['order_id'],
|
||||||
|
paymentMethodId: map['payment_method_id'],
|
||||||
|
paymentMethodName: map['payment_method_name'],
|
||||||
|
paymentMethodType: map['payment_method_type'],
|
||||||
|
amount: map['amount'],
|
||||||
|
status: map['status'],
|
||||||
|
splitNumber: map['split_number'],
|
||||||
|
splitTotal: map['split_total'],
|
||||||
|
splitDescription: map['split_description'],
|
||||||
|
refundAmount: map['refund_amount'],
|
||||||
|
metadata: map['metadata'] ?? {},
|
||||||
|
createdAt: DateTime.parse(map['created_at']),
|
||||||
|
updatedAt: DateTime.parse(map['updated_at']),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toMap() {
|
||||||
|
return {
|
||||||
|
'id': id,
|
||||||
|
'order_id': orderId,
|
||||||
|
'payment_method_id': paymentMethodId,
|
||||||
|
'payment_method_name': paymentMethodName,
|
||||||
|
'payment_method_type': paymentMethodType,
|
||||||
|
'amount': amount,
|
||||||
|
'status': status,
|
||||||
|
'split_number': splitNumber,
|
||||||
|
'split_total': splitTotal,
|
||||||
|
'split_description': splitDescription,
|
||||||
|
'refund_amount': refundAmount,
|
||||||
|
'metadata': metadata,
|
||||||
|
'created_at': createdAt?.toIso8601String(),
|
||||||
|
'updated_at': updatedAt?.toIso8601String(),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -64,8 +64,11 @@ 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)) ??
|
||||||
|
[],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,7 +52,9 @@ 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
|
||||||
|
? []
|
||||||
|
: List<ProductAnalyticItem>.from(
|
||||||
map['data'].map((x) => ProductAnalyticItem.fromMap(x)),
|
map['data'].map((x) => ProductAnalyticItem.fromMap(x)),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -72,9 +72,13 @@ class ProfitLossData {
|
|||||||
dateTo: map['date_to'],
|
dateTo: map['date_to'],
|
||||||
groupBy: map['group_by'],
|
groupBy: map['group_by'],
|
||||||
summary: ProfitLossSummary.fromMap(map['summary']),
|
summary: ProfitLossSummary.fromMap(map['summary']),
|
||||||
data: List<ProfitLossItem>.from(
|
data: map['data'] == null
|
||||||
|
? []
|
||||||
|
: List<ProfitLossItem>.from(
|
||||||
map['data'].map((x) => ProfitLossItem.fromMap(x))),
|
map['data'].map((x) => ProfitLossItem.fromMap(x))),
|
||||||
productData: List<ProfitLossProduct>.from(
|
productData: map['product_data'] == null
|
||||||
|
? []
|
||||||
|
: List<ProfitLossProduct>.from(
|
||||||
map['product_data'].map((x) => ProfitLossProduct.fromMap(x))),
|
map['product_data'].map((x) => ProfitLossProduct.fromMap(x))),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
enum BusinessType {
|
||||||
|
restaurant('restaurant'),
|
||||||
|
retail('retail'),
|
||||||
|
service('service'),
|
||||||
|
ticketing('ticketing'),
|
||||||
|
entertainment('entertainment');
|
||||||
|
|
||||||
|
final String value;
|
||||||
|
const BusinessType(this.value);
|
||||||
|
|
||||||
|
static BusinessType fromString(String value) {
|
||||||
|
return BusinessType.values.firstWhere(
|
||||||
|
(type) => type.value == value,
|
||||||
|
orElse: () => BusinessType.restaurant,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
import 'dart:developer';
|
import 'dart:developer';
|
||||||
import 'package:enaklo_pos/core/constants/theme.dart';
|
import 'package:enaklo_pos/core/constants/theme.dart';
|
||||||
|
import 'package:enaklo_pos/core/network/dio_client.dart';
|
||||||
import 'package:enaklo_pos/data/datasources/analytic_remote_datasource.dart';
|
import 'package:enaklo_pos/data/datasources/analytic_remote_datasource.dart';
|
||||||
import 'package:enaklo_pos/data/datasources/customer_remote_datasource.dart';
|
import 'package:enaklo_pos/data/datasources/customer_remote_datasource.dart';
|
||||||
import 'package:enaklo_pos/data/datasources/file_remote_datasource.dart';
|
import 'package:enaklo_pos/data/datasources/file_remote_datasource.dart';
|
||||||
@@ -18,7 +19,9 @@ import 'package:enaklo_pos/presentation/refund/bloc/refund_bloc.dart';
|
|||||||
import 'package:enaklo_pos/presentation/report/blocs/profit_loss/profit_loss_bloc.dart';
|
import 'package:enaklo_pos/presentation/report/blocs/profit_loss/profit_loss_bloc.dart';
|
||||||
import 'package:enaklo_pos/presentation/sales/blocs/order_loader/order_loader_bloc.dart';
|
import 'package:enaklo_pos/presentation/sales/blocs/order_loader/order_loader_bloc.dart';
|
||||||
import 'package:enaklo_pos/presentation/sales/blocs/payment_form/payment_form_bloc.dart';
|
import 'package:enaklo_pos/presentation/sales/blocs/payment_form/payment_form_bloc.dart';
|
||||||
|
import 'package:enaklo_pos/presentation/setting/bloc/get_printer_ticket/get_printer_ticket_bloc.dart';
|
||||||
import 'package:enaklo_pos/presentation/setting/bloc/upload_file/upload_file_bloc.dart';
|
import 'package:enaklo_pos/presentation/setting/bloc/upload_file/upload_file_bloc.dart';
|
||||||
|
import 'package:enaklo_pos/presentation/table/blocs/transfer_table/transfer_table_bloc.dart';
|
||||||
import 'package:enaklo_pos/presentation/void/bloc/void_order_bloc.dart';
|
import 'package:enaklo_pos/presentation/void/bloc/void_order_bloc.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:enaklo_pos/data/datasources/auth_local_datasource.dart';
|
import 'package:enaklo_pos/data/datasources/auth_local_datasource.dart';
|
||||||
@@ -279,8 +282,15 @@ class _MyAppState extends State<MyApp> {
|
|||||||
BlocProvider(
|
BlocProvider(
|
||||||
create: (context) => CategoryLoaderBloc(CategoryRemoteDatasource()),
|
create: (context) => CategoryLoaderBloc(CategoryRemoteDatasource()),
|
||||||
),
|
),
|
||||||
|
BlocProvider(
|
||||||
|
create: (context) => GetPrinterTicketBloc(),
|
||||||
|
),
|
||||||
|
BlocProvider(
|
||||||
|
create: (context) => TransferTableBloc(TableRemoteDataSource()),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
child: MaterialApp(
|
child: MaterialApp(
|
||||||
|
navigatorKey: AuthInterceptor.navigatorKey,
|
||||||
debugShowCheckedModeBanner: false,
|
debugShowCheckedModeBanner: false,
|
||||||
title: 'POS Resto App',
|
title: 'POS Resto App',
|
||||||
theme: getApplicationTheme,
|
theme: getApplicationTheme,
|
||||||
|
|||||||
@@ -30,11 +30,6 @@ class CustomerTitle extends StatelessWidget {
|
|||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
IconButton(
|
|
||||||
onPressed: () => context.pop(),
|
|
||||||
icon: Icon(Icons.arrow_back, color: AppColors.black),
|
|
||||||
),
|
|
||||||
SpaceWidth(16),
|
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Text(
|
child: Text(
|
||||||
title,
|
title,
|
||||||
|
|||||||
@@ -30,9 +30,14 @@ class CategoryLoaderBloc
|
|||||||
updatedAt: DateTime.now(),
|
updatedAt: DateTime.now(),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
emit(_Loaded(categories));
|
emit(_Loaded(categories, null));
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
on<_SetCategoryId>((event, emit) async {
|
||||||
|
var currentState = state as _Loaded;
|
||||||
|
|
||||||
|
emit(_Loaded(currentState.categories, event.categoryId));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,32 +19,38 @@ mixin _$CategoryLoaderEvent {
|
|||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult when<TResult extends Object?>({
|
TResult when<TResult extends Object?>({
|
||||||
required TResult Function() get,
|
required TResult Function() get,
|
||||||
|
required TResult Function(String categoryId) setCategoryId,
|
||||||
}) =>
|
}) =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult? whenOrNull<TResult extends Object?>({
|
TResult? whenOrNull<TResult extends Object?>({
|
||||||
TResult? Function()? get,
|
TResult? Function()? get,
|
||||||
|
TResult? Function(String categoryId)? setCategoryId,
|
||||||
}) =>
|
}) =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
TResult maybeWhen<TResult extends Object?>({
|
||||||
TResult Function()? get,
|
TResult Function()? get,
|
||||||
|
TResult Function(String categoryId)? setCategoryId,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) =>
|
}) =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult map<TResult extends Object?>({
|
TResult map<TResult extends Object?>({
|
||||||
required TResult Function(_Get value) get,
|
required TResult Function(_Get value) get,
|
||||||
|
required TResult Function(_SetCategoryId value) setCategoryId,
|
||||||
}) =>
|
}) =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult? mapOrNull<TResult extends Object?>({
|
TResult? mapOrNull<TResult extends Object?>({
|
||||||
TResult? Function(_Get value)? get,
|
TResult? Function(_Get value)? get,
|
||||||
|
TResult? Function(_SetCategoryId value)? setCategoryId,
|
||||||
}) =>
|
}) =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult maybeMap<TResult extends Object?>({
|
TResult maybeMap<TResult extends Object?>({
|
||||||
TResult Function(_Get value)? get,
|
TResult Function(_Get value)? get,
|
||||||
|
TResult Function(_SetCategoryId value)? setCategoryId,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) =>
|
}) =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
@@ -111,6 +117,7 @@ class _$GetImpl implements _Get {
|
|||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult when<TResult extends Object?>({
|
TResult when<TResult extends Object?>({
|
||||||
required TResult Function() get,
|
required TResult Function() get,
|
||||||
|
required TResult Function(String categoryId) setCategoryId,
|
||||||
}) {
|
}) {
|
||||||
return get();
|
return get();
|
||||||
}
|
}
|
||||||
@@ -119,6 +126,7 @@ class _$GetImpl implements _Get {
|
|||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult? whenOrNull<TResult extends Object?>({
|
TResult? whenOrNull<TResult extends Object?>({
|
||||||
TResult? Function()? get,
|
TResult? Function()? get,
|
||||||
|
TResult? Function(String categoryId)? setCategoryId,
|
||||||
}) {
|
}) {
|
||||||
return get?.call();
|
return get?.call();
|
||||||
}
|
}
|
||||||
@@ -127,6 +135,7 @@ class _$GetImpl implements _Get {
|
|||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
TResult maybeWhen<TResult extends Object?>({
|
||||||
TResult Function()? get,
|
TResult Function()? get,
|
||||||
|
TResult Function(String categoryId)? setCategoryId,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) {
|
}) {
|
||||||
if (get != null) {
|
if (get != null) {
|
||||||
@@ -139,6 +148,7 @@ class _$GetImpl implements _Get {
|
|||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult map<TResult extends Object?>({
|
TResult map<TResult extends Object?>({
|
||||||
required TResult Function(_Get value) get,
|
required TResult Function(_Get value) get,
|
||||||
|
required TResult Function(_SetCategoryId value) setCategoryId,
|
||||||
}) {
|
}) {
|
||||||
return get(this);
|
return get(this);
|
||||||
}
|
}
|
||||||
@@ -147,6 +157,7 @@ class _$GetImpl implements _Get {
|
|||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult? mapOrNull<TResult extends Object?>({
|
TResult? mapOrNull<TResult extends Object?>({
|
||||||
TResult? Function(_Get value)? get,
|
TResult? Function(_Get value)? get,
|
||||||
|
TResult? Function(_SetCategoryId value)? setCategoryId,
|
||||||
}) {
|
}) {
|
||||||
return get?.call(this);
|
return get?.call(this);
|
||||||
}
|
}
|
||||||
@@ -155,6 +166,7 @@ class _$GetImpl implements _Get {
|
|||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult maybeMap<TResult extends Object?>({
|
TResult maybeMap<TResult extends Object?>({
|
||||||
TResult Function(_Get value)? get,
|
TResult Function(_Get value)? get,
|
||||||
|
TResult Function(_SetCategoryId value)? setCategoryId,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) {
|
}) {
|
||||||
if (get != null) {
|
if (get != null) {
|
||||||
@@ -168,13 +180,156 @@ abstract class _Get implements CategoryLoaderEvent {
|
|||||||
const factory _Get() = _$GetImpl;
|
const factory _Get() = _$GetImpl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
abstract class _$$SetCategoryIdImplCopyWith<$Res> {
|
||||||
|
factory _$$SetCategoryIdImplCopyWith(
|
||||||
|
_$SetCategoryIdImpl value, $Res Function(_$SetCategoryIdImpl) then) =
|
||||||
|
__$$SetCategoryIdImplCopyWithImpl<$Res>;
|
||||||
|
@useResult
|
||||||
|
$Res call({String categoryId});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
class __$$SetCategoryIdImplCopyWithImpl<$Res>
|
||||||
|
extends _$CategoryLoaderEventCopyWithImpl<$Res, _$SetCategoryIdImpl>
|
||||||
|
implements _$$SetCategoryIdImplCopyWith<$Res> {
|
||||||
|
__$$SetCategoryIdImplCopyWithImpl(
|
||||||
|
_$SetCategoryIdImpl _value, $Res Function(_$SetCategoryIdImpl) _then)
|
||||||
|
: super(_value, _then);
|
||||||
|
|
||||||
|
/// Create a copy of CategoryLoaderEvent
|
||||||
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
@override
|
||||||
|
$Res call({
|
||||||
|
Object? categoryId = null,
|
||||||
|
}) {
|
||||||
|
return _then(_$SetCategoryIdImpl(
|
||||||
|
null == categoryId
|
||||||
|
? _value.categoryId
|
||||||
|
: categoryId // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
|
||||||
|
class _$SetCategoryIdImpl implements _SetCategoryId {
|
||||||
|
const _$SetCategoryIdImpl(this.categoryId);
|
||||||
|
|
||||||
|
@override
|
||||||
|
final String categoryId;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'CategoryLoaderEvent.setCategoryId(categoryId: $categoryId)';
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) {
|
||||||
|
return identical(this, other) ||
|
||||||
|
(other.runtimeType == runtimeType &&
|
||||||
|
other is _$SetCategoryIdImpl &&
|
||||||
|
(identical(other.categoryId, categoryId) ||
|
||||||
|
other.categoryId == categoryId));
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode => Object.hash(runtimeType, categoryId);
|
||||||
|
|
||||||
|
/// Create a copy of CategoryLoaderEvent
|
||||||
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
|
@override
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
_$$SetCategoryIdImplCopyWith<_$SetCategoryIdImpl> get copyWith =>
|
||||||
|
__$$SetCategoryIdImplCopyWithImpl<_$SetCategoryIdImpl>(this, _$identity);
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult when<TResult extends Object?>({
|
||||||
|
required TResult Function() get,
|
||||||
|
required TResult Function(String categoryId) setCategoryId,
|
||||||
|
}) {
|
||||||
|
return setCategoryId(categoryId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult? whenOrNull<TResult extends Object?>({
|
||||||
|
TResult? Function()? get,
|
||||||
|
TResult? Function(String categoryId)? setCategoryId,
|
||||||
|
}) {
|
||||||
|
return setCategoryId?.call(categoryId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult maybeWhen<TResult extends Object?>({
|
||||||
|
TResult Function()? get,
|
||||||
|
TResult Function(String categoryId)? setCategoryId,
|
||||||
|
required TResult orElse(),
|
||||||
|
}) {
|
||||||
|
if (setCategoryId != null) {
|
||||||
|
return setCategoryId(categoryId);
|
||||||
|
}
|
||||||
|
return orElse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult map<TResult extends Object?>({
|
||||||
|
required TResult Function(_Get value) get,
|
||||||
|
required TResult Function(_SetCategoryId value) setCategoryId,
|
||||||
|
}) {
|
||||||
|
return setCategoryId(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult? mapOrNull<TResult extends Object?>({
|
||||||
|
TResult? Function(_Get value)? get,
|
||||||
|
TResult? Function(_SetCategoryId value)? setCategoryId,
|
||||||
|
}) {
|
||||||
|
return setCategoryId?.call(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult maybeMap<TResult extends Object?>({
|
||||||
|
TResult Function(_Get value)? get,
|
||||||
|
TResult Function(_SetCategoryId value)? setCategoryId,
|
||||||
|
required TResult orElse(),
|
||||||
|
}) {
|
||||||
|
if (setCategoryId != null) {
|
||||||
|
return setCategoryId(this);
|
||||||
|
}
|
||||||
|
return orElse();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class _SetCategoryId implements CategoryLoaderEvent {
|
||||||
|
const factory _SetCategoryId(final String categoryId) = _$SetCategoryIdImpl;
|
||||||
|
|
||||||
|
String get categoryId;
|
||||||
|
|
||||||
|
/// Create a copy of CategoryLoaderEvent
|
||||||
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
|
_$$SetCategoryIdImplCopyWith<_$SetCategoryIdImpl> get copyWith =>
|
||||||
|
throw _privateConstructorUsedError;
|
||||||
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
mixin _$CategoryLoaderState {
|
mixin _$CategoryLoaderState {
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult when<TResult extends Object?>({
|
TResult when<TResult extends Object?>({
|
||||||
required TResult Function() initial,
|
required TResult Function() initial,
|
||||||
required TResult Function() loading,
|
required TResult Function() loading,
|
||||||
required TResult Function(List<CategoryModel> categories) loaded,
|
required TResult Function(
|
||||||
|
List<CategoryModel> categories, String? categoryId)
|
||||||
|
loaded,
|
||||||
required TResult Function(String message) error,
|
required TResult Function(String message) error,
|
||||||
}) =>
|
}) =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
@@ -182,7 +337,8 @@ mixin _$CategoryLoaderState {
|
|||||||
TResult? whenOrNull<TResult extends Object?>({
|
TResult? whenOrNull<TResult extends Object?>({
|
||||||
TResult? Function()? initial,
|
TResult? Function()? initial,
|
||||||
TResult? Function()? loading,
|
TResult? Function()? loading,
|
||||||
TResult? Function(List<CategoryModel> categories)? loaded,
|
TResult? Function(List<CategoryModel> categories, String? categoryId)?
|
||||||
|
loaded,
|
||||||
TResult? Function(String message)? error,
|
TResult? Function(String message)? error,
|
||||||
}) =>
|
}) =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
@@ -190,7 +346,8 @@ mixin _$CategoryLoaderState {
|
|||||||
TResult maybeWhen<TResult extends Object?>({
|
TResult maybeWhen<TResult extends Object?>({
|
||||||
TResult Function()? initial,
|
TResult Function()? initial,
|
||||||
TResult Function()? loading,
|
TResult Function()? loading,
|
||||||
TResult Function(List<CategoryModel> categories)? loaded,
|
TResult Function(List<CategoryModel> categories, String? categoryId)?
|
||||||
|
loaded,
|
||||||
TResult Function(String message)? error,
|
TResult Function(String message)? error,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) =>
|
}) =>
|
||||||
@@ -286,7 +443,9 @@ class _$InitialImpl implements _Initial {
|
|||||||
TResult when<TResult extends Object?>({
|
TResult when<TResult extends Object?>({
|
||||||
required TResult Function() initial,
|
required TResult Function() initial,
|
||||||
required TResult Function() loading,
|
required TResult Function() loading,
|
||||||
required TResult Function(List<CategoryModel> categories) loaded,
|
required TResult Function(
|
||||||
|
List<CategoryModel> categories, String? categoryId)
|
||||||
|
loaded,
|
||||||
required TResult Function(String message) error,
|
required TResult Function(String message) error,
|
||||||
}) {
|
}) {
|
||||||
return initial();
|
return initial();
|
||||||
@@ -297,7 +456,8 @@ class _$InitialImpl implements _Initial {
|
|||||||
TResult? whenOrNull<TResult extends Object?>({
|
TResult? whenOrNull<TResult extends Object?>({
|
||||||
TResult? Function()? initial,
|
TResult? Function()? initial,
|
||||||
TResult? Function()? loading,
|
TResult? Function()? loading,
|
||||||
TResult? Function(List<CategoryModel> categories)? loaded,
|
TResult? Function(List<CategoryModel> categories, String? categoryId)?
|
||||||
|
loaded,
|
||||||
TResult? Function(String message)? error,
|
TResult? Function(String message)? error,
|
||||||
}) {
|
}) {
|
||||||
return initial?.call();
|
return initial?.call();
|
||||||
@@ -308,7 +468,8 @@ class _$InitialImpl implements _Initial {
|
|||||||
TResult maybeWhen<TResult extends Object?>({
|
TResult maybeWhen<TResult extends Object?>({
|
||||||
TResult Function()? initial,
|
TResult Function()? initial,
|
||||||
TResult Function()? loading,
|
TResult Function()? loading,
|
||||||
TResult Function(List<CategoryModel> categories)? loaded,
|
TResult Function(List<CategoryModel> categories, String? categoryId)?
|
||||||
|
loaded,
|
||||||
TResult Function(String message)? error,
|
TResult Function(String message)? error,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) {
|
}) {
|
||||||
@@ -403,7 +564,9 @@ class _$LoadingImpl implements _Loading {
|
|||||||
TResult when<TResult extends Object?>({
|
TResult when<TResult extends Object?>({
|
||||||
required TResult Function() initial,
|
required TResult Function() initial,
|
||||||
required TResult Function() loading,
|
required TResult Function() loading,
|
||||||
required TResult Function(List<CategoryModel> categories) loaded,
|
required TResult Function(
|
||||||
|
List<CategoryModel> categories, String? categoryId)
|
||||||
|
loaded,
|
||||||
required TResult Function(String message) error,
|
required TResult Function(String message) error,
|
||||||
}) {
|
}) {
|
||||||
return loading();
|
return loading();
|
||||||
@@ -414,7 +577,8 @@ class _$LoadingImpl implements _Loading {
|
|||||||
TResult? whenOrNull<TResult extends Object?>({
|
TResult? whenOrNull<TResult extends Object?>({
|
||||||
TResult? Function()? initial,
|
TResult? Function()? initial,
|
||||||
TResult? Function()? loading,
|
TResult? Function()? loading,
|
||||||
TResult? Function(List<CategoryModel> categories)? loaded,
|
TResult? Function(List<CategoryModel> categories, String? categoryId)?
|
||||||
|
loaded,
|
||||||
TResult? Function(String message)? error,
|
TResult? Function(String message)? error,
|
||||||
}) {
|
}) {
|
||||||
return loading?.call();
|
return loading?.call();
|
||||||
@@ -425,7 +589,8 @@ class _$LoadingImpl implements _Loading {
|
|||||||
TResult maybeWhen<TResult extends Object?>({
|
TResult maybeWhen<TResult extends Object?>({
|
||||||
TResult Function()? initial,
|
TResult Function()? initial,
|
||||||
TResult Function()? loading,
|
TResult Function()? loading,
|
||||||
TResult Function(List<CategoryModel> categories)? loaded,
|
TResult Function(List<CategoryModel> categories, String? categoryId)?
|
||||||
|
loaded,
|
||||||
TResult Function(String message)? error,
|
TResult Function(String message)? error,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) {
|
}) {
|
||||||
@@ -483,7 +648,7 @@ abstract class _$$LoadedImplCopyWith<$Res> {
|
|||||||
_$LoadedImpl value, $Res Function(_$LoadedImpl) then) =
|
_$LoadedImpl value, $Res Function(_$LoadedImpl) then) =
|
||||||
__$$LoadedImplCopyWithImpl<$Res>;
|
__$$LoadedImplCopyWithImpl<$Res>;
|
||||||
@useResult
|
@useResult
|
||||||
$Res call({List<CategoryModel> categories});
|
$Res call({List<CategoryModel> categories, String? categoryId});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
@@ -500,12 +665,17 @@ class __$$LoadedImplCopyWithImpl<$Res>
|
|||||||
@override
|
@override
|
||||||
$Res call({
|
$Res call({
|
||||||
Object? categories = null,
|
Object? categories = null,
|
||||||
|
Object? categoryId = freezed,
|
||||||
}) {
|
}) {
|
||||||
return _then(_$LoadedImpl(
|
return _then(_$LoadedImpl(
|
||||||
null == categories
|
null == categories
|
||||||
? _value._categories
|
? _value._categories
|
||||||
: categories // ignore: cast_nullable_to_non_nullable
|
: categories // ignore: cast_nullable_to_non_nullable
|
||||||
as List<CategoryModel>,
|
as List<CategoryModel>,
|
||||||
|
freezed == categoryId
|
||||||
|
? _value.categoryId
|
||||||
|
: categoryId // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String?,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -513,7 +683,7 @@ class __$$LoadedImplCopyWithImpl<$Res>
|
|||||||
/// @nodoc
|
/// @nodoc
|
||||||
|
|
||||||
class _$LoadedImpl implements _Loaded {
|
class _$LoadedImpl implements _Loaded {
|
||||||
const _$LoadedImpl(final List<CategoryModel> categories)
|
const _$LoadedImpl(final List<CategoryModel> categories, this.categoryId)
|
||||||
: _categories = categories;
|
: _categories = categories;
|
||||||
|
|
||||||
final List<CategoryModel> _categories;
|
final List<CategoryModel> _categories;
|
||||||
@@ -524,9 +694,12 @@ class _$LoadedImpl implements _Loaded {
|
|||||||
return EqualUnmodifiableListView(_categories);
|
return EqualUnmodifiableListView(_categories);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
final String? categoryId;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'CategoryLoaderState.loaded(categories: $categories)';
|
return 'CategoryLoaderState.loaded(categories: $categories, categoryId: $categoryId)';
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -535,12 +708,14 @@ class _$LoadedImpl implements _Loaded {
|
|||||||
(other.runtimeType == runtimeType &&
|
(other.runtimeType == runtimeType &&
|
||||||
other is _$LoadedImpl &&
|
other is _$LoadedImpl &&
|
||||||
const DeepCollectionEquality()
|
const DeepCollectionEquality()
|
||||||
.equals(other._categories, _categories));
|
.equals(other._categories, _categories) &&
|
||||||
|
(identical(other.categoryId, categoryId) ||
|
||||||
|
other.categoryId == categoryId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
int get hashCode => Object.hash(
|
int get hashCode => Object.hash(runtimeType,
|
||||||
runtimeType, const DeepCollectionEquality().hash(_categories));
|
const DeepCollectionEquality().hash(_categories), categoryId);
|
||||||
|
|
||||||
/// Create a copy of CategoryLoaderState
|
/// Create a copy of CategoryLoaderState
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@@ -555,10 +730,12 @@ class _$LoadedImpl implements _Loaded {
|
|||||||
TResult when<TResult extends Object?>({
|
TResult when<TResult extends Object?>({
|
||||||
required TResult Function() initial,
|
required TResult Function() initial,
|
||||||
required TResult Function() loading,
|
required TResult Function() loading,
|
||||||
required TResult Function(List<CategoryModel> categories) loaded,
|
required TResult Function(
|
||||||
|
List<CategoryModel> categories, String? categoryId)
|
||||||
|
loaded,
|
||||||
required TResult Function(String message) error,
|
required TResult Function(String message) error,
|
||||||
}) {
|
}) {
|
||||||
return loaded(categories);
|
return loaded(categories, categoryId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -566,10 +743,11 @@ class _$LoadedImpl implements _Loaded {
|
|||||||
TResult? whenOrNull<TResult extends Object?>({
|
TResult? whenOrNull<TResult extends Object?>({
|
||||||
TResult? Function()? initial,
|
TResult? Function()? initial,
|
||||||
TResult? Function()? loading,
|
TResult? Function()? loading,
|
||||||
TResult? Function(List<CategoryModel> categories)? loaded,
|
TResult? Function(List<CategoryModel> categories, String? categoryId)?
|
||||||
|
loaded,
|
||||||
TResult? Function(String message)? error,
|
TResult? Function(String message)? error,
|
||||||
}) {
|
}) {
|
||||||
return loaded?.call(categories);
|
return loaded?.call(categories, categoryId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -577,12 +755,13 @@ class _$LoadedImpl implements _Loaded {
|
|||||||
TResult maybeWhen<TResult extends Object?>({
|
TResult maybeWhen<TResult extends Object?>({
|
||||||
TResult Function()? initial,
|
TResult Function()? initial,
|
||||||
TResult Function()? loading,
|
TResult Function()? loading,
|
||||||
TResult Function(List<CategoryModel> categories)? loaded,
|
TResult Function(List<CategoryModel> categories, String? categoryId)?
|
||||||
|
loaded,
|
||||||
TResult Function(String message)? error,
|
TResult Function(String message)? error,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) {
|
}) {
|
||||||
if (loaded != null) {
|
if (loaded != null) {
|
||||||
return loaded(categories);
|
return loaded(categories, categoryId);
|
||||||
}
|
}
|
||||||
return orElse();
|
return orElse();
|
||||||
}
|
}
|
||||||
@@ -626,9 +805,12 @@ class _$LoadedImpl implements _Loaded {
|
|||||||
}
|
}
|
||||||
|
|
||||||
abstract class _Loaded implements CategoryLoaderState {
|
abstract class _Loaded implements CategoryLoaderState {
|
||||||
const factory _Loaded(final List<CategoryModel> categories) = _$LoadedImpl;
|
const factory _Loaded(
|
||||||
|
final List<CategoryModel> categories, final String? categoryId) =
|
||||||
|
_$LoadedImpl;
|
||||||
|
|
||||||
List<CategoryModel> get categories;
|
List<CategoryModel> get categories;
|
||||||
|
String? get categoryId;
|
||||||
|
|
||||||
/// Create a copy of CategoryLoaderState
|
/// Create a copy of CategoryLoaderState
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@@ -707,7 +889,9 @@ class _$ErrorImpl implements _Error {
|
|||||||
TResult when<TResult extends Object?>({
|
TResult when<TResult extends Object?>({
|
||||||
required TResult Function() initial,
|
required TResult Function() initial,
|
||||||
required TResult Function() loading,
|
required TResult Function() loading,
|
||||||
required TResult Function(List<CategoryModel> categories) loaded,
|
required TResult Function(
|
||||||
|
List<CategoryModel> categories, String? categoryId)
|
||||||
|
loaded,
|
||||||
required TResult Function(String message) error,
|
required TResult Function(String message) error,
|
||||||
}) {
|
}) {
|
||||||
return error(message);
|
return error(message);
|
||||||
@@ -718,7 +902,8 @@ class _$ErrorImpl implements _Error {
|
|||||||
TResult? whenOrNull<TResult extends Object?>({
|
TResult? whenOrNull<TResult extends Object?>({
|
||||||
TResult? Function()? initial,
|
TResult? Function()? initial,
|
||||||
TResult? Function()? loading,
|
TResult? Function()? loading,
|
||||||
TResult? Function(List<CategoryModel> categories)? loaded,
|
TResult? Function(List<CategoryModel> categories, String? categoryId)?
|
||||||
|
loaded,
|
||||||
TResult? Function(String message)? error,
|
TResult? Function(String message)? error,
|
||||||
}) {
|
}) {
|
||||||
return error?.call(message);
|
return error?.call(message);
|
||||||
@@ -729,7 +914,8 @@ class _$ErrorImpl implements _Error {
|
|||||||
TResult maybeWhen<TResult extends Object?>({
|
TResult maybeWhen<TResult extends Object?>({
|
||||||
TResult Function()? initial,
|
TResult Function()? initial,
|
||||||
TResult Function()? loading,
|
TResult Function()? loading,
|
||||||
TResult Function(List<CategoryModel> categories)? loaded,
|
TResult Function(List<CategoryModel> categories, String? categoryId)?
|
||||||
|
loaded,
|
||||||
TResult Function(String message)? error,
|
TResult Function(String message)? error,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) {
|
}) {
|
||||||
|
|||||||
@@ -3,4 +3,6 @@ part of 'category_loader_bloc.dart';
|
|||||||
@freezed
|
@freezed
|
||||||
class CategoryLoaderEvent with _$CategoryLoaderEvent {
|
class CategoryLoaderEvent with _$CategoryLoaderEvent {
|
||||||
const factory CategoryLoaderEvent.get() = _Get;
|
const factory CategoryLoaderEvent.get() = _Get;
|
||||||
|
const factory CategoryLoaderEvent.setCategoryId(String categoryId) =
|
||||||
|
_SetCategoryId;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ part of 'category_loader_bloc.dart';
|
|||||||
class CategoryLoaderState with _$CategoryLoaderState {
|
class CategoryLoaderState with _$CategoryLoaderState {
|
||||||
const factory CategoryLoaderState.initial() = _Initial;
|
const factory CategoryLoaderState.initial() = _Initial;
|
||||||
const factory CategoryLoaderState.loading() = _Loading;
|
const factory CategoryLoaderState.loading() = _Loading;
|
||||||
const factory CategoryLoaderState.loaded(List<CategoryModel> categories) =
|
const factory CategoryLoaderState.loaded(
|
||||||
_Loaded;
|
List<CategoryModel> categories, String? categoryId) = _Loaded;
|
||||||
const factory CategoryLoaderState.error(String message) = _Error;
|
const factory CategoryLoaderState.error(String message) = _Error;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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"));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
@@ -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({
|
||||||
|
|||||||
@@ -18,22 +18,22 @@ final _privateConstructorUsedError = UnsupportedError(
|
|||||||
mixin _$ProductLoaderEvent {
|
mixin _$ProductLoaderEvent {
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult when<TResult extends Object?>({
|
TResult when<TResult extends Object?>({
|
||||||
required TResult Function(String? categoryId) getProduct,
|
required TResult Function(String? categoryId, String? search) getProduct,
|
||||||
required TResult Function(String? categoryId) loadMore,
|
required TResult Function(String? categoryId, String? search) loadMore,
|
||||||
required TResult Function() refresh,
|
required TResult Function() refresh,
|
||||||
}) =>
|
}) =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult? whenOrNull<TResult extends Object?>({
|
TResult? whenOrNull<TResult extends Object?>({
|
||||||
TResult? Function(String? categoryId)? getProduct,
|
TResult? Function(String? categoryId, String? search)? getProduct,
|
||||||
TResult? Function(String? categoryId)? loadMore,
|
TResult? Function(String? categoryId, String? search)? loadMore,
|
||||||
TResult? Function()? refresh,
|
TResult? Function()? refresh,
|
||||||
}) =>
|
}) =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
TResult maybeWhen<TResult extends Object?>({
|
||||||
TResult Function(String? categoryId)? getProduct,
|
TResult Function(String? categoryId, String? search)? getProduct,
|
||||||
TResult Function(String? categoryId)? loadMore,
|
TResult Function(String? categoryId, String? search)? loadMore,
|
||||||
TResult Function()? refresh,
|
TResult Function()? refresh,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) =>
|
}) =>
|
||||||
@@ -89,7 +89,7 @@ abstract class _$$GetProductImplCopyWith<$Res> {
|
|||||||
_$GetProductImpl value, $Res Function(_$GetProductImpl) then) =
|
_$GetProductImpl value, $Res Function(_$GetProductImpl) then) =
|
||||||
__$$GetProductImplCopyWithImpl<$Res>;
|
__$$GetProductImplCopyWithImpl<$Res>;
|
||||||
@useResult
|
@useResult
|
||||||
$Res call({String? categoryId});
|
$Res call({String? categoryId, String? search});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
@@ -106,12 +106,17 @@ class __$$GetProductImplCopyWithImpl<$Res>
|
|||||||
@override
|
@override
|
||||||
$Res call({
|
$Res call({
|
||||||
Object? categoryId = freezed,
|
Object? categoryId = freezed,
|
||||||
|
Object? search = freezed,
|
||||||
}) {
|
}) {
|
||||||
return _then(_$GetProductImpl(
|
return _then(_$GetProductImpl(
|
||||||
categoryId: freezed == categoryId
|
categoryId: freezed == categoryId
|
||||||
? _value.categoryId
|
? _value.categoryId
|
||||||
: categoryId // ignore: cast_nullable_to_non_nullable
|
: categoryId // ignore: cast_nullable_to_non_nullable
|
||||||
as String?,
|
as String?,
|
||||||
|
search: freezed == search
|
||||||
|
? _value.search
|
||||||
|
: search // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String?,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -119,14 +124,16 @@ class __$$GetProductImplCopyWithImpl<$Res>
|
|||||||
/// @nodoc
|
/// @nodoc
|
||||||
|
|
||||||
class _$GetProductImpl implements _GetProduct {
|
class _$GetProductImpl implements _GetProduct {
|
||||||
const _$GetProductImpl({this.categoryId});
|
const _$GetProductImpl({this.categoryId, this.search});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
final String? categoryId;
|
final String? categoryId;
|
||||||
|
@override
|
||||||
|
final String? search;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'ProductLoaderEvent.getProduct(categoryId: $categoryId)';
|
return 'ProductLoaderEvent.getProduct(categoryId: $categoryId, search: $search)';
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -135,11 +142,12 @@ class _$GetProductImpl implements _GetProduct {
|
|||||||
(other.runtimeType == runtimeType &&
|
(other.runtimeType == runtimeType &&
|
||||||
other is _$GetProductImpl &&
|
other is _$GetProductImpl &&
|
||||||
(identical(other.categoryId, categoryId) ||
|
(identical(other.categoryId, categoryId) ||
|
||||||
other.categoryId == categoryId));
|
other.categoryId == categoryId) &&
|
||||||
|
(identical(other.search, search) || other.search == search));
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
int get hashCode => Object.hash(runtimeType, categoryId);
|
int get hashCode => Object.hash(runtimeType, categoryId, search);
|
||||||
|
|
||||||
/// Create a copy of ProductLoaderEvent
|
/// Create a copy of ProductLoaderEvent
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@@ -152,33 +160,33 @@ class _$GetProductImpl implements _GetProduct {
|
|||||||
@override
|
@override
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult when<TResult extends Object?>({
|
TResult when<TResult extends Object?>({
|
||||||
required TResult Function(String? categoryId) getProduct,
|
required TResult Function(String? categoryId, String? search) getProduct,
|
||||||
required TResult Function(String? categoryId) loadMore,
|
required TResult Function(String? categoryId, String? search) loadMore,
|
||||||
required TResult Function() refresh,
|
required TResult Function() refresh,
|
||||||
}) {
|
}) {
|
||||||
return getProduct(categoryId);
|
return getProduct(categoryId, search);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult? whenOrNull<TResult extends Object?>({
|
TResult? whenOrNull<TResult extends Object?>({
|
||||||
TResult? Function(String? categoryId)? getProduct,
|
TResult? Function(String? categoryId, String? search)? getProduct,
|
||||||
TResult? Function(String? categoryId)? loadMore,
|
TResult? Function(String? categoryId, String? search)? loadMore,
|
||||||
TResult? Function()? refresh,
|
TResult? Function()? refresh,
|
||||||
}) {
|
}) {
|
||||||
return getProduct?.call(categoryId);
|
return getProduct?.call(categoryId, search);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
TResult maybeWhen<TResult extends Object?>({
|
||||||
TResult Function(String? categoryId)? getProduct,
|
TResult Function(String? categoryId, String? search)? getProduct,
|
||||||
TResult Function(String? categoryId)? loadMore,
|
TResult Function(String? categoryId, String? search)? loadMore,
|
||||||
TResult Function()? refresh,
|
TResult Function()? refresh,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) {
|
}) {
|
||||||
if (getProduct != null) {
|
if (getProduct != null) {
|
||||||
return getProduct(categoryId);
|
return getProduct(categoryId, search);
|
||||||
}
|
}
|
||||||
return orElse();
|
return orElse();
|
||||||
}
|
}
|
||||||
@@ -219,9 +227,11 @@ class _$GetProductImpl implements _GetProduct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
abstract class _GetProduct implements ProductLoaderEvent {
|
abstract class _GetProduct implements ProductLoaderEvent {
|
||||||
const factory _GetProduct({final String? categoryId}) = _$GetProductImpl;
|
const factory _GetProduct({final String? categoryId, final String? search}) =
|
||||||
|
_$GetProductImpl;
|
||||||
|
|
||||||
String? get categoryId;
|
String? get categoryId;
|
||||||
|
String? get search;
|
||||||
|
|
||||||
/// Create a copy of ProductLoaderEvent
|
/// Create a copy of ProductLoaderEvent
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@@ -236,7 +246,7 @@ abstract class _$$LoadMoreImplCopyWith<$Res> {
|
|||||||
_$LoadMoreImpl value, $Res Function(_$LoadMoreImpl) then) =
|
_$LoadMoreImpl value, $Res Function(_$LoadMoreImpl) then) =
|
||||||
__$$LoadMoreImplCopyWithImpl<$Res>;
|
__$$LoadMoreImplCopyWithImpl<$Res>;
|
||||||
@useResult
|
@useResult
|
||||||
$Res call({String? categoryId});
|
$Res call({String? categoryId, String? search});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
@@ -253,12 +263,17 @@ class __$$LoadMoreImplCopyWithImpl<$Res>
|
|||||||
@override
|
@override
|
||||||
$Res call({
|
$Res call({
|
||||||
Object? categoryId = freezed,
|
Object? categoryId = freezed,
|
||||||
|
Object? search = freezed,
|
||||||
}) {
|
}) {
|
||||||
return _then(_$LoadMoreImpl(
|
return _then(_$LoadMoreImpl(
|
||||||
categoryId: freezed == categoryId
|
categoryId: freezed == categoryId
|
||||||
? _value.categoryId
|
? _value.categoryId
|
||||||
: categoryId // ignore: cast_nullable_to_non_nullable
|
: categoryId // ignore: cast_nullable_to_non_nullable
|
||||||
as String?,
|
as String?,
|
||||||
|
search: freezed == search
|
||||||
|
? _value.search
|
||||||
|
: search // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String?,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -266,14 +281,16 @@ class __$$LoadMoreImplCopyWithImpl<$Res>
|
|||||||
/// @nodoc
|
/// @nodoc
|
||||||
|
|
||||||
class _$LoadMoreImpl implements _LoadMore {
|
class _$LoadMoreImpl implements _LoadMore {
|
||||||
const _$LoadMoreImpl({this.categoryId});
|
const _$LoadMoreImpl({this.categoryId, this.search});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
final String? categoryId;
|
final String? categoryId;
|
||||||
|
@override
|
||||||
|
final String? search;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'ProductLoaderEvent.loadMore(categoryId: $categoryId)';
|
return 'ProductLoaderEvent.loadMore(categoryId: $categoryId, search: $search)';
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -282,11 +299,12 @@ class _$LoadMoreImpl implements _LoadMore {
|
|||||||
(other.runtimeType == runtimeType &&
|
(other.runtimeType == runtimeType &&
|
||||||
other is _$LoadMoreImpl &&
|
other is _$LoadMoreImpl &&
|
||||||
(identical(other.categoryId, categoryId) ||
|
(identical(other.categoryId, categoryId) ||
|
||||||
other.categoryId == categoryId));
|
other.categoryId == categoryId) &&
|
||||||
|
(identical(other.search, search) || other.search == search));
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
int get hashCode => Object.hash(runtimeType, categoryId);
|
int get hashCode => Object.hash(runtimeType, categoryId, search);
|
||||||
|
|
||||||
/// Create a copy of ProductLoaderEvent
|
/// Create a copy of ProductLoaderEvent
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@@ -299,33 +317,33 @@ class _$LoadMoreImpl implements _LoadMore {
|
|||||||
@override
|
@override
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult when<TResult extends Object?>({
|
TResult when<TResult extends Object?>({
|
||||||
required TResult Function(String? categoryId) getProduct,
|
required TResult Function(String? categoryId, String? search) getProduct,
|
||||||
required TResult Function(String? categoryId) loadMore,
|
required TResult Function(String? categoryId, String? search) loadMore,
|
||||||
required TResult Function() refresh,
|
required TResult Function() refresh,
|
||||||
}) {
|
}) {
|
||||||
return loadMore(categoryId);
|
return loadMore(categoryId, search);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult? whenOrNull<TResult extends Object?>({
|
TResult? whenOrNull<TResult extends Object?>({
|
||||||
TResult? Function(String? categoryId)? getProduct,
|
TResult? Function(String? categoryId, String? search)? getProduct,
|
||||||
TResult? Function(String? categoryId)? loadMore,
|
TResult? Function(String? categoryId, String? search)? loadMore,
|
||||||
TResult? Function()? refresh,
|
TResult? Function()? refresh,
|
||||||
}) {
|
}) {
|
||||||
return loadMore?.call(categoryId);
|
return loadMore?.call(categoryId, search);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
TResult maybeWhen<TResult extends Object?>({
|
||||||
TResult Function(String? categoryId)? getProduct,
|
TResult Function(String? categoryId, String? search)? getProduct,
|
||||||
TResult Function(String? categoryId)? loadMore,
|
TResult Function(String? categoryId, String? search)? loadMore,
|
||||||
TResult Function()? refresh,
|
TResult Function()? refresh,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) {
|
}) {
|
||||||
if (loadMore != null) {
|
if (loadMore != null) {
|
||||||
return loadMore(categoryId);
|
return loadMore(categoryId, search);
|
||||||
}
|
}
|
||||||
return orElse();
|
return orElse();
|
||||||
}
|
}
|
||||||
@@ -366,9 +384,11 @@ class _$LoadMoreImpl implements _LoadMore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
abstract class _LoadMore implements ProductLoaderEvent {
|
abstract class _LoadMore implements ProductLoaderEvent {
|
||||||
const factory _LoadMore({final String? categoryId}) = _$LoadMoreImpl;
|
const factory _LoadMore({final String? categoryId, final String? search}) =
|
||||||
|
_$LoadMoreImpl;
|
||||||
|
|
||||||
String? get categoryId;
|
String? get categoryId;
|
||||||
|
String? get search;
|
||||||
|
|
||||||
/// Create a copy of ProductLoaderEvent
|
/// Create a copy of ProductLoaderEvent
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@@ -418,8 +438,8 @@ class _$RefreshImpl implements _Refresh {
|
|||||||
@override
|
@override
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult when<TResult extends Object?>({
|
TResult when<TResult extends Object?>({
|
||||||
required TResult Function(String? categoryId) getProduct,
|
required TResult Function(String? categoryId, String? search) getProduct,
|
||||||
required TResult Function(String? categoryId) loadMore,
|
required TResult Function(String? categoryId, String? search) loadMore,
|
||||||
required TResult Function() refresh,
|
required TResult Function() refresh,
|
||||||
}) {
|
}) {
|
||||||
return refresh();
|
return refresh();
|
||||||
@@ -428,8 +448,8 @@ class _$RefreshImpl implements _Refresh {
|
|||||||
@override
|
@override
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult? whenOrNull<TResult extends Object?>({
|
TResult? whenOrNull<TResult extends Object?>({
|
||||||
TResult? Function(String? categoryId)? getProduct,
|
TResult? Function(String? categoryId, String? search)? getProduct,
|
||||||
TResult? Function(String? categoryId)? loadMore,
|
TResult? Function(String? categoryId, String? search)? loadMore,
|
||||||
TResult? Function()? refresh,
|
TResult? Function()? refresh,
|
||||||
}) {
|
}) {
|
||||||
return refresh?.call();
|
return refresh?.call();
|
||||||
@@ -438,8 +458,8 @@ class _$RefreshImpl implements _Refresh {
|
|||||||
@override
|
@override
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
TResult maybeWhen<TResult extends Object?>({
|
||||||
TResult Function(String? categoryId)? getProduct,
|
TResult Function(String? categoryId, String? search)? getProduct,
|
||||||
TResult Function(String? categoryId)? loadMore,
|
TResult Function(String? categoryId, String? search)? loadMore,
|
||||||
TResult Function()? refresh,
|
TResult Function()? refresh,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) {
|
}) {
|
||||||
|
|||||||
@@ -2,8 +2,9 @@ part of 'product_loader_bloc.dart';
|
|||||||
|
|
||||||
@freezed
|
@freezed
|
||||||
class ProductLoaderEvent with _$ProductLoaderEvent {
|
class ProductLoaderEvent with _$ProductLoaderEvent {
|
||||||
const factory ProductLoaderEvent.getProduct({String? categoryId}) =
|
const factory ProductLoaderEvent.getProduct(
|
||||||
_GetProduct;
|
{String? categoryId, String? search}) = _GetProduct;
|
||||||
const factory ProductLoaderEvent.loadMore({String? categoryId}) = _LoadMore;
|
const factory ProductLoaderEvent.loadMore(
|
||||||
|
{String? categoryId, String? search}) = _LoadMore;
|
||||||
const factory ProductLoaderEvent.refresh() = _Refresh;
|
const factory ProductLoaderEvent.refresh() = _Refresh;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,6 +69,16 @@ class _OutletDialogState extends State<OutletDialog> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
SpaceHeight(24),
|
SpaceHeight(24),
|
||||||
|
BlocListener<UserUpdateOutletBloc, UserUpdateOutletState>(
|
||||||
|
listener: (context, state) {
|
||||||
|
state.maybeWhen(
|
||||||
|
orElse: () {},
|
||||||
|
success: () {
|
||||||
|
context.pop();
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child:
|
||||||
BlocBuilder<UserUpdateOutletBloc, UserUpdateOutletState>(
|
BlocBuilder<UserUpdateOutletBloc, UserUpdateOutletState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
return state.maybeWhen(
|
return state.maybeWhen(
|
||||||
@@ -88,6 +98,7 @@ class _OutletDialogState extends State<OutletDialog> {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -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(
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ class VariantDialog extends StatelessWidget {
|
|||||||
Text(
|
Text(
|
||||||
(variant.priceModifier ?? 0).currencyFormatRpV2,
|
(variant.priceModifier ?? 0).currencyFormatRpV2,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: AppColors.grey,
|
color: AppColors.black,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:enaklo_pos/data/type/bussines_type.dart';
|
||||||
|
|
||||||
class OutletResponse {
|
class OutletResponse {
|
||||||
final bool? success;
|
final bool? success;
|
||||||
final OutletData? data;
|
final OutletData? data;
|
||||||
@@ -101,7 +103,7 @@ class Outlet {
|
|||||||
final String? name;
|
final String? name;
|
||||||
final String? address;
|
final String? address;
|
||||||
final String? phoneNumber;
|
final String? phoneNumber;
|
||||||
final String? businessType;
|
final BusinessType? businessType;
|
||||||
final String? currency;
|
final String? currency;
|
||||||
final int? taxRate;
|
final int? taxRate;
|
||||||
final bool? isActive;
|
final bool? isActive;
|
||||||
@@ -128,7 +130,7 @@ class Outlet {
|
|||||||
name: json["name"],
|
name: json["name"],
|
||||||
address: json["address"],
|
address: json["address"],
|
||||||
phoneNumber: json["phone_number"],
|
phoneNumber: json["phone_number"],
|
||||||
businessType: json["business_type"],
|
businessType: BusinessType.fromString(json["business_type"]),
|
||||||
currency: json["currency"],
|
currency: json["currency"],
|
||||||
taxRate: json["tax_rate"],
|
taxRate: json["tax_rate"],
|
||||||
isActive: json["is_active"],
|
isActive: json["is_active"],
|
||||||
@@ -146,7 +148,7 @@ class Outlet {
|
|||||||
"name": name,
|
"name": name,
|
||||||
"address": address,
|
"address": address,
|
||||||
"phone_number": phoneNumber,
|
"phone_number": phoneNumber,
|
||||||
"business_type": businessType,
|
"business_type": businessType?.value,
|
||||||
"currency": currency,
|
"currency": currency,
|
||||||
"tax_rate": taxRate,
|
"tax_rate": taxRate,
|
||||||
"is_active": isActive,
|
"is_active": isActive,
|
||||||
|
|||||||
@@ -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),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -961,6 +966,23 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
|
|||||||
) =>
|
) =>
|
||||||
products,
|
products,
|
||||||
);
|
);
|
||||||
|
int tax = state.maybeWhen(
|
||||||
|
orElse: () => 0,
|
||||||
|
loaded: (
|
||||||
|
products,
|
||||||
|
discountModel,
|
||||||
|
discount,
|
||||||
|
discountAmount,
|
||||||
|
tax,
|
||||||
|
serviceCharge,
|
||||||
|
totalQuantity,
|
||||||
|
totalPrice,
|
||||||
|
draftName,
|
||||||
|
orderType,
|
||||||
|
deliveryType,
|
||||||
|
) =>
|
||||||
|
tax,
|
||||||
|
);
|
||||||
|
|
||||||
return Container(
|
return Container(
|
||||||
padding: EdgeInsets.all(16),
|
padding: EdgeInsets.all(16),
|
||||||
@@ -1018,6 +1040,11 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
|
|||||||
.pushReplacement(SuccessOrderPage(
|
.pushReplacement(SuccessOrderPage(
|
||||||
productQuantity: items,
|
productQuantity: items,
|
||||||
order: data,
|
order: data,
|
||||||
|
paymentMethod:
|
||||||
|
selectedPaymentMethod?.name ?? "",
|
||||||
|
nominalBayar: totalPriceController
|
||||||
|
.text.toIntegerFromText,
|
||||||
|
taxPercentage: tax,
|
||||||
));
|
));
|
||||||
},
|
},
|
||||||
error: (message) => AppFlushbar.showError(
|
error: (message) => AppFlushbar.showError(
|
||||||
@@ -1043,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,
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ import 'dart:async';
|
|||||||
import 'dart:developer';
|
import 'dart:developer';
|
||||||
|
|
||||||
import 'package:connectivity_plus/connectivity_plus.dart';
|
import 'package:connectivity_plus/connectivity_plus.dart';
|
||||||
|
import 'package:enaklo_pos/presentation/customer/pages/customer_page.dart';
|
||||||
|
import 'package:enaklo_pos/presentation/setting/pages/setting_page.dart';
|
||||||
import 'package:enaklo_pos/presentation/table/pages/table_page.dart';
|
import 'package:enaklo_pos/presentation/table/pages/table_page.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
@@ -14,8 +16,6 @@ import 'package:enaklo_pos/data/datasources/auth_local_datasource.dart';
|
|||||||
import 'package:enaklo_pos/presentation/auth/login_page.dart';
|
import 'package:enaklo_pos/presentation/auth/login_page.dart';
|
||||||
import 'package:enaklo_pos/presentation/report/pages/report_page.dart';
|
import 'package:enaklo_pos/presentation/report/pages/report_page.dart';
|
||||||
import 'package:enaklo_pos/presentation/setting/bloc/sync_order/sync_order_bloc.dart';
|
import 'package:enaklo_pos/presentation/setting/bloc/sync_order/sync_order_bloc.dart';
|
||||||
import 'package:enaklo_pos/presentation/setting/pages/printer_configuration_page.dart';
|
|
||||||
import 'package:enaklo_pos/presentation/setting/pages/settings_page.dart';
|
|
||||||
|
|
||||||
import '../../../core/assets/assets.gen.dart';
|
import '../../../core/assets/assets.gen.dart';
|
||||||
import '../../auth/bloc/logout/logout_bloc.dart';
|
import '../../auth/bloc/logout/logout_bloc.dart';
|
||||||
@@ -59,9 +59,8 @@ class _DashboardPageState extends State<DashboardPage> {
|
|||||||
),
|
),
|
||||||
const TablePage(),
|
const TablePage(),
|
||||||
const ReportPage(),
|
const ReportPage(),
|
||||||
const PrinterConfigurationPage(),
|
const CustomerPage(),
|
||||||
// SalesPage(),
|
const SettingPage(),
|
||||||
const SettingsPage(),
|
|
||||||
];
|
];
|
||||||
// ignore: unused_local_variable
|
// ignore: unused_local_variable
|
||||||
_connectivitySubscription = Connectivity()
|
_connectivitySubscription = Connectivity()
|
||||||
@@ -121,7 +120,7 @@ class _DashboardPageState extends State<DashboardPage> {
|
|||||||
onTap: () => _onItemTapped(2),
|
onTap: () => _onItemTapped(2),
|
||||||
),
|
),
|
||||||
NavItem(
|
NavItem(
|
||||||
iconPath: Assets.icons.print.path,
|
iconPath: Assets.icons.people.path,
|
||||||
isActive: _selectedIndex == 3,
|
isActive: _selectedIndex == 3,
|
||||||
onTap: () => _onItemTapped(3),
|
onTap: () => _onItemTapped(3),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -103,7 +103,8 @@ class _HomePageState extends State<HomePage> {
|
|||||||
}).toList();
|
}).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool _handleScrollNotification(ScrollNotification notification) {
|
bool _handleScrollNotification(
|
||||||
|
ScrollNotification notification, String? categoryId) {
|
||||||
// Check if the ScrollController is attached before accessing position
|
// Check if the ScrollController is attached before accessing position
|
||||||
if (!scrollController.hasClients) {
|
if (!scrollController.hasClients) {
|
||||||
return false;
|
return false;
|
||||||
@@ -111,9 +112,12 @@ class _HomePageState extends State<HomePage> {
|
|||||||
|
|
||||||
if (notification is ScrollEndNotification &&
|
if (notification is ScrollEndNotification &&
|
||||||
scrollController.position.extentAfter == 0) {
|
scrollController.position.extentAfter == 0) {
|
||||||
context
|
context.read<ProductLoaderBloc>().add(
|
||||||
.read<ProductLoaderBloc>()
|
ProductLoaderEvent.loadMore(
|
||||||
.add(const ProductLoaderEvent.loadMore());
|
categoryId: categoryId,
|
||||||
|
search: searchQuery,
|
||||||
|
),
|
||||||
|
);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -127,7 +131,6 @@ class _HomePageState extends State<HomePage> {
|
|||||||
orElse: () {},
|
orElse: () {},
|
||||||
loading: () {},
|
loading: () {},
|
||||||
success: () {
|
success: () {
|
||||||
context.pop();
|
|
||||||
Future.delayed(Duration(milliseconds: 300), () {
|
Future.delayed(Duration(milliseconds: 300), () {
|
||||||
AppFlushbar.showSuccess(context, 'Outlet berhasil diubah');
|
AppFlushbar.showSuccess(context, 'Outlet berhasil diubah');
|
||||||
context
|
context
|
||||||
@@ -148,7 +151,13 @@ class _HomePageState extends State<HomePage> {
|
|||||||
flex: 3,
|
flex: 3,
|
||||||
child: Align(
|
child: Align(
|
||||||
alignment: AlignmentDirectional.topStart,
|
alignment: AlignmentDirectional.topStart,
|
||||||
child: Column(
|
child: BlocBuilder<CategoryLoaderBloc, CategoryLoaderState>(
|
||||||
|
builder: (context, state) {
|
||||||
|
return state.maybeWhen(
|
||||||
|
orElse: () => Center(
|
||||||
|
child: CircularProgressIndicator(),
|
||||||
|
),
|
||||||
|
loaded: (categories, categoryId) => Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
HomeTitle(
|
HomeTitle(
|
||||||
@@ -157,6 +166,14 @@ class _HomePageState extends State<HomePage> {
|
|||||||
setState(() {
|
setState(() {
|
||||||
searchQuery = value;
|
searchQuery = value;
|
||||||
});
|
});
|
||||||
|
Future.delayed(Duration(milliseconds: 600), () {
|
||||||
|
context.read<ProductLoaderBloc>().add(
|
||||||
|
ProductLoaderEvent.getProduct(
|
||||||
|
categoryId: categoryId,
|
||||||
|
search: value,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
BlocBuilder<ProductLoaderBloc, ProductLoaderState>(
|
BlocBuilder<ProductLoaderBloc, ProductLoaderState>(
|
||||||
@@ -165,25 +182,15 @@ class _HomePageState extends State<HomePage> {
|
|||||||
onNotification: (notification) {
|
onNotification: (notification) {
|
||||||
return state.maybeWhen(
|
return state.maybeWhen(
|
||||||
orElse: () => false,
|
orElse: () => false,
|
||||||
loaded: (products, hasReachedMax, currentPage,
|
loaded: (products, hasReachedMax,
|
||||||
isLoadingMore) {
|
currentPage, isLoadingMore) {
|
||||||
return _handleScrollNotification(
|
return _handleScrollNotification(
|
||||||
notification);
|
notification, categoryId);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
child: Expanded(child: BlocBuilder<
|
child: Expanded(
|
||||||
CategoryLoaderBloc, CategoryLoaderState>(
|
child: CategoryTabBar(
|
||||||
builder: (contextCategory, stateCateogry) {
|
|
||||||
return stateCateogry.maybeWhen(
|
|
||||||
orElse: () => SizedBox.shrink(),
|
|
||||||
loading: () {
|
|
||||||
return const Center(
|
|
||||||
child: CircularProgressIndicator(),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
loaded: (categories) {
|
|
||||||
return CategoryTabBar(
|
|
||||||
categories: categories,
|
categories: categories,
|
||||||
tabViews: categories.map((category) {
|
tabViews: categories.map((category) {
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
@@ -229,16 +236,16 @@ class _HomePageState extends State<HomePage> {
|
|||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
}).toList(),
|
}).toList(),
|
||||||
);
|
),
|
||||||
},
|
),
|
||||||
);
|
|
||||||
},
|
|
||||||
)),
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
@@ -422,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);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import 'package:enaklo_pos/core/constants/colors.dart';
|
import 'package:enaklo_pos/core/constants/colors.dart';
|
||||||
import 'package:enaklo_pos/data/models/response/category_response_model.dart';
|
import 'package:enaklo_pos/data/models/response/category_response_model.dart';
|
||||||
|
import 'package:enaklo_pos/presentation/home/bloc/category_loader/category_loader_bloc.dart';
|
||||||
import 'package:enaklo_pos/presentation/home/bloc/product_loader/product_loader_bloc.dart';
|
import 'package:enaklo_pos/presentation/home/bloc/product_loader/product_loader_bloc.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
@@ -36,6 +37,9 @@ class _CategoryTabBarState extends State<CategoryTabBar>
|
|||||||
context.read<ProductLoaderBloc>().add(
|
context.read<ProductLoaderBloc>().add(
|
||||||
ProductLoaderEvent.getProduct(categoryId: selectedCategoryId),
|
ProductLoaderEvent.getProduct(categoryId: selectedCategoryId),
|
||||||
);
|
);
|
||||||
|
context
|
||||||
|
.read<CategoryLoaderBloc>()
|
||||||
|
.add(CategoryLoaderEvent.setCategoryId(selectedCategoryId ?? ""));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import 'package:enaklo_pos/core/constants/colors.dart';
|
|||||||
import 'package:enaklo_pos/core/extensions/build_context_ext.dart';
|
import 'package:enaklo_pos/core/extensions/build_context_ext.dart';
|
||||||
import 'package:enaklo_pos/core/extensions/string_ext.dart';
|
import 'package:enaklo_pos/core/extensions/string_ext.dart';
|
||||||
import 'package:enaklo_pos/data/models/response/table_model.dart';
|
import 'package:enaklo_pos/data/models/response/table_model.dart';
|
||||||
import 'package:enaklo_pos/presentation/customer/pages/customer_page.dart';
|
|
||||||
import 'package:enaklo_pos/presentation/home/bloc/checkout/checkout_bloc.dart';
|
import 'package:enaklo_pos/presentation/home/bloc/checkout/checkout_bloc.dart';
|
||||||
import 'package:enaklo_pos/presentation/home/dialog/delivery_dialog.dart';
|
import 'package:enaklo_pos/presentation/home/dialog/delivery_dialog.dart';
|
||||||
import 'package:enaklo_pos/presentation/home/dialog/type_dialog.dart';
|
import 'package:enaklo_pos/presentation/home/dialog/type_dialog.dart';
|
||||||
@@ -20,7 +19,7 @@ class HomeRightTitle extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Container(
|
return Container(
|
||||||
height: context.deviceHeight * 0.15,
|
height: context.deviceHeight * 0.12,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: AppColors.primary,
|
color: AppColors.primary,
|
||||||
border: Border(
|
border: Border(
|
||||||
@@ -33,7 +32,8 @@ class HomeRightTitle extends StatelessWidget {
|
|||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
Row(
|
Expanded(
|
||||||
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Button.filled(
|
child: Button.filled(
|
||||||
@@ -53,29 +53,11 @@ class HomeRightTitle extends StatelessWidget {
|
|||||||
label: 'Daftar Pesanan',
|
label: 'Daftar Pesanan',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Expanded(
|
|
||||||
child: Button.filled(
|
|
||||||
width: 180.0,
|
|
||||||
height: 40,
|
|
||||||
elevation: 0,
|
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
icon: Icon(
|
|
||||||
Icons.person_outline,
|
|
||||||
color: Colors.white,
|
|
||||||
size: 24,
|
|
||||||
),
|
|
||||||
onPressed: () {
|
|
||||||
if (table == null) {
|
|
||||||
context.push(CustomerPage());
|
|
||||||
}
|
|
||||||
},
|
|
||||||
label: 'Pelanggan',
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
Row(
|
),
|
||||||
|
Expanded(
|
||||||
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
child: BlocBuilder<CheckoutBloc, CheckoutState>(
|
child: BlocBuilder<CheckoutBloc, CheckoutState>(
|
||||||
@@ -199,6 +181,7 @@ class HomeRightTitle extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ class ProductCard extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
|
if (data.isActive == true) {
|
||||||
if (data.variants!.isEmpty) {
|
if (data.variants!.isEmpty) {
|
||||||
context.read<CheckoutBloc>().add(
|
context.read<CheckoutBloc>().add(
|
||||||
CheckoutEvent.addItem(data, null),
|
CheckoutEvent.addItem(data, null),
|
||||||
@@ -33,6 +34,7 @@ class ProductCard extends StatelessWidget {
|
|||||||
builder: (context) => VariantDialog(product: data),
|
builder: (context) => VariantDialog(product: data),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
@@ -161,6 +163,14 @@ class ProductCard extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
if (data.isActive == false)
|
||||||
|
Container(
|
||||||
|
width: double.infinity,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: BorderRadius.all(Radius.circular(8.0)),
|
||||||
|
color: AppColors.grey.withOpacity(0.5),
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -17,7 +17,16 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
|||||||
|
|
||||||
class PaymentPage extends StatefulWidget {
|
class PaymentPage extends StatefulWidget {
|
||||||
final Order order;
|
final Order order;
|
||||||
const PaymentPage({Key? key, required this.order}) : super(key: key);
|
final bool isSplit;
|
||||||
|
final String? splitType;
|
||||||
|
final String? customerId;
|
||||||
|
const PaymentPage({
|
||||||
|
super.key,
|
||||||
|
required this.order,
|
||||||
|
this.isSplit = false,
|
||||||
|
this.splitType,
|
||||||
|
this.customerId,
|
||||||
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<PaymentPage> createState() => _PaymentPageState();
|
State<PaymentPage> createState() => _PaymentPageState();
|
||||||
@@ -363,7 +372,8 @@ class _PaymentPageState extends State<PaymentPage> {
|
|||||||
success: (data) {
|
success: (data) {
|
||||||
context.pushReplacement(SuccessPaymentPage(
|
context.pushReplacement(SuccessPaymentPage(
|
||||||
productQuantity: widget.order.orderItems
|
productQuantity: widget.order.orderItems
|
||||||
?.map(
|
?.where((item) => item.status == "pending")
|
||||||
|
.map(
|
||||||
(item) => ProductQuantity(
|
(item) => ProductQuantity(
|
||||||
product: Product(
|
product: Product(
|
||||||
name: item.productName,
|
name: item.productName,
|
||||||
@@ -375,6 +385,8 @@ class _PaymentPageState extends State<PaymentPage> {
|
|||||||
.toList() ??
|
.toList() ??
|
||||||
[],
|
[],
|
||||||
payment: data,
|
payment: data,
|
||||||
|
paymentMethod: selectedPaymentMethod?.name ?? '',
|
||||||
|
nominalBayar: totalPriceController.text.toIntegerFromText,
|
||||||
));
|
));
|
||||||
},
|
},
|
||||||
error: (message) {
|
error: (message) {
|
||||||
@@ -432,7 +444,7 @@ class _PaymentPageState extends State<PaymentPage> {
|
|||||||
final itemPending = widget.order.orderItems
|
final itemPending = widget.order.orderItems
|
||||||
?.where((item) => item.status == "pending")
|
?.where((item) => item.status == "pending")
|
||||||
.toList();
|
.toList();
|
||||||
|
if (widget.isSplit == false) {
|
||||||
final request = PaymentRequestModel(
|
final request = PaymentRequestModel(
|
||||||
amount: widget.order.totalAmount ?? 0,
|
amount: widget.order.totalAmount ?? 0,
|
||||||
orderId: widget.order.id,
|
orderId: widget.order.id,
|
||||||
@@ -450,5 +462,24 @@ class _PaymentPageState extends State<PaymentPage> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
context.read<PaymentFormBloc>().add(PaymentFormEvent.create(request));
|
context.read<PaymentFormBloc>().add(PaymentFormEvent.create(request));
|
||||||
|
} else {
|
||||||
|
final request = PaymentSplitBillRequest(
|
||||||
|
amount: widget.order.totalAmount ?? 0,
|
||||||
|
customerId: widget.customerId ?? "",
|
||||||
|
items: itemPending
|
||||||
|
?.map((item) => SplitItem(
|
||||||
|
orderItemId: item.id ?? "",
|
||||||
|
quantity: item.quantity ?? 0,
|
||||||
|
))
|
||||||
|
.toList() ??
|
||||||
|
[],
|
||||||
|
orderId: widget.order.id ?? "",
|
||||||
|
paymentMethodId: selectedPaymentMethod?.id ?? "",
|
||||||
|
type: widget.splitType ?? "",
|
||||||
|
);
|
||||||
|
context.read<PaymentFormBloc>().add(
|
||||||
|
PaymentFormEvent.createSplitBill(request),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import 'package:enaklo_pos/core/components/spaces.dart';
|
import 'package:enaklo_pos/core/components/spaces.dart';
|
||||||
import 'package:enaklo_pos/core/constants/colors.dart';
|
import 'package:enaklo_pos/core/constants/colors.dart';
|
||||||
|
import 'package:enaklo_pos/core/extensions/build_context_ext.dart';
|
||||||
import 'package:enaklo_pos/core/extensions/int_ext.dart';
|
import 'package:enaklo_pos/core/extensions/int_ext.dart';
|
||||||
|
import 'package:enaklo_pos/presentation/home/pages/dashboard_page.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class RefundSuccessDialog extends StatelessWidget {
|
class RefundSuccessDialog extends StatelessWidget {
|
||||||
@@ -102,8 +104,7 @@ class RefundSuccessDialog extends StatelessWidget {
|
|||||||
Expanded(
|
Expanded(
|
||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.pop(context);
|
context.push(DashboardPage());
|
||||||
Navigator.pop(context);
|
|
||||||
},
|
},
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
backgroundColor: AppColors.primary,
|
backgroundColor: AppColors.primary,
|
||||||
|
|||||||
@@ -39,7 +39,11 @@ class _RefundPageState extends State<RefundPage> with TickerProviderStateMixin {
|
|||||||
late Animation<double> _scaleAnimation;
|
late Animation<double> _scaleAnimation;
|
||||||
|
|
||||||
final List<Map<String, dynamic>> refundReasons = [
|
final List<Map<String, dynamic>> refundReasons = [
|
||||||
{'value': 'Barang Rusak', 'icon': Icons.broken_image, 'color': Colors.red},
|
{
|
||||||
|
'value': 'Barang Rusak',
|
||||||
|
'icon': Icons.broken_image,
|
||||||
|
'color': AppColors.primary
|
||||||
|
},
|
||||||
{'value': 'Salah Item', 'icon': Icons.swap_horiz, 'color': Colors.orange},
|
{'value': 'Salah Item', 'icon': Icons.swap_horiz, 'color': Colors.orange},
|
||||||
{
|
{
|
||||||
'value': 'Tidak Sesuai Pesanan',
|
'value': 'Tidak Sesuai Pesanan',
|
||||||
@@ -56,7 +60,11 @@ class _RefundPageState extends State<RefundPage> with TickerProviderStateMixin {
|
|||||||
'icon': Icons.thumb_down,
|
'icon': Icons.thumb_down,
|
||||||
'color': Colors.purple
|
'color': Colors.purple
|
||||||
},
|
},
|
||||||
{'value': 'Lainnya', 'icon': Icons.more_horiz, 'color': Colors.grey},
|
{
|
||||||
|
'value': 'Lainnya',
|
||||||
|
'icon': Icons.more_horiz,
|
||||||
|
'color': Colors.red,
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -201,13 +209,6 @@ class _RefundPageState extends State<RefundPage> with TickerProviderStateMixin {
|
|||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
borderRadius: BorderRadius.circular(24),
|
borderRadius: BorderRadius.circular(24),
|
||||||
boxShadow: [
|
|
||||||
BoxShadow(
|
|
||||||
color: Colors.black.withOpacity(0.08),
|
|
||||||
blurRadius: 30,
|
|
||||||
offset: Offset(0, 15),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: EdgeInsets.all(20),
|
padding: EdgeInsets.all(20),
|
||||||
@@ -220,16 +221,12 @@ class _RefundPageState extends State<RefundPage> with TickerProviderStateMixin {
|
|||||||
padding: EdgeInsets.all(12),
|
padding: EdgeInsets.all(12),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
gradient: LinearGradient(
|
gradient: LinearGradient(
|
||||||
colors: [Colors.green[400]!, Colors.green[600]!],
|
colors: [
|
||||||
|
const Color.fromARGB(255, 96, 56, 148),
|
||||||
|
AppColors.primary
|
||||||
|
],
|
||||||
),
|
),
|
||||||
borderRadius: BorderRadius.circular(16),
|
borderRadius: BorderRadius.circular(16),
|
||||||
boxShadow: [
|
|
||||||
BoxShadow(
|
|
||||||
color: Colors.green.withOpacity(0.3),
|
|
||||||
blurRadius: 15,
|
|
||||||
offset: Offset(0, 8),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
child: Icon(
|
child: Icon(
|
||||||
Icons.receipt_long,
|
Icons.receipt_long,
|
||||||
@@ -327,13 +324,6 @@ class _RefundPageState extends State<RefundPage> with TickerProviderStateMixin {
|
|||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
borderRadius: BorderRadius.circular(24),
|
borderRadius: BorderRadius.circular(24),
|
||||||
boxShadow: [
|
|
||||||
BoxShadow(
|
|
||||||
color: Colors.black.withOpacity(0.08),
|
|
||||||
blurRadius: 30,
|
|
||||||
offset: Offset(0, 15),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: EdgeInsets.all(20),
|
padding: EdgeInsets.all(20),
|
||||||
@@ -345,12 +335,17 @@ class _RefundPageState extends State<RefundPage> with TickerProviderStateMixin {
|
|||||||
Container(
|
Container(
|
||||||
padding: EdgeInsets.all(12),
|
padding: EdgeInsets.all(12),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.amber.withOpacity(0.2),
|
gradient: LinearGradient(
|
||||||
|
colors: [
|
||||||
|
const Color.fromARGB(255, 96, 56, 148),
|
||||||
|
AppColors.primary
|
||||||
|
],
|
||||||
|
),
|
||||||
borderRadius: BorderRadius.circular(12),
|
borderRadius: BorderRadius.circular(12),
|
||||||
),
|
),
|
||||||
child: Icon(
|
child: Icon(
|
||||||
Icons.account_balance_wallet,
|
Icons.account_balance_wallet_outlined,
|
||||||
color: Colors.amber[700],
|
color: AppColors.white,
|
||||||
size: 24,
|
size: 24,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -402,13 +397,6 @@ class _RefundPageState extends State<RefundPage> with TickerProviderStateMixin {
|
|||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
borderRadius: BorderRadius.circular(24),
|
borderRadius: BorderRadius.circular(24),
|
||||||
boxShadow: [
|
|
||||||
BoxShadow(
|
|
||||||
color: Colors.black.withOpacity(0.08),
|
|
||||||
blurRadius: 30,
|
|
||||||
offset: Offset(0, 15),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: EdgeInsets.all(20),
|
padding: EdgeInsets.all(20),
|
||||||
@@ -421,19 +409,15 @@ class _RefundPageState extends State<RefundPage> with TickerProviderStateMixin {
|
|||||||
padding: EdgeInsets.all(12),
|
padding: EdgeInsets.all(12),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
gradient: LinearGradient(
|
gradient: LinearGradient(
|
||||||
colors: [Colors.red[400]!, Colors.red[600]!],
|
colors: [
|
||||||
),
|
const Color.fromARGB(255, 96, 56, 148),
|
||||||
borderRadius: BorderRadius.circular(16),
|
AppColors.primary
|
||||||
boxShadow: [
|
|
||||||
BoxShadow(
|
|
||||||
color: Colors.red.withOpacity(0.3),
|
|
||||||
blurRadius: 15,
|
|
||||||
offset: Offset(0, 8),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
borderRadius: BorderRadius.circular(16),
|
||||||
|
),
|
||||||
child: Icon(
|
child: Icon(
|
||||||
Icons.assignment_return,
|
Icons.assignment_return_outlined,
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
size: 24,
|
size: 24,
|
||||||
),
|
),
|
||||||
@@ -655,14 +639,14 @@ class _RefundPageState extends State<RefundPage> with TickerProviderStateMixin {
|
|||||||
orElse: () => false,
|
orElse: () => false,
|
||||||
);
|
);
|
||||||
|
|
||||||
return Container(
|
return SizedBox(
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
height: 64,
|
height: 64,
|
||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
onPressed:
|
onPressed:
|
||||||
isLoading ? null : () => _processRefund(context),
|
isLoading ? null : () => _processRefund(context),
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
backgroundColor: Colors.red[600],
|
backgroundColor: AppColors.primary,
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.circular(20),
|
borderRadius: BorderRadius.circular(20),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -172,12 +172,17 @@ class ProfitLossWidget extends StatelessWidget {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (previous == 0) return '+0.0%';
|
// Handle division by zero and invalid values
|
||||||
|
if (previous == 0 || previous.isNaN || previous.isInfinite) return '+0.0%';
|
||||||
|
if (current.isNaN || current.isInfinite) return '+0.0%';
|
||||||
|
|
||||||
final trendPercentage = ((current - previous) / previous) * 100;
|
final trendPercentage = ((current - previous) / previous) * 100;
|
||||||
final sign = trendPercentage >= 0 ? '+' : '';
|
|
||||||
|
|
||||||
return '$sign${trendPercentage.toStringAsFixed(1)}%';
|
// Check if trendPercentage is valid
|
||||||
|
if (trendPercentage.isNaN || trendPercentage.isInfinite) return '+0.0%';
|
||||||
|
|
||||||
|
final sign = trendPercentage >= 0 ? '+' : '';
|
||||||
|
return '$sign${trendPercentage.round()}%';
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildSummaryCards() {
|
Widget _buildSummaryCards() {
|
||||||
@@ -201,8 +206,7 @@ class ProfitLossWidget extends StatelessWidget {
|
|||||||
{
|
{
|
||||||
'title': 'Laba Kotor',
|
'title': 'Laba Kotor',
|
||||||
'value': _formatCurrency(data.summary.grossProfit),
|
'value': _formatCurrency(data.summary.grossProfit),
|
||||||
'subtitle':
|
'subtitle': '${_safeRound(data.summary.grossProfitMargin)}% margin',
|
||||||
'${data.summary.grossProfitMargin.toStringAsFixed(1)}% margin',
|
|
||||||
'icon': Icons.trending_up,
|
'icon': Icons.trending_up,
|
||||||
'color': AppColorProfitLoss.primary,
|
'color': AppColorProfitLoss.primary,
|
||||||
'trend': _calculateTrend('grossProfit'),
|
'trend': _calculateTrend('grossProfit'),
|
||||||
@@ -210,8 +214,7 @@ class ProfitLossWidget extends StatelessWidget {
|
|||||||
{
|
{
|
||||||
'title': 'Laba Bersih',
|
'title': 'Laba Bersih',
|
||||||
'value': _formatCurrency(data.summary.netProfit),
|
'value': _formatCurrency(data.summary.netProfit),
|
||||||
'subtitle':
|
'subtitle': '${_safeRound(data.summary.netProfitMargin)}% margin',
|
||||||
'${data.summary.netProfitMargin.toStringAsFixed(1)}% margin',
|
|
||||||
'icon': Icons.account_balance,
|
'icon': Icons.account_balance,
|
||||||
'color': AppColorProfitLoss.info,
|
'color': AppColorProfitLoss.info,
|
||||||
'trend': _calculateTrend('netProfit'),
|
'trend': _calculateTrend('netProfit'),
|
||||||
@@ -360,13 +363,17 @@ class ProfitLossWidget extends StatelessWidget {
|
|||||||
showTitles: true,
|
showTitles: true,
|
||||||
reservedSize: 50,
|
reservedSize: 50,
|
||||||
getTitlesWidget: (value, meta) {
|
getTitlesWidget: (value, meta) {
|
||||||
|
final kValue = (value / 1000);
|
||||||
|
if (kValue.isFinite) {
|
||||||
return Text(
|
return Text(
|
||||||
'${(value / 1000).toInt()}K',
|
'${kValue.toInt()}K',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Colors.grey[600],
|
color: Colors.grey[600],
|
||||||
fontSize: 10,
|
fontSize: 10,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
return const SizedBox();
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -402,8 +409,9 @@ class ProfitLossWidget extends StatelessWidget {
|
|||||||
// Garis Pendapatan
|
// Garis Pendapatan
|
||||||
LineChartBarData(
|
LineChartBarData(
|
||||||
spots: data.data.asMap().entries.map((entry) {
|
spots: data.data.asMap().entries.map((entry) {
|
||||||
|
final revenue = entry.value.revenue.toDouble();
|
||||||
return FlSpot(
|
return FlSpot(
|
||||||
entry.key.toDouble(), entry.value.revenue.toDouble());
|
entry.key.toDouble(), revenue.isFinite ? revenue : 0);
|
||||||
}).toList(),
|
}).toList(),
|
||||||
isCurved: true,
|
isCurved: true,
|
||||||
color: AppColorProfitLoss.info,
|
color: AppColorProfitLoss.info,
|
||||||
@@ -412,8 +420,9 @@ class ProfitLossWidget extends StatelessWidget {
|
|||||||
// Garis Biaya
|
// Garis Biaya
|
||||||
LineChartBarData(
|
LineChartBarData(
|
||||||
spots: data.data.asMap().entries.map((entry) {
|
spots: data.data.asMap().entries.map((entry) {
|
||||||
|
final cost = entry.value.cost.toDouble();
|
||||||
return FlSpot(
|
return FlSpot(
|
||||||
entry.key.toDouble(), entry.value.cost.toDouble());
|
entry.key.toDouble(), cost.isFinite ? cost : 0);
|
||||||
}).toList(),
|
}).toList(),
|
||||||
isCurved: true,
|
isCurved: true,
|
||||||
color: AppColorProfitLoss.danger,
|
color: AppColorProfitLoss.danger,
|
||||||
@@ -422,8 +431,9 @@ class ProfitLossWidget extends StatelessWidget {
|
|||||||
// Garis Laba Bersih
|
// Garis Laba Bersih
|
||||||
LineChartBarData(
|
LineChartBarData(
|
||||||
spots: data.data.asMap().entries.map((entry) {
|
spots: data.data.asMap().entries.map((entry) {
|
||||||
|
final netProfit = entry.value.netProfit.toDouble();
|
||||||
return FlSpot(entry.key.toDouble(),
|
return FlSpot(entry.key.toDouble(),
|
||||||
entry.value.netProfit.toDouble());
|
netProfit.isFinite ? netProfit : 0);
|
||||||
}).toList(),
|
}).toList(),
|
||||||
isCurved: true,
|
isCurved: true,
|
||||||
color: AppColorProfitLoss.success,
|
color: AppColorProfitLoss.success,
|
||||||
@@ -506,9 +516,10 @@ class ProfitLossWidget extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildProductItem(ProfitLossProduct product) {
|
Widget _buildProductItem(ProfitLossProduct product) {
|
||||||
final profitColor = product.grossProfitMargin >= 35
|
final profitMargin = _safeDouble(product.grossProfitMargin);
|
||||||
|
final profitColor = profitMargin >= 35
|
||||||
? AppColorProfitLoss.success
|
? AppColorProfitLoss.success
|
||||||
: product.grossProfitMargin >= 25
|
: profitMargin >= 25
|
||||||
? AppColorProfitLoss.warning
|
? AppColorProfitLoss.warning
|
||||||
: AppColorProfitLoss.danger;
|
: AppColorProfitLoss.danger;
|
||||||
|
|
||||||
@@ -572,7 +583,7 @@ class ProfitLossWidget extends StatelessWidget {
|
|||||||
borderRadius: BorderRadius.circular(6),
|
borderRadius: BorderRadius.circular(6),
|
||||||
),
|
),
|
||||||
child: Text(
|
child: Text(
|
||||||
'${product.grossProfitMargin.toStringAsFixed(1)}%',
|
'${_safeRound(profitMargin)}%',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
@@ -710,13 +721,17 @@ class ProfitLossWidget extends StatelessWidget {
|
|||||||
startDegreeOffset: -90,
|
startDegreeOffset: -90,
|
||||||
sections: breakdownData.asMap().entries.map((entry) {
|
sections: breakdownData.asMap().entries.map((entry) {
|
||||||
final item = entry.value;
|
final item = entry.value;
|
||||||
|
final grossProfit = data.summary.grossProfit;
|
||||||
|
final value = item['value'] as int;
|
||||||
|
|
||||||
|
// Handle division by zero
|
||||||
final percentage =
|
final percentage =
|
||||||
(item['value'] as int) / data.summary.grossProfit * 100;
|
grossProfit > 0 ? (value / grossProfit * 100) : 0.0;
|
||||||
|
|
||||||
return PieChartSectionData(
|
return PieChartSectionData(
|
||||||
color: item['color'] as Color,
|
color: item['color'] as Color,
|
||||||
value: (item['value'] as int).toDouble(),
|
value: value.toDouble(),
|
||||||
title: '${percentage.toStringAsFixed(1)}%',
|
title: '${_safeRound(percentage)}%',
|
||||||
radius: 40,
|
radius: 40,
|
||||||
titleStyle: const TextStyle(
|
titleStyle: const TextStyle(
|
||||||
fontSize: 10,
|
fontSize: 10,
|
||||||
@@ -799,7 +814,7 @@ class ProfitLossWidget extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
Text(
|
Text(
|
||||||
'${(data.summary.profitabilityRatio * 100).toStringAsFixed(1)}%',
|
'${_safeRound(data.summary.profitabilityRatio)}%',
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontSize: 24,
|
fontSize: 24,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
@@ -848,9 +863,7 @@ class ProfitLossWidget extends StatelessWidget {
|
|||||||
Expanded(
|
Expanded(
|
||||||
child: _buildMetricCard(
|
child: _buildMetricCard(
|
||||||
'Nilai Rata-rata Pesanan',
|
'Nilai Rata-rata Pesanan',
|
||||||
_formatCurrency(
|
_formatCurrency(_safeCalculateAverageOrder()),
|
||||||
(data.summary.totalRevenue / data.summary.totalOrders)
|
|
||||||
.round()),
|
|
||||||
'Per transaksi',
|
'Per transaksi',
|
||||||
Icons.shopping_cart_outlined,
|
Icons.shopping_cart_outlined,
|
||||||
AppColorProfitLoss.info,
|
AppColorProfitLoss.info,
|
||||||
@@ -870,7 +883,7 @@ class ProfitLossWidget extends StatelessWidget {
|
|||||||
Expanded(
|
Expanded(
|
||||||
child: _buildMetricCard(
|
child: _buildMetricCard(
|
||||||
'Rasio Biaya',
|
'Rasio Biaya',
|
||||||
'${((data.summary.totalCost / data.summary.totalRevenue) * 100).toStringAsFixed(1)}%',
|
'${_safeCalculateCostRatio()}%',
|
||||||
'Dari total pendapatan',
|
'Dari total pendapatan',
|
||||||
Icons.pie_chart,
|
Icons.pie_chart,
|
||||||
AppColorProfitLoss.danger,
|
AppColorProfitLoss.danger,
|
||||||
@@ -1026,7 +1039,7 @@ class ProfitLossWidget extends StatelessWidget {
|
|||||||
borderRadius: BorderRadius.circular(4),
|
borderRadius: BorderRadius.circular(4),
|
||||||
),
|
),
|
||||||
child: Text(
|
child: Text(
|
||||||
'${item.netProfitMargin.toStringAsFixed(1)}%',
|
'${_safeRound(item.netProfitMargin)}%',
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 10,
|
fontSize: 10,
|
||||||
@@ -1093,6 +1106,31 @@ class ProfitLossWidget extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Helper methods for safe calculations
|
||||||
|
int _safeRound(double value) {
|
||||||
|
if (value.isNaN || value.isInfinite) return 0;
|
||||||
|
return value.round();
|
||||||
|
}
|
||||||
|
|
||||||
|
double _safeDouble(double value) {
|
||||||
|
if (value.isNaN || value.isInfinite) return 0.0;
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _safeCalculateAverageOrder() {
|
||||||
|
if (data.summary.totalOrders == 0) return 0;
|
||||||
|
final average = data.summary.totalRevenue / data.summary.totalOrders;
|
||||||
|
if (average.isNaN || average.isInfinite) return 0;
|
||||||
|
return average.round();
|
||||||
|
}
|
||||||
|
|
||||||
|
int _safeCalculateCostRatio() {
|
||||||
|
if (data.summary.totalRevenue == 0) return 0;
|
||||||
|
final ratio = (data.summary.totalCost / data.summary.totalRevenue) * 100;
|
||||||
|
if (ratio.isNaN || ratio.isInfinite) return 0;
|
||||||
|
return ratio.round();
|
||||||
|
}
|
||||||
|
|
||||||
IconData _getProductIcon(String category) {
|
IconData _getProductIcon(String category) {
|
||||||
switch (category.toLowerCase()) {
|
switch (category.toLowerCase()) {
|
||||||
case 'coffee':
|
case 'coffee':
|
||||||
@@ -1110,8 +1148,9 @@ class ProfitLossWidget extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Color _getMarginColor(double margin) {
|
Color _getMarginColor(double margin) {
|
||||||
if (margin >= 25) return AppColorProfitLoss.success;
|
final safeMargin = _safeDouble(margin);
|
||||||
if (margin >= 15) return AppColorProfitLoss.warning;
|
if (safeMargin >= 25) return AppColorProfitLoss.success;
|
||||||
|
if (safeMargin >= 15) return AppColorProfitLoss.warning;
|
||||||
return AppColorProfitLoss.danger;
|
return AppColorProfitLoss.danger;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1126,7 +1165,7 @@ class ProfitLossWidget extends StatelessWidget {
|
|||||||
|
|
||||||
String _formatCurrencyShort(int amount) {
|
String _formatCurrencyShort(int amount) {
|
||||||
if (amount >= 1000000) {
|
if (amount >= 1000000) {
|
||||||
return 'Rp ${(amount / 1000000).toStringAsFixed(1)}M';
|
return 'Rp ${(amount / 1000000).round()}M';
|
||||||
} else if (amount >= 1000) {
|
} else if (amount >= 1000) {
|
||||||
return 'Rp ${(amount / 1000).toStringAsFixed(0)}K';
|
return 'Rp ${(amount / 1000).toStringAsFixed(0)}K';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ class OrderLoaderBloc extends Bloc<OrderLoaderEvent, OrderLoaderState> {
|
|||||||
status: event.status,
|
status: event.status,
|
||||||
dateFrom: event.dateFrom,
|
dateFrom: event.dateFrom,
|
||||||
dateTo: event.dateTo,
|
dateTo: event.dateTo,
|
||||||
|
search: event.search,
|
||||||
);
|
);
|
||||||
|
|
||||||
await result.fold(
|
await result.fold(
|
||||||
@@ -108,6 +109,7 @@ class OrderLoaderBloc extends Bloc<OrderLoaderEvent, OrderLoaderState> {
|
|||||||
status: event.status,
|
status: event.status,
|
||||||
dateFrom: event.dateFrom,
|
dateFrom: event.dateFrom,
|
||||||
dateTo: event.dateTo,
|
dateTo: event.dateTo,
|
||||||
|
search: event.search,
|
||||||
);
|
);
|
||||||
|
|
||||||
await result.fold(
|
await result.fold(
|
||||||
|
|||||||
@@ -18,33 +18,36 @@ final _privateConstructorUsedError = UnsupportedError(
|
|||||||
mixin _$OrderLoaderEvent {
|
mixin _$OrderLoaderEvent {
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult when<TResult extends Object?>({
|
TResult when<TResult extends Object?>({
|
||||||
required TResult Function(
|
required TResult Function(String status, DateTime dateFrom, DateTime dateTo,
|
||||||
String status, DateTime dateFrom, DateTime dateTo, int? limit)
|
int? limit, String? search)
|
||||||
getByStatus,
|
getByStatus,
|
||||||
required TResult Function(String id) getById,
|
required TResult Function(String id) getById,
|
||||||
required TResult Function(String status, DateTime dateFrom, DateTime dateTo)
|
required TResult Function(
|
||||||
|
String status, DateTime dateFrom, DateTime dateTo, String? search)
|
||||||
loadMore,
|
loadMore,
|
||||||
required TResult Function(String status) refresh,
|
required TResult Function(String status) refresh,
|
||||||
}) =>
|
}) =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult? whenOrNull<TResult extends Object?>({
|
TResult? whenOrNull<TResult extends Object?>({
|
||||||
TResult? Function(
|
TResult? Function(String status, DateTime dateFrom, DateTime dateTo,
|
||||||
String status, DateTime dateFrom, DateTime dateTo, int? limit)?
|
int? limit, String? search)?
|
||||||
getByStatus,
|
getByStatus,
|
||||||
TResult? Function(String id)? getById,
|
TResult? Function(String id)? getById,
|
||||||
TResult? Function(String status, DateTime dateFrom, DateTime dateTo)?
|
TResult? Function(
|
||||||
|
String status, DateTime dateFrom, DateTime dateTo, String? search)?
|
||||||
loadMore,
|
loadMore,
|
||||||
TResult? Function(String status)? refresh,
|
TResult? Function(String status)? refresh,
|
||||||
}) =>
|
}) =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
TResult maybeWhen<TResult extends Object?>({
|
||||||
TResult Function(
|
TResult Function(String status, DateTime dateFrom, DateTime dateTo,
|
||||||
String status, DateTime dateFrom, DateTime dateTo, int? limit)?
|
int? limit, String? search)?
|
||||||
getByStatus,
|
getByStatus,
|
||||||
TResult Function(String id)? getById,
|
TResult Function(String id)? getById,
|
||||||
TResult Function(String status, DateTime dateFrom, DateTime dateTo)?
|
TResult Function(
|
||||||
|
String status, DateTime dateFrom, DateTime dateTo, String? search)?
|
||||||
loadMore,
|
loadMore,
|
||||||
TResult Function(String status)? refresh,
|
TResult Function(String status)? refresh,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
@@ -104,7 +107,12 @@ abstract class _$$GetByStatusImplCopyWith<$Res> {
|
|||||||
_$GetByStatusImpl value, $Res Function(_$GetByStatusImpl) then) =
|
_$GetByStatusImpl value, $Res Function(_$GetByStatusImpl) then) =
|
||||||
__$$GetByStatusImplCopyWithImpl<$Res>;
|
__$$GetByStatusImplCopyWithImpl<$Res>;
|
||||||
@useResult
|
@useResult
|
||||||
$Res call({String status, DateTime dateFrom, DateTime dateTo, int? limit});
|
$Res call(
|
||||||
|
{String status,
|
||||||
|
DateTime dateFrom,
|
||||||
|
DateTime dateTo,
|
||||||
|
int? limit,
|
||||||
|
String? search});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
@@ -124,6 +132,7 @@ class __$$GetByStatusImplCopyWithImpl<$Res>
|
|||||||
Object? dateFrom = null,
|
Object? dateFrom = null,
|
||||||
Object? dateTo = null,
|
Object? dateTo = null,
|
||||||
Object? limit = freezed,
|
Object? limit = freezed,
|
||||||
|
Object? search = freezed,
|
||||||
}) {
|
}) {
|
||||||
return _then(_$GetByStatusImpl(
|
return _then(_$GetByStatusImpl(
|
||||||
null == status
|
null == status
|
||||||
@@ -142,6 +151,10 @@ class __$$GetByStatusImplCopyWithImpl<$Res>
|
|||||||
? _value.limit
|
? _value.limit
|
||||||
: limit // ignore: cast_nullable_to_non_nullable
|
: limit // ignore: cast_nullable_to_non_nullable
|
||||||
as int?,
|
as int?,
|
||||||
|
search: freezed == search
|
||||||
|
? _value.search
|
||||||
|
: search // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String?,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -150,7 +163,7 @@ class __$$GetByStatusImplCopyWithImpl<$Res>
|
|||||||
|
|
||||||
class _$GetByStatusImpl implements _GetByStatus {
|
class _$GetByStatusImpl implements _GetByStatus {
|
||||||
const _$GetByStatusImpl(this.status,
|
const _$GetByStatusImpl(this.status,
|
||||||
{required this.dateFrom, required this.dateTo, this.limit});
|
{required this.dateFrom, required this.dateTo, this.limit, this.search});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
final String status;
|
final String status;
|
||||||
@@ -160,10 +173,12 @@ class _$GetByStatusImpl implements _GetByStatus {
|
|||||||
final DateTime dateTo;
|
final DateTime dateTo;
|
||||||
@override
|
@override
|
||||||
final int? limit;
|
final int? limit;
|
||||||
|
@override
|
||||||
|
final String? search;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'OrderLoaderEvent.getByStatus(status: $status, dateFrom: $dateFrom, dateTo: $dateTo, limit: $limit)';
|
return 'OrderLoaderEvent.getByStatus(status: $status, dateFrom: $dateFrom, dateTo: $dateTo, limit: $limit, search: $search)';
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -175,11 +190,13 @@ class _$GetByStatusImpl implements _GetByStatus {
|
|||||||
(identical(other.dateFrom, dateFrom) ||
|
(identical(other.dateFrom, dateFrom) ||
|
||||||
other.dateFrom == dateFrom) &&
|
other.dateFrom == dateFrom) &&
|
||||||
(identical(other.dateTo, dateTo) || other.dateTo == dateTo) &&
|
(identical(other.dateTo, dateTo) || other.dateTo == dateTo) &&
|
||||||
(identical(other.limit, limit) || other.limit == limit));
|
(identical(other.limit, limit) || other.limit == limit) &&
|
||||||
|
(identical(other.search, search) || other.search == search));
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
int get hashCode => Object.hash(runtimeType, status, dateFrom, dateTo, limit);
|
int get hashCode =>
|
||||||
|
Object.hash(runtimeType, status, dateFrom, dateTo, limit, search);
|
||||||
|
|
||||||
/// Create a copy of OrderLoaderEvent
|
/// Create a copy of OrderLoaderEvent
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@@ -192,45 +209,48 @@ class _$GetByStatusImpl implements _GetByStatus {
|
|||||||
@override
|
@override
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult when<TResult extends Object?>({
|
TResult when<TResult extends Object?>({
|
||||||
required TResult Function(
|
required TResult Function(String status, DateTime dateFrom, DateTime dateTo,
|
||||||
String status, DateTime dateFrom, DateTime dateTo, int? limit)
|
int? limit, String? search)
|
||||||
getByStatus,
|
getByStatus,
|
||||||
required TResult Function(String id) getById,
|
required TResult Function(String id) getById,
|
||||||
required TResult Function(String status, DateTime dateFrom, DateTime dateTo)
|
required TResult Function(
|
||||||
|
String status, DateTime dateFrom, DateTime dateTo, String? search)
|
||||||
loadMore,
|
loadMore,
|
||||||
required TResult Function(String status) refresh,
|
required TResult Function(String status) refresh,
|
||||||
}) {
|
}) {
|
||||||
return getByStatus(status, dateFrom, dateTo, limit);
|
return getByStatus(status, dateFrom, dateTo, limit, search);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult? whenOrNull<TResult extends Object?>({
|
TResult? whenOrNull<TResult extends Object?>({
|
||||||
TResult? Function(
|
TResult? Function(String status, DateTime dateFrom, DateTime dateTo,
|
||||||
String status, DateTime dateFrom, DateTime dateTo, int? limit)?
|
int? limit, String? search)?
|
||||||
getByStatus,
|
getByStatus,
|
||||||
TResult? Function(String id)? getById,
|
TResult? Function(String id)? getById,
|
||||||
TResult? Function(String status, DateTime dateFrom, DateTime dateTo)?
|
TResult? Function(
|
||||||
|
String status, DateTime dateFrom, DateTime dateTo, String? search)?
|
||||||
loadMore,
|
loadMore,
|
||||||
TResult? Function(String status)? refresh,
|
TResult? Function(String status)? refresh,
|
||||||
}) {
|
}) {
|
||||||
return getByStatus?.call(status, dateFrom, dateTo, limit);
|
return getByStatus?.call(status, dateFrom, dateTo, limit, search);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
TResult maybeWhen<TResult extends Object?>({
|
||||||
TResult Function(
|
TResult Function(String status, DateTime dateFrom, DateTime dateTo,
|
||||||
String status, DateTime dateFrom, DateTime dateTo, int? limit)?
|
int? limit, String? search)?
|
||||||
getByStatus,
|
getByStatus,
|
||||||
TResult Function(String id)? getById,
|
TResult Function(String id)? getById,
|
||||||
TResult Function(String status, DateTime dateFrom, DateTime dateTo)?
|
TResult Function(
|
||||||
|
String status, DateTime dateFrom, DateTime dateTo, String? search)?
|
||||||
loadMore,
|
loadMore,
|
||||||
TResult Function(String status)? refresh,
|
TResult Function(String status)? refresh,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) {
|
}) {
|
||||||
if (getByStatus != null) {
|
if (getByStatus != null) {
|
||||||
return getByStatus(status, dateFrom, dateTo, limit);
|
return getByStatus(status, dateFrom, dateTo, limit, search);
|
||||||
}
|
}
|
||||||
return orElse();
|
return orElse();
|
||||||
}
|
}
|
||||||
@@ -277,12 +297,14 @@ abstract class _GetByStatus implements OrderLoaderEvent {
|
|||||||
const factory _GetByStatus(final String status,
|
const factory _GetByStatus(final String status,
|
||||||
{required final DateTime dateFrom,
|
{required final DateTime dateFrom,
|
||||||
required final DateTime dateTo,
|
required final DateTime dateTo,
|
||||||
final int? limit}) = _$GetByStatusImpl;
|
final int? limit,
|
||||||
|
final String? search}) = _$GetByStatusImpl;
|
||||||
|
|
||||||
String get status;
|
String get status;
|
||||||
DateTime get dateFrom;
|
DateTime get dateFrom;
|
||||||
DateTime get dateTo;
|
DateTime get dateTo;
|
||||||
int? get limit;
|
int? get limit;
|
||||||
|
String? get search;
|
||||||
|
|
||||||
/// Create a copy of OrderLoaderEvent
|
/// Create a copy of OrderLoaderEvent
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@@ -359,11 +381,12 @@ class _$GetByIdImpl implements _GetById {
|
|||||||
@override
|
@override
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult when<TResult extends Object?>({
|
TResult when<TResult extends Object?>({
|
||||||
required TResult Function(
|
required TResult Function(String status, DateTime dateFrom, DateTime dateTo,
|
||||||
String status, DateTime dateFrom, DateTime dateTo, int? limit)
|
int? limit, String? search)
|
||||||
getByStatus,
|
getByStatus,
|
||||||
required TResult Function(String id) getById,
|
required TResult Function(String id) getById,
|
||||||
required TResult Function(String status, DateTime dateFrom, DateTime dateTo)
|
required TResult Function(
|
||||||
|
String status, DateTime dateFrom, DateTime dateTo, String? search)
|
||||||
loadMore,
|
loadMore,
|
||||||
required TResult Function(String status) refresh,
|
required TResult Function(String status) refresh,
|
||||||
}) {
|
}) {
|
||||||
@@ -373,11 +396,12 @@ class _$GetByIdImpl implements _GetById {
|
|||||||
@override
|
@override
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult? whenOrNull<TResult extends Object?>({
|
TResult? whenOrNull<TResult extends Object?>({
|
||||||
TResult? Function(
|
TResult? Function(String status, DateTime dateFrom, DateTime dateTo,
|
||||||
String status, DateTime dateFrom, DateTime dateTo, int? limit)?
|
int? limit, String? search)?
|
||||||
getByStatus,
|
getByStatus,
|
||||||
TResult? Function(String id)? getById,
|
TResult? Function(String id)? getById,
|
||||||
TResult? Function(String status, DateTime dateFrom, DateTime dateTo)?
|
TResult? Function(
|
||||||
|
String status, DateTime dateFrom, DateTime dateTo, String? search)?
|
||||||
loadMore,
|
loadMore,
|
||||||
TResult? Function(String status)? refresh,
|
TResult? Function(String status)? refresh,
|
||||||
}) {
|
}) {
|
||||||
@@ -387,11 +411,12 @@ class _$GetByIdImpl implements _GetById {
|
|||||||
@override
|
@override
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
TResult maybeWhen<TResult extends Object?>({
|
||||||
TResult Function(
|
TResult Function(String status, DateTime dateFrom, DateTime dateTo,
|
||||||
String status, DateTime dateFrom, DateTime dateTo, int? limit)?
|
int? limit, String? search)?
|
||||||
getByStatus,
|
getByStatus,
|
||||||
TResult Function(String id)? getById,
|
TResult Function(String id)? getById,
|
||||||
TResult Function(String status, DateTime dateFrom, DateTime dateTo)?
|
TResult Function(
|
||||||
|
String status, DateTime dateFrom, DateTime dateTo, String? search)?
|
||||||
loadMore,
|
loadMore,
|
||||||
TResult Function(String status)? refresh,
|
TResult Function(String status)? refresh,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
@@ -458,7 +483,8 @@ abstract class _$$LoadMoreImplCopyWith<$Res> {
|
|||||||
_$LoadMoreImpl value, $Res Function(_$LoadMoreImpl) then) =
|
_$LoadMoreImpl value, $Res Function(_$LoadMoreImpl) then) =
|
||||||
__$$LoadMoreImplCopyWithImpl<$Res>;
|
__$$LoadMoreImplCopyWithImpl<$Res>;
|
||||||
@useResult
|
@useResult
|
||||||
$Res call({String status, DateTime dateFrom, DateTime dateTo});
|
$Res call(
|
||||||
|
{String status, DateTime dateFrom, DateTime dateTo, String? search});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
@@ -477,6 +503,7 @@ class __$$LoadMoreImplCopyWithImpl<$Res>
|
|||||||
Object? status = null,
|
Object? status = null,
|
||||||
Object? dateFrom = null,
|
Object? dateFrom = null,
|
||||||
Object? dateTo = null,
|
Object? dateTo = null,
|
||||||
|
Object? search = freezed,
|
||||||
}) {
|
}) {
|
||||||
return _then(_$LoadMoreImpl(
|
return _then(_$LoadMoreImpl(
|
||||||
null == status
|
null == status
|
||||||
@@ -491,6 +518,10 @@ class __$$LoadMoreImplCopyWithImpl<$Res>
|
|||||||
? _value.dateTo
|
? _value.dateTo
|
||||||
: dateTo // ignore: cast_nullable_to_non_nullable
|
: dateTo // ignore: cast_nullable_to_non_nullable
|
||||||
as DateTime,
|
as DateTime,
|
||||||
|
search: freezed == search
|
||||||
|
? _value.search
|
||||||
|
: search // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String?,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -499,7 +530,7 @@ class __$$LoadMoreImplCopyWithImpl<$Res>
|
|||||||
|
|
||||||
class _$LoadMoreImpl implements _LoadMore {
|
class _$LoadMoreImpl implements _LoadMore {
|
||||||
const _$LoadMoreImpl(this.status,
|
const _$LoadMoreImpl(this.status,
|
||||||
{required this.dateFrom, required this.dateTo});
|
{required this.dateFrom, required this.dateTo, this.search});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
final String status;
|
final String status;
|
||||||
@@ -507,10 +538,12 @@ class _$LoadMoreImpl implements _LoadMore {
|
|||||||
final DateTime dateFrom;
|
final DateTime dateFrom;
|
||||||
@override
|
@override
|
||||||
final DateTime dateTo;
|
final DateTime dateTo;
|
||||||
|
@override
|
||||||
|
final String? search;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'OrderLoaderEvent.loadMore(status: $status, dateFrom: $dateFrom, dateTo: $dateTo)';
|
return 'OrderLoaderEvent.loadMore(status: $status, dateFrom: $dateFrom, dateTo: $dateTo, search: $search)';
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -521,11 +554,13 @@ class _$LoadMoreImpl implements _LoadMore {
|
|||||||
(identical(other.status, status) || other.status == status) &&
|
(identical(other.status, status) || other.status == status) &&
|
||||||
(identical(other.dateFrom, dateFrom) ||
|
(identical(other.dateFrom, dateFrom) ||
|
||||||
other.dateFrom == dateFrom) &&
|
other.dateFrom == dateFrom) &&
|
||||||
(identical(other.dateTo, dateTo) || other.dateTo == dateTo));
|
(identical(other.dateTo, dateTo) || other.dateTo == dateTo) &&
|
||||||
|
(identical(other.search, search) || other.search == search));
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
int get hashCode => Object.hash(runtimeType, status, dateFrom, dateTo);
|
int get hashCode =>
|
||||||
|
Object.hash(runtimeType, status, dateFrom, dateTo, search);
|
||||||
|
|
||||||
/// Create a copy of OrderLoaderEvent
|
/// Create a copy of OrderLoaderEvent
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@@ -538,45 +573,48 @@ class _$LoadMoreImpl implements _LoadMore {
|
|||||||
@override
|
@override
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult when<TResult extends Object?>({
|
TResult when<TResult extends Object?>({
|
||||||
required TResult Function(
|
required TResult Function(String status, DateTime dateFrom, DateTime dateTo,
|
||||||
String status, DateTime dateFrom, DateTime dateTo, int? limit)
|
int? limit, String? search)
|
||||||
getByStatus,
|
getByStatus,
|
||||||
required TResult Function(String id) getById,
|
required TResult Function(String id) getById,
|
||||||
required TResult Function(String status, DateTime dateFrom, DateTime dateTo)
|
required TResult Function(
|
||||||
|
String status, DateTime dateFrom, DateTime dateTo, String? search)
|
||||||
loadMore,
|
loadMore,
|
||||||
required TResult Function(String status) refresh,
|
required TResult Function(String status) refresh,
|
||||||
}) {
|
}) {
|
||||||
return loadMore(status, dateFrom, dateTo);
|
return loadMore(status, dateFrom, dateTo, search);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult? whenOrNull<TResult extends Object?>({
|
TResult? whenOrNull<TResult extends Object?>({
|
||||||
TResult? Function(
|
TResult? Function(String status, DateTime dateFrom, DateTime dateTo,
|
||||||
String status, DateTime dateFrom, DateTime dateTo, int? limit)?
|
int? limit, String? search)?
|
||||||
getByStatus,
|
getByStatus,
|
||||||
TResult? Function(String id)? getById,
|
TResult? Function(String id)? getById,
|
||||||
TResult? Function(String status, DateTime dateFrom, DateTime dateTo)?
|
TResult? Function(
|
||||||
|
String status, DateTime dateFrom, DateTime dateTo, String? search)?
|
||||||
loadMore,
|
loadMore,
|
||||||
TResult? Function(String status)? refresh,
|
TResult? Function(String status)? refresh,
|
||||||
}) {
|
}) {
|
||||||
return loadMore?.call(status, dateFrom, dateTo);
|
return loadMore?.call(status, dateFrom, dateTo, search);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
TResult maybeWhen<TResult extends Object?>({
|
||||||
TResult Function(
|
TResult Function(String status, DateTime dateFrom, DateTime dateTo,
|
||||||
String status, DateTime dateFrom, DateTime dateTo, int? limit)?
|
int? limit, String? search)?
|
||||||
getByStatus,
|
getByStatus,
|
||||||
TResult Function(String id)? getById,
|
TResult Function(String id)? getById,
|
||||||
TResult Function(String status, DateTime dateFrom, DateTime dateTo)?
|
TResult Function(
|
||||||
|
String status, DateTime dateFrom, DateTime dateTo, String? search)?
|
||||||
loadMore,
|
loadMore,
|
||||||
TResult Function(String status)? refresh,
|
TResult Function(String status)? refresh,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) {
|
}) {
|
||||||
if (loadMore != null) {
|
if (loadMore != null) {
|
||||||
return loadMore(status, dateFrom, dateTo);
|
return loadMore(status, dateFrom, dateTo, search);
|
||||||
}
|
}
|
||||||
return orElse();
|
return orElse();
|
||||||
}
|
}
|
||||||
@@ -622,11 +660,13 @@ class _$LoadMoreImpl implements _LoadMore {
|
|||||||
abstract class _LoadMore implements OrderLoaderEvent {
|
abstract class _LoadMore implements OrderLoaderEvent {
|
||||||
const factory _LoadMore(final String status,
|
const factory _LoadMore(final String status,
|
||||||
{required final DateTime dateFrom,
|
{required final DateTime dateFrom,
|
||||||
required final DateTime dateTo}) = _$LoadMoreImpl;
|
required final DateTime dateTo,
|
||||||
|
final String? search}) = _$LoadMoreImpl;
|
||||||
|
|
||||||
String get status;
|
String get status;
|
||||||
DateTime get dateFrom;
|
DateTime get dateFrom;
|
||||||
DateTime get dateTo;
|
DateTime get dateTo;
|
||||||
|
String? get search;
|
||||||
|
|
||||||
/// Create a copy of OrderLoaderEvent
|
/// Create a copy of OrderLoaderEvent
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@@ -703,11 +743,12 @@ class _$RefreshImpl implements _Refresh {
|
|||||||
@override
|
@override
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult when<TResult extends Object?>({
|
TResult when<TResult extends Object?>({
|
||||||
required TResult Function(
|
required TResult Function(String status, DateTime dateFrom, DateTime dateTo,
|
||||||
String status, DateTime dateFrom, DateTime dateTo, int? limit)
|
int? limit, String? search)
|
||||||
getByStatus,
|
getByStatus,
|
||||||
required TResult Function(String id) getById,
|
required TResult Function(String id) getById,
|
||||||
required TResult Function(String status, DateTime dateFrom, DateTime dateTo)
|
required TResult Function(
|
||||||
|
String status, DateTime dateFrom, DateTime dateTo, String? search)
|
||||||
loadMore,
|
loadMore,
|
||||||
required TResult Function(String status) refresh,
|
required TResult Function(String status) refresh,
|
||||||
}) {
|
}) {
|
||||||
@@ -717,11 +758,12 @@ class _$RefreshImpl implements _Refresh {
|
|||||||
@override
|
@override
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult? whenOrNull<TResult extends Object?>({
|
TResult? whenOrNull<TResult extends Object?>({
|
||||||
TResult? Function(
|
TResult? Function(String status, DateTime dateFrom, DateTime dateTo,
|
||||||
String status, DateTime dateFrom, DateTime dateTo, int? limit)?
|
int? limit, String? search)?
|
||||||
getByStatus,
|
getByStatus,
|
||||||
TResult? Function(String id)? getById,
|
TResult? Function(String id)? getById,
|
||||||
TResult? Function(String status, DateTime dateFrom, DateTime dateTo)?
|
TResult? Function(
|
||||||
|
String status, DateTime dateFrom, DateTime dateTo, String? search)?
|
||||||
loadMore,
|
loadMore,
|
||||||
TResult? Function(String status)? refresh,
|
TResult? Function(String status)? refresh,
|
||||||
}) {
|
}) {
|
||||||
@@ -731,11 +773,12 @@ class _$RefreshImpl implements _Refresh {
|
|||||||
@override
|
@override
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
TResult maybeWhen<TResult extends Object?>({
|
||||||
TResult Function(
|
TResult Function(String status, DateTime dateFrom, DateTime dateTo,
|
||||||
String status, DateTime dateFrom, DateTime dateTo, int? limit)?
|
int? limit, String? search)?
|
||||||
getByStatus,
|
getByStatus,
|
||||||
TResult Function(String id)? getById,
|
TResult Function(String id)? getById,
|
||||||
TResult Function(String status, DateTime dateFrom, DateTime dateTo)?
|
TResult Function(
|
||||||
|
String status, DateTime dateFrom, DateTime dateTo, String? search)?
|
||||||
loadMore,
|
loadMore,
|
||||||
TResult Function(String status)? refresh,
|
TResult Function(String status)? refresh,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
|
|||||||
@@ -2,15 +2,19 @@ part of 'order_loader_bloc.dart';
|
|||||||
|
|
||||||
@freezed
|
@freezed
|
||||||
class OrderLoaderEvent with _$OrderLoaderEvent {
|
class OrderLoaderEvent with _$OrderLoaderEvent {
|
||||||
const factory OrderLoaderEvent.getByStatus(String status,
|
const factory OrderLoaderEvent.getByStatus(
|
||||||
{required DateTime dateFrom,
|
String status, {
|
||||||
|
required DateTime dateFrom,
|
||||||
required DateTime dateTo,
|
required DateTime dateTo,
|
||||||
int? limit}) = _GetByStatus;
|
int? limit,
|
||||||
|
String? search,
|
||||||
|
}) = _GetByStatus;
|
||||||
const factory OrderLoaderEvent.getById(String id) = _GetById;
|
const factory OrderLoaderEvent.getById(String id) = _GetById;
|
||||||
const factory OrderLoaderEvent.loadMore(
|
const factory OrderLoaderEvent.loadMore(
|
||||||
String status, {
|
String status, {
|
||||||
required DateTime dateFrom,
|
required DateTime dateFrom,
|
||||||
required DateTime dateTo,
|
required DateTime dateTo,
|
||||||
|
String? search,
|
||||||
}) = _LoadMore;
|
}) = _LoadMore;
|
||||||
const factory OrderLoaderEvent.refresh(String status) = _Refresh;
|
const factory OrderLoaderEvent.refresh(String status) = _Refresh;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,5 +29,22 @@ class PaymentFormBloc extends Bloc<PaymentFormEvent, PaymentFormState> {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
on<_CreateSplitBill>(
|
||||||
|
(event, emit) async {
|
||||||
|
emit(const _Loading());
|
||||||
|
|
||||||
|
try {
|
||||||
|
final result = await _orderRemoteDatasource
|
||||||
|
.createPaymentSplitBill(event.payment);
|
||||||
|
|
||||||
|
result.fold(
|
||||||
|
(error) => emit(_Error(error)),
|
||||||
|
(success) => emit(_Success(success.data!)),
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
emit(_Error("Failed to create payment split bill: $e"));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,45 +16,45 @@ final _privateConstructorUsedError = UnsupportedError(
|
|||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
mixin _$PaymentFormEvent {
|
mixin _$PaymentFormEvent {
|
||||||
PaymentRequestModel get payment => throw _privateConstructorUsedError;
|
Object get payment => throw _privateConstructorUsedError;
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult when<TResult extends Object?>({
|
TResult when<TResult extends Object?>({
|
||||||
required TResult Function(PaymentRequestModel payment) create,
|
required TResult Function(PaymentRequestModel payment) create,
|
||||||
|
required TResult Function(PaymentSplitBillRequest payment) createSplitBill,
|
||||||
}) =>
|
}) =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult? whenOrNull<TResult extends Object?>({
|
TResult? whenOrNull<TResult extends Object?>({
|
||||||
TResult? Function(PaymentRequestModel payment)? create,
|
TResult? Function(PaymentRequestModel payment)? create,
|
||||||
|
TResult? Function(PaymentSplitBillRequest payment)? createSplitBill,
|
||||||
}) =>
|
}) =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
TResult maybeWhen<TResult extends Object?>({
|
||||||
TResult Function(PaymentRequestModel payment)? create,
|
TResult Function(PaymentRequestModel payment)? create,
|
||||||
|
TResult Function(PaymentSplitBillRequest payment)? createSplitBill,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) =>
|
}) =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult map<TResult extends Object?>({
|
TResult map<TResult extends Object?>({
|
||||||
required TResult Function(_Create value) create,
|
required TResult Function(_Create value) create,
|
||||||
|
required TResult Function(_CreateSplitBill value) createSplitBill,
|
||||||
}) =>
|
}) =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult? mapOrNull<TResult extends Object?>({
|
TResult? mapOrNull<TResult extends Object?>({
|
||||||
TResult? Function(_Create value)? create,
|
TResult? Function(_Create value)? create,
|
||||||
|
TResult? Function(_CreateSplitBill value)? createSplitBill,
|
||||||
}) =>
|
}) =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult maybeMap<TResult extends Object?>({
|
TResult maybeMap<TResult extends Object?>({
|
||||||
TResult Function(_Create value)? create,
|
TResult Function(_Create value)? create,
|
||||||
|
TResult Function(_CreateSplitBill value)? createSplitBill,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) =>
|
}) =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
|
|
||||||
/// Create a copy of PaymentFormEvent
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
||||||
$PaymentFormEventCopyWith<PaymentFormEvent> get copyWith =>
|
|
||||||
throw _privateConstructorUsedError;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
@@ -62,8 +62,6 @@ abstract class $PaymentFormEventCopyWith<$Res> {
|
|||||||
factory $PaymentFormEventCopyWith(
|
factory $PaymentFormEventCopyWith(
|
||||||
PaymentFormEvent value, $Res Function(PaymentFormEvent) then) =
|
PaymentFormEvent value, $Res Function(PaymentFormEvent) then) =
|
||||||
_$PaymentFormEventCopyWithImpl<$Res, PaymentFormEvent>;
|
_$PaymentFormEventCopyWithImpl<$Res, PaymentFormEvent>;
|
||||||
@useResult
|
|
||||||
$Res call({PaymentRequestModel payment});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
@@ -78,27 +76,13 @@ class _$PaymentFormEventCopyWithImpl<$Res, $Val extends PaymentFormEvent>
|
|||||||
|
|
||||||
/// Create a copy of PaymentFormEvent
|
/// Create a copy of PaymentFormEvent
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
@override
|
|
||||||
$Res call({
|
|
||||||
Object? payment = null,
|
|
||||||
}) {
|
|
||||||
return _then(_value.copyWith(
|
|
||||||
payment: null == payment
|
|
||||||
? _value.payment
|
|
||||||
: payment // ignore: cast_nullable_to_non_nullable
|
|
||||||
as PaymentRequestModel,
|
|
||||||
) as $Val);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
abstract class _$$CreateImplCopyWith<$Res>
|
abstract class _$$CreateImplCopyWith<$Res> {
|
||||||
implements $PaymentFormEventCopyWith<$Res> {
|
|
||||||
factory _$$CreateImplCopyWith(
|
factory _$$CreateImplCopyWith(
|
||||||
_$CreateImpl value, $Res Function(_$CreateImpl) then) =
|
_$CreateImpl value, $Res Function(_$CreateImpl) then) =
|
||||||
__$$CreateImplCopyWithImpl<$Res>;
|
__$$CreateImplCopyWithImpl<$Res>;
|
||||||
@override
|
|
||||||
@useResult
|
@useResult
|
||||||
$Res call({PaymentRequestModel payment});
|
$Res call({PaymentRequestModel payment});
|
||||||
}
|
}
|
||||||
@@ -163,6 +147,7 @@ class _$CreateImpl implements _Create {
|
|||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult when<TResult extends Object?>({
|
TResult when<TResult extends Object?>({
|
||||||
required TResult Function(PaymentRequestModel payment) create,
|
required TResult Function(PaymentRequestModel payment) create,
|
||||||
|
required TResult Function(PaymentSplitBillRequest payment) createSplitBill,
|
||||||
}) {
|
}) {
|
||||||
return create(payment);
|
return create(payment);
|
||||||
}
|
}
|
||||||
@@ -171,6 +156,7 @@ class _$CreateImpl implements _Create {
|
|||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult? whenOrNull<TResult extends Object?>({
|
TResult? whenOrNull<TResult extends Object?>({
|
||||||
TResult? Function(PaymentRequestModel payment)? create,
|
TResult? Function(PaymentRequestModel payment)? create,
|
||||||
|
TResult? Function(PaymentSplitBillRequest payment)? createSplitBill,
|
||||||
}) {
|
}) {
|
||||||
return create?.call(payment);
|
return create?.call(payment);
|
||||||
}
|
}
|
||||||
@@ -179,6 +165,7 @@ class _$CreateImpl implements _Create {
|
|||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
TResult maybeWhen<TResult extends Object?>({
|
||||||
TResult Function(PaymentRequestModel payment)? create,
|
TResult Function(PaymentRequestModel payment)? create,
|
||||||
|
TResult Function(PaymentSplitBillRequest payment)? createSplitBill,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) {
|
}) {
|
||||||
if (create != null) {
|
if (create != null) {
|
||||||
@@ -191,6 +178,7 @@ class _$CreateImpl implements _Create {
|
|||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult map<TResult extends Object?>({
|
TResult map<TResult extends Object?>({
|
||||||
required TResult Function(_Create value) create,
|
required TResult Function(_Create value) create,
|
||||||
|
required TResult Function(_CreateSplitBill value) createSplitBill,
|
||||||
}) {
|
}) {
|
||||||
return create(this);
|
return create(this);
|
||||||
}
|
}
|
||||||
@@ -199,6 +187,7 @@ class _$CreateImpl implements _Create {
|
|||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult? mapOrNull<TResult extends Object?>({
|
TResult? mapOrNull<TResult extends Object?>({
|
||||||
TResult? Function(_Create value)? create,
|
TResult? Function(_Create value)? create,
|
||||||
|
TResult? Function(_CreateSplitBill value)? createSplitBill,
|
||||||
}) {
|
}) {
|
||||||
return create?.call(this);
|
return create?.call(this);
|
||||||
}
|
}
|
||||||
@@ -207,6 +196,7 @@ class _$CreateImpl implements _Create {
|
|||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult maybeMap<TResult extends Object?>({
|
TResult maybeMap<TResult extends Object?>({
|
||||||
TResult Function(_Create value)? create,
|
TResult Function(_Create value)? create,
|
||||||
|
TResult Function(_CreateSplitBill value)? createSplitBill,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) {
|
}) {
|
||||||
if (create != null) {
|
if (create != null) {
|
||||||
@@ -224,12 +214,154 @@ abstract class _Create implements PaymentFormEvent {
|
|||||||
|
|
||||||
/// Create a copy of PaymentFormEvent
|
/// Create a copy of PaymentFormEvent
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@override
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
_$$CreateImplCopyWith<_$CreateImpl> get copyWith =>
|
_$$CreateImplCopyWith<_$CreateImpl> get copyWith =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
abstract class _$$CreateSplitBillImplCopyWith<$Res> {
|
||||||
|
factory _$$CreateSplitBillImplCopyWith(_$CreateSplitBillImpl value,
|
||||||
|
$Res Function(_$CreateSplitBillImpl) then) =
|
||||||
|
__$$CreateSplitBillImplCopyWithImpl<$Res>;
|
||||||
|
@useResult
|
||||||
|
$Res call({PaymentSplitBillRequest payment});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
class __$$CreateSplitBillImplCopyWithImpl<$Res>
|
||||||
|
extends _$PaymentFormEventCopyWithImpl<$Res, _$CreateSplitBillImpl>
|
||||||
|
implements _$$CreateSplitBillImplCopyWith<$Res> {
|
||||||
|
__$$CreateSplitBillImplCopyWithImpl(
|
||||||
|
_$CreateSplitBillImpl _value, $Res Function(_$CreateSplitBillImpl) _then)
|
||||||
|
: super(_value, _then);
|
||||||
|
|
||||||
|
/// Create a copy of PaymentFormEvent
|
||||||
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
@override
|
||||||
|
$Res call({
|
||||||
|
Object? payment = null,
|
||||||
|
}) {
|
||||||
|
return _then(_$CreateSplitBillImpl(
|
||||||
|
null == payment
|
||||||
|
? _value.payment
|
||||||
|
: payment // ignore: cast_nullable_to_non_nullable
|
||||||
|
as PaymentSplitBillRequest,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
|
||||||
|
class _$CreateSplitBillImpl implements _CreateSplitBill {
|
||||||
|
const _$CreateSplitBillImpl(this.payment);
|
||||||
|
|
||||||
|
@override
|
||||||
|
final PaymentSplitBillRequest payment;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'PaymentFormEvent.createSplitBill(payment: $payment)';
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) {
|
||||||
|
return identical(this, other) ||
|
||||||
|
(other.runtimeType == runtimeType &&
|
||||||
|
other is _$CreateSplitBillImpl &&
|
||||||
|
(identical(other.payment, payment) || other.payment == payment));
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode => Object.hash(runtimeType, payment);
|
||||||
|
|
||||||
|
/// Create a copy of PaymentFormEvent
|
||||||
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
|
@override
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
_$$CreateSplitBillImplCopyWith<_$CreateSplitBillImpl> get copyWith =>
|
||||||
|
__$$CreateSplitBillImplCopyWithImpl<_$CreateSplitBillImpl>(
|
||||||
|
this, _$identity);
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult when<TResult extends Object?>({
|
||||||
|
required TResult Function(PaymentRequestModel payment) create,
|
||||||
|
required TResult Function(PaymentSplitBillRequest payment) createSplitBill,
|
||||||
|
}) {
|
||||||
|
return createSplitBill(payment);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult? whenOrNull<TResult extends Object?>({
|
||||||
|
TResult? Function(PaymentRequestModel payment)? create,
|
||||||
|
TResult? Function(PaymentSplitBillRequest payment)? createSplitBill,
|
||||||
|
}) {
|
||||||
|
return createSplitBill?.call(payment);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult maybeWhen<TResult extends Object?>({
|
||||||
|
TResult Function(PaymentRequestModel payment)? create,
|
||||||
|
TResult Function(PaymentSplitBillRequest payment)? createSplitBill,
|
||||||
|
required TResult orElse(),
|
||||||
|
}) {
|
||||||
|
if (createSplitBill != null) {
|
||||||
|
return createSplitBill(payment);
|
||||||
|
}
|
||||||
|
return orElse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult map<TResult extends Object?>({
|
||||||
|
required TResult Function(_Create value) create,
|
||||||
|
required TResult Function(_CreateSplitBill value) createSplitBill,
|
||||||
|
}) {
|
||||||
|
return createSplitBill(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult? mapOrNull<TResult extends Object?>({
|
||||||
|
TResult? Function(_Create value)? create,
|
||||||
|
TResult? Function(_CreateSplitBill value)? createSplitBill,
|
||||||
|
}) {
|
||||||
|
return createSplitBill?.call(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult maybeMap<TResult extends Object?>({
|
||||||
|
TResult Function(_Create value)? create,
|
||||||
|
TResult Function(_CreateSplitBill value)? createSplitBill,
|
||||||
|
required TResult orElse(),
|
||||||
|
}) {
|
||||||
|
if (createSplitBill != null) {
|
||||||
|
return createSplitBill(this);
|
||||||
|
}
|
||||||
|
return orElse();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class _CreateSplitBill implements PaymentFormEvent {
|
||||||
|
const factory _CreateSplitBill(final PaymentSplitBillRequest payment) =
|
||||||
|
_$CreateSplitBillImpl;
|
||||||
|
|
||||||
|
@override
|
||||||
|
PaymentSplitBillRequest get payment;
|
||||||
|
|
||||||
|
/// Create a copy of PaymentFormEvent
|
||||||
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
|
_$$CreateSplitBillImplCopyWith<_$CreateSplitBillImpl> get copyWith =>
|
||||||
|
throw _privateConstructorUsedError;
|
||||||
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
mixin _$PaymentFormState {
|
mixin _$PaymentFormState {
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
|
|||||||
@@ -2,5 +2,10 @@ part of 'payment_form_bloc.dart';
|
|||||||
|
|
||||||
@freezed
|
@freezed
|
||||||
class PaymentFormEvent with _$PaymentFormEvent {
|
class PaymentFormEvent with _$PaymentFormEvent {
|
||||||
const factory PaymentFormEvent.create(PaymentRequestModel payment) = _Create;
|
const factory PaymentFormEvent.create(
|
||||||
|
PaymentRequestModel payment,
|
||||||
|
) = _Create;
|
||||||
|
const factory PaymentFormEvent.createSplitBill(
|
||||||
|
PaymentSplitBillRequest payment,
|
||||||
|
) = _CreateSplitBill;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -343,6 +343,8 @@ class _PaymentDialogState extends State<PaymentDialog> {
|
|||||||
.toList() ??
|
.toList() ??
|
||||||
[],
|
[],
|
||||||
payment: data,
|
payment: data,
|
||||||
|
paymentMethod: selectedPaymentMethod?.name ?? "",
|
||||||
|
nominalBayar: totalPriceController.text.toIntegerFromText,
|
||||||
));
|
));
|
||||||
},
|
},
|
||||||
error: (message) {
|
error: (message) {
|
||||||
|
|||||||
@@ -6,9 +6,9 @@ import 'package:enaklo_pos/presentation/home/bloc/order_form/order_form_bloc.dar
|
|||||||
import 'package:enaklo_pos/presentation/payment/pages/payment_page.dart';
|
import 'package:enaklo_pos/presentation/payment/pages/payment_page.dart';
|
||||||
import 'package:enaklo_pos/presentation/refund/pages/refund_page.dart';
|
import 'package:enaklo_pos/presentation/refund/pages/refund_page.dart';
|
||||||
import 'package:enaklo_pos/presentation/sales/blocs/order_loader/order_loader_bloc.dart';
|
import 'package:enaklo_pos/presentation/sales/blocs/order_loader/order_loader_bloc.dart';
|
||||||
|
import 'package:enaklo_pos/presentation/sales/widgets/sales_payment_summary.dart';
|
||||||
import 'package:enaklo_pos/presentation/split_bill/pages/split_bill_page.dart';
|
import 'package:enaklo_pos/presentation/split_bill/pages/split_bill_page.dart';
|
||||||
import 'package:enaklo_pos/presentation/void/pages/void_page.dart';
|
import 'package:enaklo_pos/presentation/void/pages/void_page.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_list_order.dart';
|
||||||
import 'package:enaklo_pos/presentation/sales/widgets/sales_order_information.dart';
|
import 'package:enaklo_pos/presentation/sales/widgets/sales_order_information.dart';
|
||||||
import 'package:enaklo_pos/presentation/sales/widgets/sales_payment.dart';
|
import 'package:enaklo_pos/presentation/sales/widgets/sales_payment.dart';
|
||||||
@@ -45,18 +45,6 @@ class _SalesPageState extends State<SalesPage> {
|
|||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Order> _filterOrders(List<Order> orders) {
|
|
||||||
if (searchQuery.isEmpty) {
|
|
||||||
return orders;
|
|
||||||
}
|
|
||||||
|
|
||||||
return orders.where((order) {
|
|
||||||
final customerName = order.orderNumber?.toLowerCase() ?? "";
|
|
||||||
final queryLower = searchQuery.toLowerCase();
|
|
||||||
return customerName.contains(queryLower);
|
|
||||||
}).toList();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return SafeArea(
|
return SafeArea(
|
||||||
@@ -71,8 +59,13 @@ class _SalesPageState extends State<SalesPage> {
|
|||||||
if (notification is ScrollEndNotification &&
|
if (notification is ScrollEndNotification &&
|
||||||
scrollController.position.extentAfter == 0) {
|
scrollController.position.extentAfter == 0) {
|
||||||
context.read<OrderLoaderBloc>().add(
|
context.read<OrderLoaderBloc>().add(
|
||||||
OrderLoaderEvent.loadMore(widget.status,
|
OrderLoaderEvent.loadMore(
|
||||||
dateFrom: startDate, dateTo: endDate));
|
widget.status,
|
||||||
|
dateFrom: startDate,
|
||||||
|
dateTo: endDate,
|
||||||
|
search: searchQuery,
|
||||||
|
),
|
||||||
|
);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,6 +85,16 @@ class _SalesPageState extends State<SalesPage> {
|
|||||||
setState(() {
|
setState(() {
|
||||||
searchQuery = value;
|
searchQuery = value;
|
||||||
});
|
});
|
||||||
|
Future.delayed(const Duration(milliseconds: 800), () {
|
||||||
|
context.read<OrderLoaderBloc>().add(
|
||||||
|
OrderLoaderEvent.getByStatus(
|
||||||
|
widget.status,
|
||||||
|
dateFrom: startDate,
|
||||||
|
dateTo: endDate,
|
||||||
|
search: searchQuery,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
onDateRangeChanged: (start, end) {
|
onDateRangeChanged: (start, end) {
|
||||||
setState(() {
|
setState(() {
|
||||||
@@ -125,8 +128,7 @@ class _SalesPageState extends State<SalesPage> {
|
|||||||
),
|
),
|
||||||
loaded: (orders, totalOrder, hasReachedMax,
|
loaded: (orders, totalOrder, hasReachedMax,
|
||||||
currentPage, isLoadingMore) {
|
currentPage, isLoadingMore) {
|
||||||
final filtered = _filterOrders(orders);
|
if (orders.isEmpty) {
|
||||||
if (filtered.isEmpty) {
|
|
||||||
return Center(
|
return Center(
|
||||||
child: Text(
|
child: Text(
|
||||||
"Belum ada transaksi saat ini. ",
|
"Belum ada transaksi saat ini. ",
|
||||||
@@ -138,17 +140,17 @@ class _SalesPageState extends State<SalesPage> {
|
|||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return ListView.builder(
|
return ListView.builder(
|
||||||
itemCount: filtered.length,
|
itemCount: orders.length,
|
||||||
controller: scrollController,
|
controller: scrollController,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
setState(() {
|
setState(() {
|
||||||
orderDetail = filtered[index];
|
orderDetail = orders[index];
|
||||||
});
|
});
|
||||||
context.read<OrderFormBloc>().add(
|
context.read<OrderFormBloc>().add(
|
||||||
OrderFormEvent.started(
|
OrderFormEvent.started(
|
||||||
filtered[index]));
|
orders[index]));
|
||||||
},
|
},
|
||||||
child: SalesCard(
|
child: SalesCard(
|
||||||
order: orders[index],
|
order: orders[index],
|
||||||
@@ -257,35 +259,35 @@ class _SalesPageState extends State<SalesPage> {
|
|||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(16.0),
|
padding: const EdgeInsets.all(16.0),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
|
||||||
Row(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
// Order Header
|
||||||
child: SalesOrderInformation(
|
SalesOrderInformation(
|
||||||
order: orderDetail,
|
order: orderDetail,
|
||||||
),
|
),
|
||||||
),
|
// Order Items
|
||||||
SpaceWidth(16),
|
SalesListOrder(order: orderDetail),
|
||||||
Expanded(
|
const SpaceHeight(16),
|
||||||
child: SalesDetail(
|
|
||||||
order: orderDetail,
|
// Payment Summary
|
||||||
),
|
SalesPaymentSummary(order: orderDetail),
|
||||||
),
|
const SpaceHeight(16),
|
||||||
|
|
||||||
|
// Payment Information
|
||||||
|
if (orderDetail?.payments != null &&
|
||||||
|
orderDetail?.payments!.isNotEmpty ==
|
||||||
|
true) ...[
|
||||||
|
SalesPayment(order: orderDetail),
|
||||||
|
const SpaceHeight(20),
|
||||||
],
|
],
|
||||||
),
|
|
||||||
SalesListOrder(
|
|
||||||
order: orderDetail,
|
|
||||||
),
|
|
||||||
SalesPayment(
|
|
||||||
order: orderDetail,
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -29,8 +29,9 @@ class SalesCard extends StatelessWidget {
|
|||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Align(
|
Row(
|
||||||
alignment: Alignment.centerRight,
|
children: [
|
||||||
|
Expanded(
|
||||||
child: Text(
|
child: Text(
|
||||||
'${order.orderNumber}',
|
'${order.orderNumber}',
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
@@ -39,10 +40,46 @@ class SalesCard extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
if (order.isRefund == true)
|
||||||
|
Container(
|
||||||
|
padding:
|
||||||
|
const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.red.withOpacity(0.15),
|
||||||
|
borderRadius: BorderRadius.circular(16),
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
'Refund',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.red,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
fontSize: 10,
|
||||||
|
letterSpacing: 0.5,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (order.isVoid == true)
|
||||||
|
Container(
|
||||||
|
padding:
|
||||||
|
const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.red.withOpacity(0.15),
|
||||||
|
borderRadius: BorderRadius.circular(16),
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
'Void',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.red,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
fontSize: 10,
|
||||||
|
letterSpacing: 0.5,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
const SizedBox(height: 12),
|
const SizedBox(height: 12),
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
children: [
|
||||||
CircleAvatar(
|
CircleAvatar(
|
||||||
radius: 22,
|
radius: 22,
|
||||||
@@ -63,6 +100,7 @@ class SalesCard extends StatelessWidget {
|
|||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w600,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
if (order.orderType == "dineIn") ...[
|
||||||
const SizedBox(height: 4),
|
const SizedBox(height: 4),
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
@@ -74,26 +112,11 @@ class SalesCard extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
]
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Container(
|
_buildStatus(),
|
||||||
padding:
|
|
||||||
const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Colors.green.withOpacity(0.15),
|
|
||||||
borderRadius: BorderRadius.circular(16),
|
|
||||||
),
|
|
||||||
child: Text(
|
|
||||||
(order.status ?? "").toUpperCase(),
|
|
||||||
style: TextStyle(
|
|
||||||
color: Colors.green,
|
|
||||||
fontWeight: FontWeight.w600,
|
|
||||||
fontSize: 12,
|
|
||||||
letterSpacing: 0.5,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
@@ -101,7 +124,10 @@ class SalesCard extends StatelessWidget {
|
|||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
(order.totalAmount ?? 0).currencyFormatRpV2,
|
order.status == 'pending'
|
||||||
|
? ((order.totalAmount ?? 0) - (order.totalPaid ?? 0))
|
||||||
|
.currencyFormatRpV2
|
||||||
|
: (order.totalAmount ?? 0).currencyFormatRpV2,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 18,
|
fontSize: 18,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
@@ -121,4 +147,60 @@ class SalesCard extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget _buildStatus() {
|
||||||
|
switch (order.status) {
|
||||||
|
case 'pending':
|
||||||
|
return Container(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.amber.withOpacity(0.15),
|
||||||
|
borderRadius: BorderRadius.circular(16),
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
(order.status ?? "").toUpperCase(),
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.amber,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
fontSize: 12,
|
||||||
|
letterSpacing: 0.5,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
case 'completed':
|
||||||
|
return Container(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.green.withOpacity(0.15),
|
||||||
|
borderRadius: BorderRadius.circular(16),
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
(order.status ?? "").toUpperCase(),
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.green,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
fontSize: 12,
|
||||||
|
letterSpacing: 0.5,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
default:
|
||||||
|
return Container(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.grey.withOpacity(0.15),
|
||||||
|
borderRadius: BorderRadius.circular(16),
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
(order.status ?? "").toUpperCase(),
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.grey,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
fontSize: 12,
|
||||||
|
letterSpacing: 0.5,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,71 +0,0 @@
|
|||||||
import 'package:enaklo_pos/core/constants/colors.dart';
|
|
||||||
import 'package:enaklo_pos/core/extensions/date_time_ext.dart';
|
|
||||||
import 'package:enaklo_pos/data/models/response/order_response_model.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
class SalesDetail extends StatelessWidget {
|
|
||||||
final Order? order;
|
|
||||||
const SalesDetail({super.key, this.order});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Container(
|
|
||||||
padding: const EdgeInsets.all(16),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: AppColors.white,
|
|
||||||
borderRadius: BorderRadius.circular(8),
|
|
||||||
),
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
'Detail',
|
|
||||||
style: TextStyle(
|
|
||||||
color: AppColors.black,
|
|
||||||
fontSize: 16,
|
|
||||||
fontWeight: FontWeight.w600,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
_item(
|
|
||||||
title: 'Pelanggan',
|
|
||||||
value: order?.metadata?['customer_name'] ?? "-",
|
|
||||||
),
|
|
||||||
_item(
|
|
||||||
title: 'Waktu',
|
|
||||||
value: (order?.createdAt ?? DateTime.now()).toFormattedDate3(),
|
|
||||||
),
|
|
||||||
_item(
|
|
||||||
title: 'Status',
|
|
||||||
value: order?.status ?? "-",
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Padding _item({
|
|
||||||
required String title,
|
|
||||||
required String value,
|
|
||||||
}) {
|
|
||||||
return Padding(
|
|
||||||
padding: const EdgeInsets.only(top: 12),
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
title,
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 14,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
value,
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 14,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -63,27 +63,6 @@ class SalesListOrder extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
Container(
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: AppColors.white,
|
|
||||||
borderRadius: BorderRadius.circular(8),
|
|
||||||
border: Border.all(
|
|
||||||
color: isAllSelected ? AppColors.primary : Colors.grey.shade300,
|
|
||||||
width: 2,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
child: Checkbox(
|
|
||||||
value: isAllSelected,
|
|
||||||
activeColor: AppColors.primary,
|
|
||||||
checkColor: AppColors.white,
|
|
||||||
onChanged: (val) {
|
|
||||||
context
|
|
||||||
.read<OrderFormBloc>()
|
|
||||||
.add(OrderFormEvent.toggleSelectAll(val ?? false));
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(width: 12),
|
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
@@ -179,28 +158,6 @@ class SalesListOrder extends StatelessWidget {
|
|||||||
Row(
|
Row(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Container(
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: AppColors.white,
|
|
||||||
borderRadius: BorderRadius.circular(6),
|
|
||||||
border: Border.all(
|
|
||||||
color:
|
|
||||||
isSelected ? AppColors.primary : Colors.grey.shade300,
|
|
||||||
width: 1.5,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
child: Checkbox(
|
|
||||||
value: isSelected,
|
|
||||||
activeColor: AppColors.primary,
|
|
||||||
checkColor: AppColors.white,
|
|
||||||
onChanged: (_) {
|
|
||||||
context
|
|
||||||
.read<OrderFormBloc>()
|
|
||||||
.add(OrderFormEvent.toggleItem(product));
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(width: 12),
|
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
@@ -314,6 +271,57 @@ class SalesListOrder extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
if (order?.splitType == 'ITEM' && order?.status == 'pending') ...[
|
||||||
|
SpaceHeight(6),
|
||||||
|
Align(
|
||||||
|
alignment: Alignment.centerRight,
|
||||||
|
child: Container(
|
||||||
|
padding:
|
||||||
|
const EdgeInsets.symmetric(horizontal: 10, vertical: 4),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: AppColors.primary.withOpacity(0.2),
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
border: Border.all(color: AppColors.primary),
|
||||||
|
),
|
||||||
|
child: RichText(
|
||||||
|
text: TextSpan(
|
||||||
|
children: [
|
||||||
|
TextSpan(
|
||||||
|
text: '${product.paidQuantity} ',
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 12,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: AppColors.primary,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
TextSpan(
|
||||||
|
text: 'dari ',
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 12,
|
||||||
|
color: AppColors.primary,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
TextSpan(
|
||||||
|
text: '${product.quantity} ',
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 12,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: AppColors.primary,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
TextSpan(
|
||||||
|
text: 'kuantiti telah dibayar.',
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 12,
|
||||||
|
color: AppColors.primary,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -328,8 +336,8 @@ class SalesListOrder extends StatelessWidget {
|
|||||||
|
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case "pending":
|
case "pending":
|
||||||
backgroundColor = Colors.orange.withOpacity(0.1);
|
backgroundColor = Colors.white;
|
||||||
textColor = Colors.orange.shade700;
|
textColor = Colors.white;
|
||||||
displayText = "Pending";
|
displayText = "Pending";
|
||||||
icon = Icons.access_time;
|
icon = Icons.access_time;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import 'package:enaklo_pos/core/components/spaces.dart';
|
||||||
import 'package:enaklo_pos/core/constants/colors.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/date_time_ext.dart';
|
||||||
import 'package:enaklo_pos/data/models/response/order_response_model.dart';
|
import 'package:enaklo_pos/data/models/response/order_response_model.dart';
|
||||||
@@ -10,66 +11,121 @@ class SalesOrderInformation extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Container(
|
return Container(
|
||||||
|
width: double.infinity,
|
||||||
padding: const EdgeInsets.all(16),
|
padding: const EdgeInsets.all(16),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: AppColors.white,
|
color: AppColors.primary,
|
||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: BorderRadius.circular(8),
|
||||||
),
|
),
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
'Informasi Pesanan',
|
order?.orderNumber ?? "",
|
||||||
style: TextStyle(
|
style: const TextStyle(
|
||||||
color: AppColors.black,
|
color: Colors.white,
|
||||||
fontSize: 16,
|
fontSize: 18,
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.bold,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
_item(
|
_buildStatus(),
|
||||||
title: 'No. Order',
|
],
|
||||||
value: "${order?.orderNumber}",
|
|
||||||
),
|
),
|
||||||
_item(
|
const SizedBox(height: 8),
|
||||||
title: 'Tanggal',
|
Row(
|
||||||
value: (order?.createdAt ?? DateTime.now()).toFormattedDate2(),
|
children: [
|
||||||
|
if (order?.orderType == 'dineIn') ...[
|
||||||
|
_buildRowItem(Icons.table_restaurant_outlined,
|
||||||
|
'Meja ${order?.tableNumber}'),
|
||||||
|
const SizedBox(width: 16),
|
||||||
|
],
|
||||||
|
_buildRowItem(Icons.restaurant_outlined, '${order?.orderType}'),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
_item(
|
const SizedBox(height: 8),
|
||||||
title: 'No. Meja',
|
Text(
|
||||||
value: order?.tableNumber ?? "-",
|
'Pelanggan: ${order?.metadata?['customer_name'] ?? ""}',
|
||||||
|
style: const TextStyle(color: Colors.white, fontSize: 14),
|
||||||
),
|
),
|
||||||
_item(
|
Text(
|
||||||
title: 'Jenis Order',
|
'Dibuat: ${order?.createdAt?.toFormattedDate3() ?? ""}',
|
||||||
value: order?.orderType ?? "-",
|
style: const TextStyle(color: Colors.white70, fontSize: 12),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Padding _item({
|
Row _buildRowItem(IconData icon, String title) {
|
||||||
required String title,
|
return Row(
|
||||||
required String value,
|
|
||||||
}) {
|
|
||||||
return Padding(
|
|
||||||
padding: const EdgeInsets.only(top: 12),
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
children: [
|
||||||
|
Icon(
|
||||||
|
icon,
|
||||||
|
color: Colors.white70,
|
||||||
|
size: 16,
|
||||||
|
),
|
||||||
|
const SpaceWidth(4),
|
||||||
Text(
|
Text(
|
||||||
title,
|
title,
|
||||||
style: const TextStyle(
|
style: const TextStyle(color: Colors.white70, fontSize: 14),
|
||||||
fontSize: 14,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
value,
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 14,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Container _buildStatus() {
|
||||||
|
switch (order?.status) {
|
||||||
|
case 'pending':
|
||||||
|
return Container(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 4),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.orange,
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
(order?.status ?? "").toUpperCase(),
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
fontSize: 12,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
case 'completed':
|
||||||
|
return Container(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 4),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.greenAccent,
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
(order?.status ?? "").toUpperCase(),
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
fontSize: 12,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
default:
|
||||||
|
return Container(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 4),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.grey,
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
(order?.status ?? "").toUpperCase(),
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
fontSize: 12,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import 'package:enaklo_pos/core/components/dashed_divider.dart';
|
|
||||||
import 'package:enaklo_pos/core/components/spaces.dart';
|
import 'package:enaklo_pos/core/components/spaces.dart';
|
||||||
import 'package:enaklo_pos/core/constants/colors.dart';
|
import 'package:enaklo_pos/core/constants/colors.dart';
|
||||||
import 'package:enaklo_pos/core/extensions/int_ext.dart';
|
import 'package:enaklo_pos/core/extensions/int_ext.dart';
|
||||||
|
import 'package:enaklo_pos/core/extensions/string_ext.dart';
|
||||||
import 'package:enaklo_pos/data/models/response/order_response_model.dart';
|
import 'package:enaklo_pos/data/models/response/order_response_model.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
@@ -12,88 +12,165 @@ class SalesPayment extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Container(
|
return Container(
|
||||||
|
width: double.infinity,
|
||||||
padding: const EdgeInsets.all(16),
|
padding: const EdgeInsets.all(16),
|
||||||
margin: const EdgeInsets.only(top: 16),
|
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: AppColors.white,
|
color: Colors.white,
|
||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: BorderRadius.circular(8),
|
||||||
),
|
),
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
'Informasi Pesanan',
|
'Informasi Pembayaran',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: AppColors.black,
|
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.bold,
|
||||||
),
|
|
||||||
),
|
|
||||||
SpaceHeight(12),
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
'Subtotal ${order?.orderItems?.length} Produk',
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 16,
|
|
||||||
fontWeight: FontWeight.w600,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
(order?.subtotal)?.currencyFormatRp ?? "0",
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 16,
|
|
||||||
fontWeight: FontWeight.w600,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
SpaceHeight(12),
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
'Pajak',
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 16,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
(order?.taxAmount)?.currencyFormatRp ?? "0",
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 16,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
SpaceHeight(12),
|
|
||||||
DashedDivider(
|
|
||||||
color: AppColors.stroke,
|
|
||||||
),
|
|
||||||
SpaceHeight(12),
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
'Total',
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 18,
|
|
||||||
fontWeight: FontWeight.w700,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
(order?.totalAmount)?.currencyFormatRp ?? "0",
|
|
||||||
style: const TextStyle(
|
|
||||||
color: AppColors.primary,
|
color: AppColors.primary,
|
||||||
fontSize: 18,
|
),
|
||||||
fontWeight: FontWeight.w700,
|
),
|
||||||
|
_buildPaymentStatus(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SpaceHeight(12),
|
||||||
|
...List.generate(
|
||||||
|
order?.payments?.length ?? 0,
|
||||||
|
(index) => Padding(
|
||||||
|
padding: const EdgeInsets.only(bottom: 8.0),
|
||||||
|
child: _buildPaymentItem(order?.payments?[index] ?? Payment()),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SpaceHeight(4),
|
||||||
|
const Divider(),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'Jumlah yang Dibayar',
|
||||||
|
style: TextStyle(color: Colors.grey.shade700),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
(order?.totalPaid ?? 0).currencyFormatRpV2,
|
||||||
|
style: TextStyle(fontWeight: FontWeight.w500),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
if (((order?.totalAmount ?? 0) - (order?.totalPaid ?? 0)) != 0) ...[
|
||||||
|
const SpaceHeight(4),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'Sisa Tagihan',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.red.shade700,
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
((order?.totalAmount ?? 0) - (order?.totalPaid ?? 0))
|
||||||
|
.currencyFormatRpV2,
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.red.shade700,
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Container _buildPaymentStatus() {
|
||||||
|
switch (order?.paymentStatus) {
|
||||||
|
case 'completed':
|
||||||
|
return Container(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: AppColors.green.withOpacity(0.2),
|
||||||
|
borderRadius: BorderRadius.circular(4),
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
(order?.paymentStatus ?? "").toTitleCase(),
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 10,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: AppColors.green,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
default:
|
||||||
|
return Container(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.amber.shade100,
|
||||||
|
borderRadius: BorderRadius.circular(4),
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
(order?.paymentStatus ?? "").toTitleCase(),
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 10,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: Colors.amber.shade800,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Row _buildPaymentItem(Payment payment) {
|
||||||
|
return Row(
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
width: 32,
|
||||||
|
height: 32,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.green.shade100,
|
||||||
|
borderRadius: BorderRadius.circular(4),
|
||||||
|
),
|
||||||
|
child: Icon(
|
||||||
|
Icons.payments,
|
||||||
|
color: Colors.green.shade700,
|
||||||
|
size: 16,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 12),
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
payment.paymentMethodName ?? "",
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 14,
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if ((payment.splitTotal ?? 0) > 1)
|
||||||
|
Text(
|
||||||
|
'Split ${payment.splitNumber ?? 0} of ${payment.splitTotal ?? 0}',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 12,
|
||||||
|
color: Colors.grey.shade600,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
(payment.amount ?? 0).currencyFormatRpV2,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 14,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: AppColors.green,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,94 @@
|
|||||||
|
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/data/models/response/order_response_model.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class SalesPaymentSummary extends StatelessWidget {
|
||||||
|
final Order? order;
|
||||||
|
const SalesPaymentSummary({super.key, this.order});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Container(
|
||||||
|
width: double.infinity,
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white,
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
const Text(
|
||||||
|
'Ringkasan Pembayaran',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 16,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: AppColors.primary,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SpaceHeight(12),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'Subtotal',
|
||||||
|
style: TextStyle(color: Colors.grey.shade700),
|
||||||
|
),
|
||||||
|
Text((order?.subtotal ?? 0).currencyFormatRpV2),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SpaceHeight(4),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'Tax',
|
||||||
|
style: TextStyle(color: Colors.grey.shade700),
|
||||||
|
),
|
||||||
|
Text((order?.taxAmount ?? 0).currencyFormatRpV2),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SpaceHeight(4),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'Discount',
|
||||||
|
style: TextStyle(color: Colors.grey.shade700),
|
||||||
|
),
|
||||||
|
Text((order?.discountAmount ?? 0).currencyFormatRpV2),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SpaceHeight(8),
|
||||||
|
const DashedDivider(
|
||||||
|
color: AppColors.grey,
|
||||||
|
),
|
||||||
|
const SpaceHeight(8),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
const Text(
|
||||||
|
'Total',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 16,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
(order?.totalAmount ?? 0).currencyFormatRpV2,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 16,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: AppColors.primary,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
import 'package:bloc/bloc.dart';
|
||||||
|
import 'package:enaklo_pos/data/datasources/product_local_datasource.dart';
|
||||||
|
import 'package:enaklo_pos/data/models/response/print_model.dart';
|
||||||
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||||
|
|
||||||
|
part 'get_printer_ticket_event.dart';
|
||||||
|
part 'get_printer_ticket_state.dart';
|
||||||
|
part 'get_printer_ticket_bloc.freezed.dart';
|
||||||
|
|
||||||
|
class GetPrinterTicketBloc
|
||||||
|
extends Bloc<GetPrinterTicketEvent, GetPrinterTicketState> {
|
||||||
|
GetPrinterTicketBloc() : super(_Initial()) {
|
||||||
|
on<_Get>((event, emit) async {
|
||||||
|
emit(_Loading());
|
||||||
|
final result =
|
||||||
|
await ProductLocalDatasource.instance.getPrinterByCode('ticket');
|
||||||
|
emit(_Success(result));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,608 @@
|
|||||||
|
// 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 'get_printer_ticket_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 _$GetPrinterTicketEvent {
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult when<TResult extends Object?>({
|
||||||
|
required TResult Function() get,
|
||||||
|
}) =>
|
||||||
|
throw _privateConstructorUsedError;
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult? whenOrNull<TResult extends Object?>({
|
||||||
|
TResult? Function()? get,
|
||||||
|
}) =>
|
||||||
|
throw _privateConstructorUsedError;
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult maybeWhen<TResult extends Object?>({
|
||||||
|
TResult Function()? get,
|
||||||
|
required TResult orElse(),
|
||||||
|
}) =>
|
||||||
|
throw _privateConstructorUsedError;
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult map<TResult extends Object?>({
|
||||||
|
required TResult Function(_Get value) get,
|
||||||
|
}) =>
|
||||||
|
throw _privateConstructorUsedError;
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult? mapOrNull<TResult extends Object?>({
|
||||||
|
TResult? Function(_Get value)? get,
|
||||||
|
}) =>
|
||||||
|
throw _privateConstructorUsedError;
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult maybeMap<TResult extends Object?>({
|
||||||
|
TResult Function(_Get value)? get,
|
||||||
|
required TResult orElse(),
|
||||||
|
}) =>
|
||||||
|
throw _privateConstructorUsedError;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
abstract class $GetPrinterTicketEventCopyWith<$Res> {
|
||||||
|
factory $GetPrinterTicketEventCopyWith(GetPrinterTicketEvent value,
|
||||||
|
$Res Function(GetPrinterTicketEvent) then) =
|
||||||
|
_$GetPrinterTicketEventCopyWithImpl<$Res, GetPrinterTicketEvent>;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
class _$GetPrinterTicketEventCopyWithImpl<$Res,
|
||||||
|
$Val extends GetPrinterTicketEvent>
|
||||||
|
implements $GetPrinterTicketEventCopyWith<$Res> {
|
||||||
|
_$GetPrinterTicketEventCopyWithImpl(this._value, this._then);
|
||||||
|
|
||||||
|
// ignore: unused_field
|
||||||
|
final $Val _value;
|
||||||
|
// ignore: unused_field
|
||||||
|
final $Res Function($Val) _then;
|
||||||
|
|
||||||
|
/// Create a copy of GetPrinterTicketEvent
|
||||||
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
abstract class _$$GetImplCopyWith<$Res> {
|
||||||
|
factory _$$GetImplCopyWith(_$GetImpl value, $Res Function(_$GetImpl) then) =
|
||||||
|
__$$GetImplCopyWithImpl<$Res>;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
class __$$GetImplCopyWithImpl<$Res>
|
||||||
|
extends _$GetPrinterTicketEventCopyWithImpl<$Res, _$GetImpl>
|
||||||
|
implements _$$GetImplCopyWith<$Res> {
|
||||||
|
__$$GetImplCopyWithImpl(_$GetImpl _value, $Res Function(_$GetImpl) _then)
|
||||||
|
: super(_value, _then);
|
||||||
|
|
||||||
|
/// Create a copy of GetPrinterTicketEvent
|
||||||
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
|
||||||
|
class _$GetImpl implements _Get {
|
||||||
|
const _$GetImpl();
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'GetPrinterTicketEvent.get()';
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) {
|
||||||
|
return identical(this, other) ||
|
||||||
|
(other.runtimeType == runtimeType && other is _$GetImpl);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode => runtimeType.hashCode;
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult when<TResult extends Object?>({
|
||||||
|
required TResult Function() get,
|
||||||
|
}) {
|
||||||
|
return get();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult? whenOrNull<TResult extends Object?>({
|
||||||
|
TResult? Function()? get,
|
||||||
|
}) {
|
||||||
|
return get?.call();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult maybeWhen<TResult extends Object?>({
|
||||||
|
TResult Function()? get,
|
||||||
|
required TResult orElse(),
|
||||||
|
}) {
|
||||||
|
if (get != null) {
|
||||||
|
return get();
|
||||||
|
}
|
||||||
|
return orElse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult map<TResult extends Object?>({
|
||||||
|
required TResult Function(_Get value) get,
|
||||||
|
}) {
|
||||||
|
return get(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult? mapOrNull<TResult extends Object?>({
|
||||||
|
TResult? Function(_Get value)? get,
|
||||||
|
}) {
|
||||||
|
return get?.call(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult maybeMap<TResult extends Object?>({
|
||||||
|
TResult Function(_Get value)? get,
|
||||||
|
required TResult orElse(),
|
||||||
|
}) {
|
||||||
|
if (get != null) {
|
||||||
|
return get(this);
|
||||||
|
}
|
||||||
|
return orElse();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class _Get implements GetPrinterTicketEvent {
|
||||||
|
const factory _Get() = _$GetImpl;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
mixin _$GetPrinterTicketState {
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult when<TResult extends Object?>({
|
||||||
|
required TResult Function() initial,
|
||||||
|
required TResult Function() loading,
|
||||||
|
required TResult Function(PrintModel? printer) success,
|
||||||
|
}) =>
|
||||||
|
throw _privateConstructorUsedError;
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult? whenOrNull<TResult extends Object?>({
|
||||||
|
TResult? Function()? initial,
|
||||||
|
TResult? Function()? loading,
|
||||||
|
TResult? Function(PrintModel? printer)? success,
|
||||||
|
}) =>
|
||||||
|
throw _privateConstructorUsedError;
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult maybeWhen<TResult extends Object?>({
|
||||||
|
TResult Function()? initial,
|
||||||
|
TResult Function()? loading,
|
||||||
|
TResult Function(PrintModel? printer)? success,
|
||||||
|
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(_Success value) success,
|
||||||
|
}) =>
|
||||||
|
throw _privateConstructorUsedError;
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult? mapOrNull<TResult extends Object?>({
|
||||||
|
TResult? Function(_Initial value)? initial,
|
||||||
|
TResult? Function(_Loading value)? loading,
|
||||||
|
TResult? Function(_Success value)? success,
|
||||||
|
}) =>
|
||||||
|
throw _privateConstructorUsedError;
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult maybeMap<TResult extends Object?>({
|
||||||
|
TResult Function(_Initial value)? initial,
|
||||||
|
TResult Function(_Loading value)? loading,
|
||||||
|
TResult Function(_Success value)? success,
|
||||||
|
required TResult orElse(),
|
||||||
|
}) =>
|
||||||
|
throw _privateConstructorUsedError;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
abstract class $GetPrinterTicketStateCopyWith<$Res> {
|
||||||
|
factory $GetPrinterTicketStateCopyWith(GetPrinterTicketState value,
|
||||||
|
$Res Function(GetPrinterTicketState) then) =
|
||||||
|
_$GetPrinterTicketStateCopyWithImpl<$Res, GetPrinterTicketState>;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
class _$GetPrinterTicketStateCopyWithImpl<$Res,
|
||||||
|
$Val extends GetPrinterTicketState>
|
||||||
|
implements $GetPrinterTicketStateCopyWith<$Res> {
|
||||||
|
_$GetPrinterTicketStateCopyWithImpl(this._value, this._then);
|
||||||
|
|
||||||
|
// ignore: unused_field
|
||||||
|
final $Val _value;
|
||||||
|
// ignore: unused_field
|
||||||
|
final $Res Function($Val) _then;
|
||||||
|
|
||||||
|
/// Create a copy of GetPrinterTicketState
|
||||||
|
/// 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 _$GetPrinterTicketStateCopyWithImpl<$Res, _$InitialImpl>
|
||||||
|
implements _$$InitialImplCopyWith<$Res> {
|
||||||
|
__$$InitialImplCopyWithImpl(
|
||||||
|
_$InitialImpl _value, $Res Function(_$InitialImpl) _then)
|
||||||
|
: super(_value, _then);
|
||||||
|
|
||||||
|
/// Create a copy of GetPrinterTicketState
|
||||||
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
|
||||||
|
class _$InitialImpl implements _Initial {
|
||||||
|
const _$InitialImpl();
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'GetPrinterTicketState.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(PrintModel? printer) success,
|
||||||
|
}) {
|
||||||
|
return initial();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult? whenOrNull<TResult extends Object?>({
|
||||||
|
TResult? Function()? initial,
|
||||||
|
TResult? Function()? loading,
|
||||||
|
TResult? Function(PrintModel? printer)? success,
|
||||||
|
}) {
|
||||||
|
return initial?.call();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult maybeWhen<TResult extends Object?>({
|
||||||
|
TResult Function()? initial,
|
||||||
|
TResult Function()? loading,
|
||||||
|
TResult Function(PrintModel? printer)? success,
|
||||||
|
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(_Success value) success,
|
||||||
|
}) {
|
||||||
|
return initial(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult? mapOrNull<TResult extends Object?>({
|
||||||
|
TResult? Function(_Initial value)? initial,
|
||||||
|
TResult? Function(_Loading value)? loading,
|
||||||
|
TResult? Function(_Success value)? success,
|
||||||
|
}) {
|
||||||
|
return initial?.call(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult maybeMap<TResult extends Object?>({
|
||||||
|
TResult Function(_Initial value)? initial,
|
||||||
|
TResult Function(_Loading value)? loading,
|
||||||
|
TResult Function(_Success value)? success,
|
||||||
|
required TResult orElse(),
|
||||||
|
}) {
|
||||||
|
if (initial != null) {
|
||||||
|
return initial(this);
|
||||||
|
}
|
||||||
|
return orElse();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class _Initial implements GetPrinterTicketState {
|
||||||
|
const factory _Initial() = _$InitialImpl;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
abstract class _$$LoadingImplCopyWith<$Res> {
|
||||||
|
factory _$$LoadingImplCopyWith(
|
||||||
|
_$LoadingImpl value, $Res Function(_$LoadingImpl) then) =
|
||||||
|
__$$LoadingImplCopyWithImpl<$Res>;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
class __$$LoadingImplCopyWithImpl<$Res>
|
||||||
|
extends _$GetPrinterTicketStateCopyWithImpl<$Res, _$LoadingImpl>
|
||||||
|
implements _$$LoadingImplCopyWith<$Res> {
|
||||||
|
__$$LoadingImplCopyWithImpl(
|
||||||
|
_$LoadingImpl _value, $Res Function(_$LoadingImpl) _then)
|
||||||
|
: super(_value, _then);
|
||||||
|
|
||||||
|
/// Create a copy of GetPrinterTicketState
|
||||||
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
|
||||||
|
class _$LoadingImpl implements _Loading {
|
||||||
|
const _$LoadingImpl();
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'GetPrinterTicketState.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(PrintModel? printer) success,
|
||||||
|
}) {
|
||||||
|
return loading();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult? whenOrNull<TResult extends Object?>({
|
||||||
|
TResult? Function()? initial,
|
||||||
|
TResult? Function()? loading,
|
||||||
|
TResult? Function(PrintModel? printer)? success,
|
||||||
|
}) {
|
||||||
|
return loading?.call();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult maybeWhen<TResult extends Object?>({
|
||||||
|
TResult Function()? initial,
|
||||||
|
TResult Function()? loading,
|
||||||
|
TResult Function(PrintModel? printer)? success,
|
||||||
|
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(_Success value) success,
|
||||||
|
}) {
|
||||||
|
return loading(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult? mapOrNull<TResult extends Object?>({
|
||||||
|
TResult? Function(_Initial value)? initial,
|
||||||
|
TResult? Function(_Loading value)? loading,
|
||||||
|
TResult? Function(_Success value)? success,
|
||||||
|
}) {
|
||||||
|
return loading?.call(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult maybeMap<TResult extends Object?>({
|
||||||
|
TResult Function(_Initial value)? initial,
|
||||||
|
TResult Function(_Loading value)? loading,
|
||||||
|
TResult Function(_Success value)? success,
|
||||||
|
required TResult orElse(),
|
||||||
|
}) {
|
||||||
|
if (loading != null) {
|
||||||
|
return loading(this);
|
||||||
|
}
|
||||||
|
return orElse();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class _Loading implements GetPrinterTicketState {
|
||||||
|
const factory _Loading() = _$LoadingImpl;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
abstract class _$$SuccessImplCopyWith<$Res> {
|
||||||
|
factory _$$SuccessImplCopyWith(
|
||||||
|
_$SuccessImpl value, $Res Function(_$SuccessImpl) then) =
|
||||||
|
__$$SuccessImplCopyWithImpl<$Res>;
|
||||||
|
@useResult
|
||||||
|
$Res call({PrintModel? printer});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
class __$$SuccessImplCopyWithImpl<$Res>
|
||||||
|
extends _$GetPrinterTicketStateCopyWithImpl<$Res, _$SuccessImpl>
|
||||||
|
implements _$$SuccessImplCopyWith<$Res> {
|
||||||
|
__$$SuccessImplCopyWithImpl(
|
||||||
|
_$SuccessImpl _value, $Res Function(_$SuccessImpl) _then)
|
||||||
|
: super(_value, _then);
|
||||||
|
|
||||||
|
/// Create a copy of GetPrinterTicketState
|
||||||
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
@override
|
||||||
|
$Res call({
|
||||||
|
Object? printer = freezed,
|
||||||
|
}) {
|
||||||
|
return _then(_$SuccessImpl(
|
||||||
|
freezed == printer
|
||||||
|
? _value.printer
|
||||||
|
: printer // ignore: cast_nullable_to_non_nullable
|
||||||
|
as PrintModel?,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
|
||||||
|
class _$SuccessImpl implements _Success {
|
||||||
|
const _$SuccessImpl(this.printer);
|
||||||
|
|
||||||
|
@override
|
||||||
|
final PrintModel? printer;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'GetPrinterTicketState.success(printer: $printer)';
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) {
|
||||||
|
return identical(this, other) ||
|
||||||
|
(other.runtimeType == runtimeType &&
|
||||||
|
other is _$SuccessImpl &&
|
||||||
|
(identical(other.printer, printer) || other.printer == printer));
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode => Object.hash(runtimeType, printer);
|
||||||
|
|
||||||
|
/// Create a copy of GetPrinterTicketState
|
||||||
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
|
@override
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
_$$SuccessImplCopyWith<_$SuccessImpl> get copyWith =>
|
||||||
|
__$$SuccessImplCopyWithImpl<_$SuccessImpl>(this, _$identity);
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult when<TResult extends Object?>({
|
||||||
|
required TResult Function() initial,
|
||||||
|
required TResult Function() loading,
|
||||||
|
required TResult Function(PrintModel? printer) success,
|
||||||
|
}) {
|
||||||
|
return success(printer);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult? whenOrNull<TResult extends Object?>({
|
||||||
|
TResult? Function()? initial,
|
||||||
|
TResult? Function()? loading,
|
||||||
|
TResult? Function(PrintModel? printer)? success,
|
||||||
|
}) {
|
||||||
|
return success?.call(printer);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult maybeWhen<TResult extends Object?>({
|
||||||
|
TResult Function()? initial,
|
||||||
|
TResult Function()? loading,
|
||||||
|
TResult Function(PrintModel? printer)? success,
|
||||||
|
required TResult orElse(),
|
||||||
|
}) {
|
||||||
|
if (success != null) {
|
||||||
|
return success(printer);
|
||||||
|
}
|
||||||
|
return orElse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult map<TResult extends Object?>({
|
||||||
|
required TResult Function(_Initial value) initial,
|
||||||
|
required TResult Function(_Loading value) loading,
|
||||||
|
required TResult Function(_Success value) success,
|
||||||
|
}) {
|
||||||
|
return success(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult? mapOrNull<TResult extends Object?>({
|
||||||
|
TResult? Function(_Initial value)? initial,
|
||||||
|
TResult? Function(_Loading value)? loading,
|
||||||
|
TResult? Function(_Success value)? success,
|
||||||
|
}) {
|
||||||
|
return success?.call(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult maybeMap<TResult extends Object?>({
|
||||||
|
TResult Function(_Initial value)? initial,
|
||||||
|
TResult Function(_Loading value)? loading,
|
||||||
|
TResult Function(_Success value)? success,
|
||||||
|
required TResult orElse(),
|
||||||
|
}) {
|
||||||
|
if (success != null) {
|
||||||
|
return success(this);
|
||||||
|
}
|
||||||
|
return orElse();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class _Success implements GetPrinterTicketState {
|
||||||
|
const factory _Success(final PrintModel? printer) = _$SuccessImpl;
|
||||||
|
|
||||||
|
PrintModel? get printer;
|
||||||
|
|
||||||
|
/// Create a copy of GetPrinterTicketState
|
||||||
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
|
_$$SuccessImplCopyWith<_$SuccessImpl> get copyWith =>
|
||||||
|
throw _privateConstructorUsedError;
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
part of 'get_printer_ticket_bloc.dart';
|
||||||
|
|
||||||
|
@freezed
|
||||||
|
class GetPrinterTicketEvent with _$GetPrinterTicketEvent {
|
||||||
|
const factory GetPrinterTicketEvent.get() = _Get;
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
part of 'get_printer_ticket_bloc.dart';
|
||||||
|
|
||||||
|
@freezed
|
||||||
|
class GetPrinterTicketState with _$GetPrinterTicketState {
|
||||||
|
const factory GetPrinterTicketState.initial() = _Initial;
|
||||||
|
const factory GetPrinterTicketState.loading() = _Loading;
|
||||||
|
const factory GetPrinterTicketState.success(PrintModel? printer) = _Success;
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
import 'package:enaklo_pos/presentation/home/widgets/custom_tab_bar.dart';
|
||||||
|
import 'package:enaklo_pos/presentation/setting/widgets/bar_printer_page.dart';
|
||||||
|
import 'package:enaklo_pos/presentation/setting/widgets/checker_printer_page.dart';
|
||||||
|
import 'package:enaklo_pos/presentation/setting/widgets/kitchen_printer_page.dart';
|
||||||
|
import 'package:enaklo_pos/presentation/setting/widgets/receipt_printer_page.dart';
|
||||||
|
import 'package:enaklo_pos/presentation/setting/widgets/settings_title.dart';
|
||||||
|
import 'package:enaklo_pos/presentation/setting/widgets/ticket_printer_page.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class SettingPrinterPage extends StatelessWidget {
|
||||||
|
const SettingPrinterPage({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
SettingsTitle(
|
||||||
|
'Printer',
|
||||||
|
subtitle: 'Kelola printer untuk cetak struk',
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: CustomTabBarV2(
|
||||||
|
tabTitles: [
|
||||||
|
'Receipt Printer',
|
||||||
|
'Checker Printer',
|
||||||
|
'Kitchen Printer',
|
||||||
|
'Bar Printer',
|
||||||
|
'Tiket Printer',
|
||||||
|
],
|
||||||
|
tabViews: [
|
||||||
|
ReceiptPrinterPage(),
|
||||||
|
CheckerPrinterPage(),
|
||||||
|
KitchenPrinterPage(),
|
||||||
|
BarPrinterPage(),
|
||||||
|
TicketPrinterPage()
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,112 @@
|
|||||||
|
import 'package:enaklo_pos/core/constants/colors.dart';
|
||||||
|
import 'package:enaklo_pos/core/extensions/build_context_ext.dart';
|
||||||
|
import 'package:enaklo_pos/presentation/setting/pages/printer_page.dart';
|
||||||
|
import 'package:enaklo_pos/presentation/setting/pages/setting_tile.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class SettingPage extends StatefulWidget {
|
||||||
|
const SettingPage({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<SettingPage> createState() => _SettingPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _SettingPageState extends State<SettingPage> {
|
||||||
|
int currentIndex = 0;
|
||||||
|
String? role;
|
||||||
|
|
||||||
|
void indexValue(int index) {
|
||||||
|
currentIndex = index;
|
||||||
|
setState(() {});
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
backgroundColor: AppColors.background,
|
||||||
|
body: Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
flex: 2,
|
||||||
|
child: Align(
|
||||||
|
alignment: Alignment.topCenter,
|
||||||
|
child: Material(
|
||||||
|
color: AppColors.white,
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 16.0,
|
||||||
|
vertical: 12.0,
|
||||||
|
),
|
||||||
|
width: double.infinity,
|
||||||
|
height: context.deviceHeight * 0.1,
|
||||||
|
decoration: const BoxDecoration(
|
||||||
|
color: AppColors.white,
|
||||||
|
border: Border(
|
||||||
|
bottom: BorderSide(
|
||||||
|
color: AppColors.background,
|
||||||
|
width: 1.0,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
const Text(
|
||||||
|
'Pengaturan',
|
||||||
|
style: TextStyle(
|
||||||
|
color: AppColors.black,
|
||||||
|
fontSize: 20,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
'Kelola pengaturan aplikasi',
|
||||||
|
style: TextStyle(
|
||||||
|
color: AppColors.grey,
|
||||||
|
fontSize: 14,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
SettingTile(
|
||||||
|
index: 0,
|
||||||
|
currentIndex: currentIndex,
|
||||||
|
title: 'Printer',
|
||||||
|
subtitle: 'Kelola printer',
|
||||||
|
icon: Icons.print_outlined,
|
||||||
|
onTap: () => indexValue(0),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
flex: 4,
|
||||||
|
child: Align(
|
||||||
|
alignment: AlignmentDirectional.topStart,
|
||||||
|
child: IndexedStack(
|
||||||
|
index: currentIndex,
|
||||||
|
children: [
|
||||||
|
SettingPrinterPage(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||