From c97dd40b058b15330d57aeb82ee18602376c6e56 Mon Sep 17 00:00:00 2001 From: Rafeek Alkhoudare Date: Mon, 26 May 2025 06:11:06 -0500 Subject: [PATCH] add toSelected function to convert from product to selectedProduct --- .../all_spaces/model/product_model.dart | 11 +++++++++++ .../tag_model/widgets/device_type_tile_widget.dart | 8 ++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/lib/pages/spaces_management/all_spaces/model/product_model.dart b/lib/pages/spaces_management/all_spaces/model/product_model.dart index a4ebd550..8f905032 100644 --- a/lib/pages/spaces_management/all_spaces/model/product_model.dart +++ b/lib/pages/spaces_management/all_spaces/model/product_model.dart @@ -1,5 +1,7 @@ import 'package:syncrow_web/utils/constants/assets.dart'; +import 'selected_product_model.dart'; + class ProductModel { final String uuid; final String catName; @@ -38,6 +40,15 @@ class ProductModel { }; } + SelectedProduct toSelectedProduct(int count) { + return SelectedProduct( + productId: uuid, + count: count, + productName: name!, + product: this, + ); + } + static String _mapIconToProduct(String prodType) { const iconMapping = { '1G': Assets.Gang1SwitchIcon, diff --git a/lib/pages/spaces_management/tag_model/widgets/device_type_tile_widget.dart b/lib/pages/spaces_management/tag_model/widgets/device_type_tile_widget.dart index 7d103cdb..3d645d7c 100644 --- a/lib/pages/spaces_management/tag_model/widgets/device_type_tile_widget.dart +++ b/lib/pages/spaces_management/tag_model/widgets/device_type_tile_widget.dart @@ -54,10 +54,10 @@ class DeviceTypeTileWidget extends StatelessWidget { onCountChanged: (newCount) { context.read().add( UpdateProductCountEvent( - productId: product.uuid, - count: newCount, - productName: product.catName, - product: product), + selectedProduct: product.toSelectedProduct( + newCount, + ), + ), ); }, ),