import 'package:hive_ce/hive.dart';
import 'package:worker/core/constants/storage_constants.dart';

part 'showroom_product_model.g.dart';

@HiveType(typeId: HiveTypeIds.showroomProductModel)
class ShowroomProductModel extends HiveObject {
  ShowroomProductModel({
    required this.showroomId,
    required this.productId,
    required this.quantityUsed,
  });

  @HiveField(0)
  final String showroomId;
  @HiveField(1)
  final String productId;
  @HiveField(2)
  final double quantityUsed;

  factory ShowroomProductModel.fromJson(Map<String, dynamic> json) =>
      ShowroomProductModel(
        showroomId: json['showroom_id'] as String,
        productId: json['product_id'] as String,
        quantityUsed: (json['quantity_used'] as num).toDouble(),
      );

  Map<String, dynamic> toJson() => {
    'showroom_id': showroomId,
    'product_id': productId,
    'quantity_used': quantityUsed,
  };
}
