import 'package:auto_size_text/auto_size_text.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/cupertino.dart';
import 'package:mc_common_app/classes/app_state.dart';
import 'package:mc_common_app/classes/consts.dart';
import 'package:mc_common_app/theme/colors.dart';
import 'package:mc_common_app/utils/date_helper.dart';
import 'package:mc_common_app/utils/enums.dart';

extension EmailValidator on String {
  Widget toText(
      {Color? color,
      bool isBold = false,
      double? fontSize,
      bool isUnderLine = false,
      bool isItalic = false,
      TextDecoration? textDecoration,
      double letterSpacing = 0,
      TextAlign? textAlign,
      FontWeight? fontWeight,
      double? height,
      Color? decorationColor,
      TextOverflow? overflow,
      bool isUpperCase = false,
      int? maxLines}) {
    bool isArabic = AppState().postParamsObject!.languageID == 1; // arabic -> 1 , English -> 2
    return AutoSizeText(
      isUpperCase ? toUpperCase() : this,
      textAlign: textAlign,
      maxLines: maxLines,
      style: TextStyle(
        overflow: overflow,
        fontStyle: isItalic ? FontStyle.italic : null,
        height: height,
        decoration: isUnderLine ? TextDecoration.underline : textDecoration ?? TextDecoration.none,
        decorationColor: decorationColor ?? color ?? MyColors.darkTextColor,
        fontSize: fontSize ?? 10,
        fontFamily: isArabic ? MyFonts.gessTwoFont : MyFonts.poppinsFont,
        fontWeight: isBold ? FontWeight.bold : fontWeight ?? MyFonts.SemiBold,
        color: color ?? MyColors.darkTextColor,
        letterSpacing: letterSpacing,
      ),
    );
  }

  bool isValidEmail() {
    return RegExp(r'^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$').hasMatch(this);
  }

  bool isNum() {
    return RegExp(r'^[0-9]+$').hasMatch(this);
  }

  getMonth(int month) {
    switch (month) {
      case 1:
        return "January";
      case 2:
        return "February";
      case 3:
        return "March";
      case 4:
        return "April";
      case 5:
        return "May";
      case 6:
        return "June";
      case 7:
        return "July";
      case 8:
        return "August";
      case 9:
        return "September";
      case 10:
        return "October";
      case 11:
        return "November";
      case 12:
        return "December";
    }
  }
}

extension FormatDate on String {
  /// get month by
  /// [month] convert month number in to month name
  /// get month by
  /// [month] convert month number in to month name in Arabic
  static String getMonthArabic(int month) {
    switch (month) {
      case 1:
        return "يناير";
      case 2:
        return " فبراير";
      case 3:
        return "مارس";
      case 4:
        return "أبريل";
      case 5:
        return "مايو";
      case 6:
        return "يونيو";
      case 7:
        return "يوليو";
      case 8:
        return "أغسطس";
      case 9:
        return "سبتمبر";
      case 10:
        return " اكتوبر";
      case 11:
        return " نوفمبر";
      case 12:
        return "ديسمبر";
      default:
        return "";
    }
  }

  static String getMonth(int month) {
    switch (month) {
      case 1:
        return "January";
      case 2:
        return "February";
      case 3:
        return "March";
      case 4:
        return "April";
      case 5:
        return "May";
      case 6:
        return "June";
      case 7:
        return "July";
      case 8:
        return "August";
      case 9:
        return "September";
      case 10:
        return "October";
      case 11:
        return "November";
      case 12:
        return "December";
      default:
        return "";
    }
  }

  String toFormattedDate() {
    String date = split("T")[0];
    String time = split("T")[1];
    var dates = date.split("-");
    return "${dates[2]} ${getMonth(int.parse(dates[1]))} ${dates[0]} ${DateFormat('hh:mm a', "en_US").format(DateFormat('hh:mm:ss', "en_US").parse(time))}";
  }

  String toFormattedDateWithoutTime() {
    String date = split("T")[0];
    var dates = date.split("-");
    return "${dates[2]} ${getMonth(int.parse(dates[1]))}, ${dates[0]}";
  }
}

