import 'package:test_sa/app_strings/app_asset.dart';
import 'package:test_sa/models/enums/demo_request_step.dart';
import 'package:test_sa/models/enums/recurrent_task_inspection_data_type.dart';
import 'package:test_sa/models/enums/swipe_type.dart';
import 'package:test_sa/models/enums/work_order_next_step.dart';

extension EnumExtensionsWorkOrder on WorkOrderNextStepEnum {
  int getIntFromWorkOrderNextStepEnum() {
    switch (this) {
      case WorkOrderNextStepEnum.assignToMe:
        return 2;
      case WorkOrderNextStepEnum.markedAsFixed:
        return 3;
      case WorkOrderNextStepEnum.nTakeAction:
        return 5;

      case WorkOrderNextStepEnum.eRejectAccept:
        return 9;

      case WorkOrderNextStepEnum.eFixRemotelyNeedVisit:
        return 12;

      case WorkOrderNextStepEnum.eArrived:
        return 15;

      case WorkOrderNextStepEnum.verifyAssetDetail:
        return 16;

      case WorkOrderNextStepEnum.activity:
        return 17;

      case WorkOrderNextStepEnum.endWorkFlow:
        return 22;
      case WorkOrderNextStepEnum.assetRetirementManagementApproval:
        return 26;
      case WorkOrderNextStepEnum.waitingForRequesterToConfirm:
        //replace with correct value...
        return 31;
      case WorkOrderNextStepEnum.eFixRemotely:
        return 35;
      case WorkOrderNextStepEnum.eNeedVisit:
        return 36;
    }
  }
}

extension IntExtensionsWorkOrder on int {
  WorkOrderNextStepEnum toWorkOrderNextStepEnum() {
    switch (this) {
      case 2:
        return WorkOrderNextStepEnum.assignToMe;
      case 3:
        return WorkOrderNextStepEnum.markedAsFixed;
      case 5:
        return WorkOrderNextStepEnum.nTakeAction;
      case 9:
        return WorkOrderNextStepEnum.eRejectAccept;
      case 12:
        return WorkOrderNextStepEnum.eFixRemotelyNeedVisit;
      case 15:
        return WorkOrderNextStepEnum.eArrived;
      case 16:
        return WorkOrderNextStepEnum.verifyAssetDetail;
      case 17:
        return WorkOrderNextStepEnum.activity;
      case 22:
        return WorkOrderNextStepEnum.endWorkFlow;
      case 26:
        return WorkOrderNextStepEnum.assetRetirementManagementApproval;
      case 31:
        return WorkOrderNextStepEnum.waitingForRequesterToConfirm;
      case 35:
        return WorkOrderNextStepEnum.eFixRemotely;
      case 36:
        return WorkOrderNextStepEnum.eNeedVisit;
      default:
        return WorkOrderNextStepEnum.assignToMe;
    }
  }

  String getVerificationIconByValue() {
    switch (this) {
      case 1:
        return AppAsset.scanQrIcon;
      case 2:
        return AppAsset.askRequesterIcon;
      case 3:
        return AppAsset.askOtpIcon;
      case 4:
        return AppAsset.takeDevicePhotoIcon;
      case 5:
        return AppAsset.scanQrIcon;
      default:
        return AppAsset.askRequesterIcon;
    }
  }
}

extension IntExtensionsDemoRequest on int {
  DemoRequestStepEnum toDemoRequestStepEnum() {
    //Todo need to check exact stages
    switch (this) {
      // {      "id": 7690,      "name": "Pending Assessor Acceptance",      "value": 5    },
      //
      // update request details
      //
      //
      // {      "id": 7692,      "name": "Assessor Audit Doc Pending",      "value": 7    },
      //
      // Update request details
      //
      //
      // {      "id": 7766,      "name": "Demo Period Expired",      "value": 15    }
      //
      // request for extention
      //
      //
      // {      "id": 7769,      "name": "Awaiting MD Evaluation",      "value": 18    },
      //
      // evaluation

      case 5:
        return DemoRequestStepEnum.qAuditorRejectAccept;
      // case 7:
      //   return DemoRequestStepEnum.qAuditorRejectAccept;
      case 5:
        return DemoRequestStepEnum.updateRequest;

      case 21:
        return DemoRequestStepEnum.updateRequest;
        return DemoRequestStepEnum.viewOnly;
      case 15:
        return DemoRequestStepEnum.extendDemoPeriod;
      case 18:
        return DemoRequestStepEnum.submitEvaluation;
      default:
        return DemoRequestStepEnum.viewOnly;
    }
  }
}

extension EnumExtensionsSwipeType on SwipeTypeEnum {
  int getIntFromSwipeTypeEnum() {
    switch (this) {
      case SwipeTypeEnum.NFC:
        return 1;
      case SwipeTypeEnum.QR:
        return 2;
      case SwipeTypeEnum.Wifi:
        return 3;
    }
  }
}

extension StringExtensionsRecurrentTaskInpesctionDataType on String {
  RecurrentTaskInspectionDataTypeEnum toRecurrentTaskInspectionDataTypeEnum() {
    switch (this) {
      case 'bool':
        return RecurrentTaskInspectionDataTypeEnum.bool;
      case 'number':
        return RecurrentTaskInspectionDataTypeEnum.number;
      default:
        return RecurrentTaskInspectionDataTypeEnum.bool;
    }
  }
}

extension IntExtensionsAssetDeliveryStage on int {
  AssetDeliveryStageEnum toAssetDeliveryStageEnum() {
    switch (this) {
      case 2:
        return AssetDeliveryStageEnum.deliveryInspection;
      case 3:
        return AssetDeliveryStageEnum.technicalInspection;
      case 4:
        return AssetDeliveryStageEnum.endUserAcceptance;
      default:
        return AssetDeliveryStageEnum.other;
    }
  }
}

enum DropDownMatchType {
  identifier,
  name,
}

enum CostCenterType {
  costCenter,
  serialNumber,
}

enum AssetDeliveryStageEnum {
  deliveryInspection,
  technicalInspection,
  endUserAcceptance,
  other,
}

enum RequestTypeEnum {
  unassigned,
  open,
  inProgress,
  completed,
  closed,
  canceled,
  overdue,
  highPriority,
  pendingAcknowledgment,
}
