From f47700ad2b3dd9522b265b66f7feed8df9029566 Mon Sep 17 00:00:00 2001 From: renolation Date: Sun, 2 Nov 2025 22:08:28 +0700 Subject: [PATCH] asdasda --- .../pages/product_detail_page.dart | 29 +++++++++++++++---- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/lib/features/products/presentation/pages/product_detail_page.dart b/lib/features/products/presentation/pages/product_detail_page.dart index d9193a6..8c69d66 100644 --- a/lib/features/products/presentation/pages/product_detail_page.dart +++ b/lib/features/products/presentation/pages/product_detail_page.dart @@ -141,6 +141,13 @@ class _ProductDetailPageState extends ConsumerState { }); } + void _clearUserSelections() { + setState(() { + _selectedWarehouseUser = null; + _selectedEmployee = null; + }); + } + void _showBarcodeScanner() { final controller = MobileScannerController( formats: const [BarcodeFormat.code128], @@ -354,7 +361,7 @@ class _ProductDetailPageState extends ConsumerState { return Scaffold( appBar: AppBar( - title: Text('${operationTitle} ${productName}'), + title: Text('$operationTitle: $productName'), actions: [ IconButton( icon: const Icon(Icons.qr_code_scanner), @@ -841,7 +848,7 @@ class _ProductDetailPageState extends ConsumerState { ); } }, - (_) { + (_) async { // Success - show success message if (mounted) { ScaffoldMessenger.of(context).showSnackBar( @@ -852,14 +859,24 @@ class _ProductDetailPageState extends ConsumerState { ), ); - // Clear the text fields after successful add - _clearControllers(); - // Refresh the product detail to show updated quantities - ref.read(productDetailProvider(_providerKey).notifier).refreshProductDetail( + await ref.read(productDetailProvider(_providerKey).notifier).refreshProductDetail( widget.warehouseId, widget.productId, ); + + // Get updated stage data + final updatedStages = ref.read(productDetailProvider(_providerKey)).stages; + final updatedStage = updatedStages.firstWhere( + (s) => s.productStageId == stage.productStageId, + orElse: () => stage, + ); + + // Automatically print after successful save + await _printQuantities(updatedStage); + + // Do NOT clear quantity/weight fields - keep them for reference + // User can manually clear them if needed using the 'C' button } }, );