add toSelected function to convert from product to selectedProduct

This commit is contained in:
Rafeek Alkhoudare
2025-05-26 06:11:06 -05:00
parent 0b65c58947
commit c97dd40b05
2 changed files with 15 additions and 4 deletions

View File

@ -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,

View File

@ -54,10 +54,10 @@ class DeviceTypeTileWidget extends StatelessWidget {
onCountChanged: (newCount) {
context.read<AddDeviceTypeModelBloc>().add(
UpdateProductCountEvent(
productId: product.uuid,
count: newCount,
productName: product.catName,
product: product),
selectedProduct: product.toSelectedProduct(
newCount,
),
),
);
},
),