import 'package:flutter/src/widgets/framework.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:test_sa/controllers/api_routes/urls.dart';
import 'package:test_sa/extensions/context_extension.dart';
import 'package:test_sa/models/device/asset.dart';
import 'package:test_sa/models/fault_description.dart';
import 'package:test_sa/models/lookup.dart';
import 'package:test_sa/models/generic_attachment_model.dart';

class EquipmentInternalAuditFormModel {
  int? id=0;
  String? deviceArName;
  String? auditorId;
  String? woOrderNo;
  List<String>? devicePhotos;
  List<Lookup> findings =[];
  List<GenericAttachmentModel> attachments = [];
  String? remarks;
  Asset? device;
  EquipmentInternalAuditFormModel({
    this.id,
    this.deviceArName,
    this.auditorId,
    this.devicePhotos,
    this.woOrderNo,
    this.remarks,
  });

  Map<String, dynamic> toJson() {
    return {
      'id': id??0,
      'assetId': device?.id,
      'auditorId': auditorId,
      'findings': findings.map((e) => {'findingId': e.value}).toList(),
      'attachments': attachments.whereType<GenericAttachmentModel>().map((e) => e.toInternalAuditJson()).toList(),
      'remarks': remarks,
    };
  }


}