import 'dart:developer';

import 'package:mc_common_app/extensions/string_extensions.dart';
import 'package:mc_common_app/main.dart';
import 'package:mc_common_app/models/chat_models/chat_message_model.dart';
import 'package:mc_common_app/utils/enums.dart';

class ProviderOffersModel {
  int? id;
  int? customerID;
  int? requestType;
  int? requestStatus;
  String? brand;
  String? model;
  int? year;
  bool? isNew;
  String? description;
  double? price;
  int? spOfferCount;
  List<ServiceProvidersOffers>? serviceProviders;

  ProviderOffersModel({
    this.id,
    this.customerID,
    this.requestType,
    this.requestStatus,
    this.brand,
    this.model,
    this.year,
    this.isNew,
    this.description,
    this.price,
    this.spOfferCount,
    this.serviceProviders,
  });

  ProviderOffersModel.fromJson(Map<String, dynamic> json, int? reqId) {
    id = json['id'];
    customerID = json['customerID'];
    requestType = json['requestType'];
    requestStatus = json['requestStatus'];
    brand = json['brand'];
    model = json['model'];
    year = json['year'];
    isNew = json['isNew'];
    description = json['description'];
    price = json['price'];
    spOfferCount = json['spOfferCount'];
    if (json['serviceProviders'] != null) {
      serviceProviders = <ServiceProvidersOffers>[];
      json['serviceProviders'].forEach((v) {
        serviceProviders!.add(ServiceProvidersOffers.fromJson(v, reqId));
      });
    }
  }
}

class ServiceProvidersOffers {
  String? providerUserId;
  int? providerId;
  String? name;
  String? mobileNo;
  String? email;
  String? companyName;
  String? createdOn;
  RequestOfferStatusEnum? requestOfferStatusEnum;
  int? offerCount;
  int? requestId;
  List<ChatMessageModel>? chatMessages;

  ServiceProvidersOffers({
    this.providerId,
    this.name,
    this.mobileNo,
    this.email,
    this.companyName,
    this.offerCount,
    this.requestId,
    this.chatMessages,
    this.providerUserId,
    this.createdOn,
    this.requestOfferStatusEnum,
  });

  ServiceProvidersOffers.fromJson(Map<String, dynamic> json, int? reqId) {
    providerId = json['providerID'];
    providerUserId = json['providerUserID'];
    name = json['name'];
    mobileNo = json['mobileNo'];
    email = json['email'];
    companyName = json['companyName'];
    offerCount = json['offerCount'];
    requestId = reqId;
    createdOn = json['createdOn'];
    requestOfferStatusEnum = ((json['offerStatusLast']) as int).toRequestOfferStatusEnum();
    chatMessages = [];
  }

  @override
  String toString() {
    return 'ServiceProvidersOffers{providerUserId: $providerUserId, providerId: $providerId, name: $name, mobileNo: $mobileNo, email: $email, companyName: $companyName,offeredItemCreatedOn: $createdOn, requestOfferStatusEnum: $requestOfferStatusEnum, offerCount: $offerCount, chatMessages: $chatMessages}';
  }
}