extension RequestEnum on int {
  RequestStatusEnum toRequestStatusEnum() {
    if (this == 1) {
      return RequestStatusEnum.submitted;
    } else if (this == 2) {
      return RequestStatusEnum.inProgress;
    } else if (this == 3) {
      return RequestStatusEnum.completed;
    } else if (this == 4) {
      return RequestStatusEnum.cancelled;
    } else if (this == 5) {
      return RequestStatusEnum.paid;
    } else if (this == 6) {
      return RequestStatusEnum.expired;
    } else if (this == 7) {
      return RequestStatusEnum.shipping;
    } else if (this == 8) {
      return RequestStatusEnum.delivery;
    } else {
      return RequestStatusEnum.pending;
    }
  }
}

extension RequestStatusEnumToInt on RequestStatusEnum {
  int getIdFromRequestStatusEnum() {
    switch (this) {
      case RequestStatusEnum.submitted:
        return 1;
      case RequestStatusEnum.inProgress:
        return 2;
      case RequestStatusEnum.completed:
        return 3;
      case RequestStatusEnum.cancelled:
        return 4;
      case RequestStatusEnum.paid:
        return 5;
      case RequestStatusEnum.expired:
        return 6;
      case RequestStatusEnum.shipping:
        return 7;
      case RequestStatusEnum.delivery:
        return 8;
      case RequestStatusEnum.pending:
        return 0;

      default:
        return 0;
    }
  }
}

extension AdPostEnum on int {
  AdPostStatus toAdPostEnum() {
    if (this == 1) {
      return AdPostStatus.pendingForReview;
    } else if (this == 2) {
      return AdPostStatus.pendingForPayment;
    } else if (this == 3) {
      return AdPostStatus.rejected;
    } else if (this == 4) {
      return AdPostStatus.cancelled;
    } else if (this == 5) {
      return AdPostStatus.pendingForPost;
    } else if (this == 6) {
      return AdPostStatus.active;
    } else if (this == 7) {
      return AdPostStatus.expired;
    } else if (this == 8) {
      return AdPostStatus.sold;
    } else if (this == 9) {
      return AdPostStatus.reserved;
    } else if (this == 10) {
      return AdPostStatus.buyingService;
    } else if (this == 11) {
      return AdPostStatus.reserveCancel;
    } else if (this == 12) {
      return AdPostStatus.deActive;
    } else if (this == 13) {
      return AdPostStatus.pendingForActive;
    } else if (this == 0) {
      return AdPostStatus.allAds;
    } else {
      return AdPostStatus.pendingForPost;
    }
  }
}

extension AppointmentStatusToInt on AppointmentStatusEnum {
  int getIdFromAppointmentStatusEnum() {
    switch (this) {
      case AppointmentStatusEnum.booked:
        return 1;

      case AppointmentStatusEnum.confirmed:
        return 2;

      case AppointmentStatusEnum.arrived:
        return 3;

      case AppointmentStatusEnum.cancelled:
        return 4;

      case AppointmentStatusEnum.rescheduled:
        return 5;

      case AppointmentStatusEnum.workStarted:
        return 7;

      case AppointmentStatusEnum.visitCompleted:
        return 8;

      case AppointmentStatusEnum.today:
        return 9;

      case AppointmentStatusEnum.past:
        return 10;

      case AppointmentStatusEnum.upcoming:
        return 11;

      case AppointmentStatusEnum.allAppointments:
        return 0;

      default:
        return 0;
    }
  }
}

extension AppointmentTypeEnumExt on int {
  AppointmentTypeEnum toAppointmentTypeEnum() {
    if (this == 1) {
      return AppointmentTypeEnum.workshop;
    } else if (this == 2) {
      return AppointmentTypeEnum.home;
    } else {
      return AppointmentTypeEnum.workshop;
    }
  }
}

extension AppointmentTypeEnumExtString on AppointmentTypeEnum {
  int getIdFromAppointmentTypeEnum() {
    switch (this) {
      case AppointmentTypeEnum.workshop:
        return 1;
      case AppointmentTypeEnum.home:
        return 2;
      default:
        return 1;
    }
  }
}

extension AppointmentStatusToString on AppointmentStatusEnum {
  String getAppointmentNameFromEnum() {
    switch (this) {
      case AppointmentStatusEnum.booked:
        return "Booked";

      case AppointmentStatusEnum.confirmed:
        return "Confirmed";

      case AppointmentStatusEnum.arrived:
        return "Arrived";

      case AppointmentStatusEnum.cancelled:
        return "Canceled";

      case AppointmentStatusEnum.rescheduled:
        return "Rescheduled";

      case AppointmentStatusEnum.upcoming:
        return "Upcoming";

      case AppointmentStatusEnum.workStarted:
        return "Work Started";

      case AppointmentStatusEnum.visitCompleted:
        return "Visit Completed";

      case AppointmentStatusEnum.past:
        return "Past";

      case AppointmentStatusEnum.today:
        return "Today";

      default:
        return "Booked";
    }
  }
}

