import 'package:domain/generated/json/base/json_convert_content.dart';
import 'package:domain/entity/response/t_h_employee_remarks_entity.dart';

THEmployeeRemarksEntity $THEmployeeRemarksEntityFromJson(Map<String, dynamic> json) {
  final THEmployeeRemarksEntity tHEmployeeRemarksEntity = THEmployeeRemarksEntity();
  final int? count = jsonConvert.convert<int>(json['count']);
  if (count != null) {
    tHEmployeeRemarksEntity.count = count;
  }
  final String? avgScore = jsonConvert.convert<String>(json['avg_score']);
  if (avgScore != null) {
    tHEmployeeRemarksEntity.avgScore = avgScore;
  }
  final List<THEmployeeRemarksReviews>? reviews = (json['reviews'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<THEmployeeRemarksReviews>(e) as THEmployeeRemarksReviews).toList();
  if (reviews != null) {
    tHEmployeeRemarksEntity.reviews = reviews;
  }
  final int? memberId = jsonConvert.convert<int>(json['member_id']);
  if (memberId != null) {
    tHEmployeeRemarksEntity.memberId = memberId;
  }
  final String? labourerName = jsonConvert.convert<String>(json['labourer_name']);
  if (labourerName != null) {
    tHEmployeeRemarksEntity.labourerName = labourerName;
  }
  return tHEmployeeRemarksEntity;
}

Map<String, dynamic> $THEmployeeRemarksEntityToJson(THEmployeeRemarksEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['count'] = entity.count;
  data['avg_score'] = entity.avgScore;
  data['reviews'] = entity.reviews.map((v) => v.toJson()).toList();
  data['member_id'] = entity.memberId;
  data['labourer_name'] = entity.labourerName;
  return data;
}

extension THEmployeeRemarksEntityExtension on THEmployeeRemarksEntity {
  THEmployeeRemarksEntity copyWith({
    int? count,
    String? avgScore,
    List<THEmployeeRemarksReviews>? reviews,
    int? memberId,
    String? labourerName,
  }) {
    return THEmployeeRemarksEntity()
      ..count = count ?? this.count
      ..avgScore = avgScore ?? this.avgScore
      ..reviews = reviews ?? this.reviews
      ..memberId = memberId ?? this.memberId
      ..labourerName = labourerName ?? this.labourerName;
  }
}

THEmployeeRemarksReviews $THEmployeeRemarksReviewsFromJson(Map<String, dynamic> json) {
  final THEmployeeRemarksReviews tHEmployeeRemarksReviews = THEmployeeRemarksReviews();
  final String? employerName = jsonConvert.convert<String>(json['employer_name']);
  if (employerName != null) {
    tHEmployeeRemarksReviews.employerName = employerName;
  }
  final double? attitudeRate = jsonConvert.convert<double>(json['attitude_rate']);
  if (attitudeRate != null) {
    tHEmployeeRemarksReviews.attitudeRate = attitudeRate;
  }
  final double? groomingRate = jsonConvert.convert<double>(json['grooming_rate']);
  if (groomingRate != null) {
    tHEmployeeRemarksReviews.groomingRate = groomingRate;
  }
  final double? performanceRate = jsonConvert.convert<double>(json['performance_rate']);
  if (performanceRate != null) {
    tHEmployeeRemarksReviews.performanceRate = performanceRate;
  }
  final double? experienceRate = jsonConvert.convert<double>(json['experience_rate']);
  if (experienceRate != null) {
    tHEmployeeRemarksReviews.experienceRate = experienceRate;
  }
  final String? feedback = jsonConvert.convert<String>(json['feedback']);
  if (feedback != null) {
    tHEmployeeRemarksReviews.feedback = feedback;
  }
  final String? createdAt = jsonConvert.convert<String>(json['created_at']);
  if (createdAt != null) {
    tHEmployeeRemarksReviews.createdAt = createdAt;
  }
  return tHEmployeeRemarksReviews;
}

Map<String, dynamic> $THEmployeeRemarksReviewsToJson(THEmployeeRemarksReviews entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['employer_name'] = entity.employerName;
  data['attitude_rate'] = entity.attitudeRate;
  data['grooming_rate'] = entity.groomingRate;
  data['performance_rate'] = entity.performanceRate;
  data['experience_rate'] = entity.experienceRate;
  data['feedback'] = entity.feedback;
  data['created_at'] = entity.createdAt;
  return data;
}

extension THEmployeeRemarksReviewsExtension on THEmployeeRemarksReviews {
  THEmployeeRemarksReviews copyWith({
    String? employerName,
    double? attitudeRate,
    double? groomingRate,
    double? performanceRate,
    double? experienceRate,
    String? feedback,
    String? createdAt,
  }) {
    return THEmployeeRemarksReviews()
      ..employerName = employerName ?? this.employerName
      ..attitudeRate = attitudeRate ?? this.attitudeRate
      ..groomingRate = groomingRate ?? this.groomingRate
      ..performanceRate = performanceRate ?? this.performanceRate
      ..experienceRate = experienceRate ?? this.experienceRate
      ..feedback = feedback ?? this.feedback
      ..createdAt = createdAt ?? this.createdAt;
  }
}