import 'package:test_sa/models/lookup.dart';
import 'package:test_sa/models/service_request/spare_parts.dart';

class SparePartHelperModel {
  int? id;
  int? workOrderId;
  int? partCatalogItemId;
  int? activityStatusId;
  SparePart? sparePart;
  Lookup? activityStatus;
  num? quantity;
  num? installQty;
  num? returnQty;
  String? comment;
  List<SparePartAttachments>? sparePartAttachments;

  SparePartHelperModel({
    this.id,
    this.workOrderId,
    this.partCatalogItemId,
    this.quantity,
    this.installQty,
    this.returnQty,
    this.sparePart,
    this.activityStatusId,
    this.activityStatus,
    this.comment,this.sparePartAttachments,
  });


  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['id'] = id;
    data['workOrderId'] = workOrderId;
    data['partCatalogItemId'] = sparePart?.id;
    data['quantity'] = quantity;
    data['installQty'] = installQty;
    data['returnQty'] = returnQty;
    if(activityStatus!=null){
      data['activityStatusId'] = activityStatus?.id;
    }
    data['comment'] = comment;
    if (sparePartAttachments != null) {
      data['acitiySparePartAttachments'] =
          sparePartAttachments!.map((v) => v.toJson()).toList();
    }
    return data;
  }
}

class SparePartAttachments {
  int? id;
  String? name;

  SparePartAttachments({this.id, this.name});

  SparePartAttachments.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    name = json['name'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['id'] = id;
    data['name'] = name;
    return data;
  }
}