mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 15:17:31 +00:00
add toSelected function to convert from product to selectedProduct
This commit is contained in:
@ -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,
|
||||
|
@ -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,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
|
Reference in New Issue
Block a user