extension AppointmentEnum on int {
  AppointmentStatusEnum toAppointmentStatusEnum() {
    if (this == 1) {
      return AppointmentStatusEnum.booked;
    } else if (this == 2) {
      return AppointmentStatusEnum.confirmed;
    } else if (this == 3) {
      return AppointmentStatusEnum.arrived;
    } else if (this == 4) {
      return AppointmentStatusEnum.cancelled;
    } else if (this == 5) {
      return AppointmentStatusEnum.rescheduled;
    } else if (this == 7) {
      return AppointmentStatusEnum.workStarted;
    } else if (this == 8) {
      return AppointmentStatusEnum.visitCompleted;
    } else if (this == 9) {
      return AppointmentStatusEnum.today;
    } else if (this == 10) {
      return AppointmentStatusEnum.past;
    } else if (this == 11) {
      return AppointmentStatusEnum.upcoming;
    } else {
      return AppointmentStatusEnum.allAppointments;
    }
  }
}

extension AppointmentPaymentStatusToInt on AppointmentPaymentStatusEnum {
  int getIdFromAppointmentPaymentStatusEnum() {
    switch (this) {
      case AppointmentPaymentStatusEnum.defaultStatus:
        return 1;

      case AppointmentPaymentStatusEnum.payNow:
        return 2;

      case AppointmentPaymentStatusEnum.paid:
        return 3;

      case AppointmentPaymentStatusEnum.payLater:
        return 4;

      case AppointmentPaymentStatusEnum.payPartial:
        return 5;

      default:
        return 1;
    }
  }
}

extension AppointmentPaymentEnum on int {
  AppointmentPaymentStatusEnum toAppointmentPaymentStatusEnum() {
    if (this == 1) {
      return AppointmentPaymentStatusEnum.defaultStatus;
    } else if (this == 2) {
      return AppointmentPaymentStatusEnum.payNow;
    } else if (this == 3) {
      return AppointmentPaymentStatusEnum.paid;
    } else if (this == 4) {
      return AppointmentPaymentStatusEnum.payLater;
    } else if (this == 5) {
      return AppointmentPaymentStatusEnum.payPartial;
    } else {
      return AppointmentPaymentStatusEnum.defaultStatus;
    }
  }
}

extension RequestTypeTypEnum on int {
  RequestsTypeEnum toRequestTypeEnum() {
    if (this == 1) {
      return RequestsTypeEnum.specialCarRequest;
    } else if (this == 2) {
      return RequestsTypeEnum.serviceRequest;
    }
    return RequestsTypeEnum.specialCarRequest;
  }
}

extension RequestTypeStatusToInt on RequestsTypeEnum {
  int getIdFromRequestTypeEnum() {
    switch (this) {
      case RequestsTypeEnum.specialCarRequest:
        return 1;

      case RequestsTypeEnum.serviceRequest:
        return 2;

      default:
        return 0;
    }
  }
}

extension AdPostStatusToInt on AdPostStatus {
  int getIdFromAdPostStatusEnum() {
    switch (this) {
      case AdPostStatus.pendingForReview:
        return 1;

      case AdPostStatus.pendingForPayment:
        return 2;

      case AdPostStatus.rejected:
        return 3;

      case AdPostStatus.cancelled:
        return 4;

      case AdPostStatus.pendingForPost:
        return 5;

      case AdPostStatus.active:
        return 6;

      case AdPostStatus.expired:
        return 7;

      case AdPostStatus.sold:
        return 8;

      case AdPostStatus.reserved:
        return 9;

      case AdPostStatus.buyingService:
        return 10;

      case AdPostStatus.reserveCancel:
        return 11;

      case AdPostStatus.deActive:
        return 12;

      case AdPostStatus.pendingForActive:
        return 13;

      default:
        return 0;
    }
  }
}

