import 'package:test_sa/models/lookup.dart';
import 'package:test_sa/models/new_models/assistant_employee.dart';
import 'package:test_sa/models/new_models/work_order_detail_model.dart';
import 'package:test_sa/models/service_request/supp_engineer_work_orders.dart';
import 'package:test_sa/models/service_request/supplier_details.dart';
import 'package:test_sa/models/timer_model.dart';

class ActivityMaintenanceHelperModel {
  int? id;
  int? workOrderId;

  //remove this
  int? lastSituationId;
  Lookup? lastSituation;
  Lookup? activityStatus;
  DateTime? startTime;
  DateTime? endTime;
  num? workingHour;
  num? travelHours;
  Lookup? repairLocation;
  SupplierDetails? supplier;
  String? assignedEmployeeId;
  String? technicalComment;
  int? supplierId;
  int? supplierEngineerId;
  DateTime? supplierStartTime;
  DateTime? supplierEndTime;
  num? supplierWorkingHour;

  // AssignedEmployee? assignedEmployee;
  WorkOrderAssignedEmployee? assignedEmployee;
  SuppEngineerWorkOrders? supEngineer;
  ActivityMaintenanceAssistantEmployees? modelAssistantEmployees;
  List<AssistantEmployees>? assistantEmployees;
  List<ActivityMaintenanceTimers>? activityMaintenanceTimers = [];
  TimerModel? activityMaintenanceTimerModel = TimerModel();
  List<TimerModel>? timerModelList = [];

  ActivityMaintenanceHelperModel(
      {this.id,
      this.workOrderId,
      this.lastSituationId,
      this.lastSituation,
      this.activityStatus,
      this.startTime,
      this.supplier,
      this.endTime,
      this.workingHour,
      this.activityMaintenanceTimerModel,
      this.travelHours,
      this.repairLocation,
      this.assignedEmployeeId,
      this.technicalComment,
      this.supplierId,
      this.supplierEngineerId,
      this.supplierStartTime,
      this.supplierEndTime,
      this.supplierWorkingHour,
      this.assistantEmployees,
      this.supEngineer,
      this.assignedEmployee,
      this.activityMaintenanceTimers,
      this.timerModelList,
      this.modelAssistantEmployees});

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};

    data['id'] = id;
    data['workOrderId'] = workOrderId;
    data['activityStatusId'] = activityStatus?.id;
    data['startTime'] = startTime?.toIso8601String();
    data['endTime'] = endTime?.toIso8601String();
    data['workingHour'] = workingHour;
    data['travelHours'] = travelHours;
    data['repairLocationId'] = repairLocation?.id;
    data['assignedEmployeeId'] = assignedEmployee?.userId;
    data['technicalComment'] = technicalComment;
    data['supplierId'] = supplier?.id;
    data['supplierEngineerId'] = supEngineer?.id;
    data['supplierStartTime'] = supplierStartTime?.toIso8601String();
    data['supplierEndTime'] = supplierEndTime?.toIso8601String();
    data['supplierWorkingHour'] = supplierWorkingHour;
    //TODO fix this properly...
    data['activityMaintenanceTimers'] = activityMaintenanceTimers;
    if (assistantEmployees != null && assistantEmployees!.isNotEmpty) {
      data['assistantEmployees'] = [modelAssistantEmployees?.toJson()];
    } else {
      data['assistantEmployees'] = [];
    }
    return data;
  }
}