extension PaymentTypesToInt on PaymentTypes {
  int getIdFromPaymentTypesEnum() {
    switch (this) {
      case PaymentTypes.subscription:
        return 1;
      case PaymentTypes.appointment:
        return 2;
      case PaymentTypes.adReserve:
        return 4;
      case PaymentTypes.ads:
        return 3;
      case PaymentTypes.request:
        return 5;
      case PaymentTypes.extendAds:
        return 6;
      case PaymentTypes.partialAppointment:
        return 7;

      default:
        return 0;
    }
  }
}

extension PaymentIdToPaymentTypes on int {
  PaymentTypes getPaymentTypeFromId() {
    switch (this) {
      case 1:
        return PaymentTypes.subscription;
      case 2:
        return PaymentTypes.appointment;
      case 4:
        return PaymentTypes.adReserve;
      case 3:
        return PaymentTypes.ads;
      case 5:
        return PaymentTypes.request;
      case 6:
        return PaymentTypes.extendAds;
      case 7:
        return PaymentTypes.partialAppointment;

      default:
        return PaymentTypes.ads;
    }
  }
}

extension CreatedByRoleEnumToInt on CreatedByRoleEnum {
  int getIdFromCreatedByRoleEnum() {
    switch (this) {
      case CreatedByRoleEnum.admin:
        return 1;
      case CreatedByRoleEnum.customer:
        return 2;
      case CreatedByRoleEnum.provider:
        return 3;
      case CreatedByRoleEnum.allAds:
        return 0;
      default:
        return 1;
    }
  }
}

extension AdReserveStatusEnum on int {
  AdReserveStatus toAdRserveStatusEnum() {
    if (this == 0) {
      return AdReserveStatus.defaultStatus;
    } else if (this == 1) {
      return AdReserveStatus.reserved;
    } else if (this == 2) {
      return AdReserveStatus.cancelledByOwner;
    } else if (this == 3) {
      return AdReserveStatus.cancelledByAdmin;
    } else if (this == 4) {
      return AdReserveStatus.timeOver;
    } else if (this == 5) {
      return AdReserveStatus.dealDone;
    } else if (this == 6) {
      return AdReserveStatus.fullPaymentVerified;
    } else {
      return AdReserveStatus.defaultStatus;
    }
  }
}

extension AdOwnerEnum on int {
  CreatedByRoleEnum toCreatedByRoleEnum() {
    if (this == 0) {
      return CreatedByRoleEnum.allAds;
    } else if (this == 1) {
      return CreatedByRoleEnum.admin;
    } else if (this == 2) {
      return CreatedByRoleEnum.customer;
    } else if (this == 3) {
      return CreatedByRoleEnum.provider;
    }
    return CreatedByRoleEnum.customer;
  }
}

extension BranchsEnum on int {
  BranchStatusEnum toBranchStatusEnum() {
    if (this == 1) {
      return BranchStatusEnum.pending;
    } else if (this == 2) {
      return BranchStatusEnum.review;
    } else if (this == 3) {
      return BranchStatusEnum.approvedOrActive;
    } else if (this == 4) {
      return BranchStatusEnum.rejected;
    } else if (this == 5) {
      return BranchStatusEnum.blocked;
    } else if (this == 6) {
      return BranchStatusEnum.deactivated;
    } else {
      return BranchStatusEnum.pending;
    }
  }
}

extension ServiceEnum on int {
  ServiceStatusEnum toServiceStatusEnum() {
    if (this == 1) {
      return ServiceStatusEnum.pending;
    } else if (this == 2) {
      return ServiceStatusEnum.review;
    } else if (this == 3) {
      return ServiceStatusEnum.approvedOrActive;
    } else if (this == 4) {
      return ServiceStatusEnum.rejected;
    } else if (this == 5) {
      return ServiceStatusEnum.blocked;
    } else if (this == 6) {
      return ServiceStatusEnum.deactivated;
    } else {
      return ServiceStatusEnum.pending;
    }
  }
}

extension BranchServiceEnumStatusToInt on ServiceStatusEnum {
  int getIdFromServiceStatusEnum() {
    switch (this) {
      case ServiceStatusEnum.pending:
        return 1;

      case ServiceStatusEnum.review:
        return 2;

      case ServiceStatusEnum.approvedOrActive:
        return 3;

      case ServiceStatusEnum.rejected:
        return 4;

      case ServiceStatusEnum.blocked:
        return 5;

      case ServiceStatusEnum.deactivated:
        return 6;

      default:
        return 1;
    }
  }
}

extension DateTimeConversions on DateTime {
  String getTimeAgo({bool numericDates = true}) {
    final date2 = DateTime.now();
    final difference = date2.difference(this);
    if ((difference.inDays / 7).floor() >= 2) {
      return DateHelper.formatAsDayMonthYear(this);
    } else if ((difference.inDays / 7).floor() >= 1) {
      return (numericDates) ? '1 week ago' : 'Last week';
    } else if (difference.inDays >= 2) {
      return '${difference.inDays} days ago';
    } else if (difference.inDays >= 1) {
      return (numericDates) ? '1 day ago' : 'Yesterday';
    } else if (difference.inHours >= 2) {
      return '${difference.inHours} hours ago';
    } else if (difference.inHours >= 1) {
      return (numericDates) ? '1 hour ago' : 'An hour ago';
    } else if (difference.inMinutes >= 2) {
      return '${difference.inMinutes} min ago';
    } else if (difference.inMinutes >= 1) {
      return (numericDates) ? '1 min ago' : 'A min ago';
    } else if (difference.inSeconds >= 3) {
      return '${difference.inSeconds} sec ago';
    } else {
      return 'Just now';
    }
  }
}

extension VehicleAdTypeEnum on int {
  VehicleType toVehicleTypeEnum() {
    if (this == 1) {
      return VehicleType.car;
    } else if (this == 2) {
      return VehicleType.motorCycle;
    } else if (this == 3) {
      return VehicleType.golfCart;
    } else if (this == 4) {
      return VehicleType.buggy;
    } else {
      return VehicleType.car;
    }
  }

  String toVehicleTypeString() {
    if (this == 1) {
      return "Car";
    } else if (this == 2) {
      return "Motorcycle";
    } else if (this == 3) {
      return "Golf Cart";
    } else if (this == 4) {
      return "Buggy";
    } else {
      return "Car";
    }
  }
}

extension FormatMonthByName on int {
  String getMonthNameByNumber() {
    switch (this) {
      case 1:
        return "January";
      case 2:
        return "February";
      case 3:
        return "March";
      case 4:
        return "April";
      case 5:
        return "May";
      case 6:
        return "June";
      case 7:
        return "July";
      case 8:
        return "August";
      case 9:
        return "September";
      case 10:
        return "October";
      case 11:
        return "November";
      case 12:
        return "December";
      default:
        return "";
    }
  }
}

extension FormatMonthByNumber on String {
  int getMonthNumberByName() {
    switch (this) {
      case "January":
        return 1;
      case "February":
        return 2;
      case "March":
        return 3;
      case "April":
        return 4;
      case "May":
        return 5;
      case "June":
        return 6;
      case "July":
        return 7;
      case "August":
        return 8;
      case "September":
        return 9;
      case "October":
        return 10;
      case "November":
        return 11;
      case "December":
        return 12;
      default:
        return 1;
    }
  }
}

extension NameExtensions on String {
  String getInitials() {
    final name = trim();
    String initials = "";
    if (name.isEmpty) {
      return initials;
    }
    final list = name.split(' ');

    if (list.length > 1) {
      initials = list[0][0].toUpperCase() + list[1][0].toUpperCase();
    }

    return initials;
  }
}

extension ChatMessageTypeEnumExt on int {
  //FreeText = 1,
  //     Image = 2,
  //     Audio = 3,
  //     Video = 4,
  //     Offer = 5
  ChatMessageTypeEnum toChatMessageTypeEnum() {
    if (this == 1) {
      return ChatMessageTypeEnum.freeText;
    } else if (this == 2) {
      return ChatMessageTypeEnum.image;
    } else if (this == 3) {
      return ChatMessageTypeEnum.audio;
    } else if (this == 4) {
      return ChatMessageTypeEnum.video;
    } else if (this == 5) {
      return ChatMessageTypeEnum.offer;
    }
    return ChatMessageTypeEnum.freeText;
  }
}

extension ChatMessageTypeToInt on ChatMessageTypeEnum {
  int getIdFromChatMessageTypeEnum() {
    switch (this) {
      case ChatMessageTypeEnum.freeText:
        return 1;
      case ChatMessageTypeEnum.image:
        return 2;
      case ChatMessageTypeEnum.audio:
        return 3;
      case ChatMessageTypeEnum.video:
        return 4;
      case ChatMessageTypeEnum.offer:
        return 5;

      default:
        return 1;
    }
  }
}

extension RequestOfferStatusEnumExt on int {
  RequestOfferStatusEnum toRequestOfferStatusEnum() {
    if (this == 1) {
      return RequestOfferStatusEnum.offer;
    } else if (this == 2) {
      return RequestOfferStatusEnum.negotiate;
    } else if (this == 3) {
      return RequestOfferStatusEnum.accepted;
    } else if (this == 4) {
      return RequestOfferStatusEnum.rejected;
    } else if (this == 5) {
      return RequestOfferStatusEnum.cancel;
    }
    return RequestOfferStatusEnum.cancel;
  }
}

extension RequestOfferStatusEnumToInt on RequestOfferStatusEnum {
  int getIdFromRequestOfferStatusEnum() {
    switch (this) {
      case RequestOfferStatusEnum.offer:
        return 1;
      case RequestOfferStatusEnum.negotiate:
        return 2;
      case RequestOfferStatusEnum.accepted:
        return 3;
      case RequestOfferStatusEnum.rejected:
        return 4;
      case RequestOfferStatusEnum.cancel:
        return 5;

      default:
        return 0;
    }
  }
}

extension ChatTypeEnumExt on int {
  ChatTypeEnum toChatTypeEnum() {
    if (this == 1) {
      return ChatTypeEnum.general;
    } else if (this == 2) {
      return ChatTypeEnum.ads;
    } else if (this == 3) {
      return ChatTypeEnum.requestOffer;
    }
    return ChatTypeEnum.general;
  }
}

extension ChatTypeEnumToInt on ChatTypeEnum {
  int getIdFromChatTypeEnum() {
    switch (this) {
      case ChatTypeEnum.general:
        return 1;
      case ChatTypeEnum.ads:
        return 2;
      case ChatTypeEnum.requestOffer:
        return 3;

      default:
        return 1;
    }
  }
}

extension SubscriptionTypeEnumExt on int {
  SubscriptionTypeEnum toSubscriptionTypeEnum() {
    if (this == 2) {
      return SubscriptionTypeEnum.upgrade;
    } else if (this == 3) {
      return SubscriptionTypeEnum.downgrade;
    }
    return SubscriptionTypeEnum.current;
  }
}

extension SubscriptionTypeEnumToInt on SubscriptionTypeEnum {
  int getIdSubscriptionTypeEnum() {
    switch (this) {
      case SubscriptionTypeEnum.current:
        return 1;
      case SubscriptionTypeEnum.upgrade:
        return 2;
      case SubscriptionTypeEnum.downgrade:
        return 3;

      default:
        return 1;
    }
  }
}

extension SubscriptionTypeEnumToString on SubscriptionTypeEnum {
  String getStringSubscriptionTypeEnum() {
    switch (this) {
      case SubscriptionTypeEnum.current:
        return "Current";
      case SubscriptionTypeEnum.upgrade:
        return "Upgrade";
      case SubscriptionTypeEnum.downgrade:
        return "Downgrade";

      default:
        return "Current";
    }
  }
}

extension ShippingStatusEnumExt on int {
  ShippingRequestStatusEnum toShippingStatusEnum() {
    if (this == -1) {
      return ShippingRequestStatusEnum.allRequests;
    } else if (this == 0) {
      return ShippingRequestStatusEnum.pending;
    } else if (this == 1) {
      return ShippingRequestStatusEnum.initiated;
    } else if (this == 2) {
      return ShippingRequestStatusEnum.inTransit;
    } else if (this == 3) {
      return ShippingRequestStatusEnum.outForDelivery;
    } else if (this == 4) {
      return ShippingRequestStatusEnum.delivered;
    }
    return ShippingRequestStatusEnum.pending;
  }
}

extension ShippingStatusEnumToInt on ShippingRequestStatusEnum {
  int getIdFromShippingStatusEnum() {
    switch (this) {
      case ShippingRequestStatusEnum.pending:
        return 0;
      case ShippingRequestStatusEnum.initiated:
        return 1;
      case ShippingRequestStatusEnum.inTransit:
        return 2;
      case ShippingRequestStatusEnum.outForDelivery:
        return 3;
      case ShippingRequestStatusEnum.delivered:
        return 4;
      default:
        return 0;
    }
  }
}
