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

UKReportLabourEntity $UKReportLabourEntityFromJson(Map<String, dynamic> json) {
  final UKReportLabourEntity uKReportLabourEntity = UKReportLabourEntity();
  final int? total = jsonConvert.convert<int>(json['total']);
  if (total != null) {
    uKReportLabourEntity.total = total;
  }
  final List<UKReportLabourRows>? rows = (json['rows'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<UKReportLabourRows>(e) as UKReportLabourRows).toList();
  if (rows != null) {
    uKReportLabourEntity.rows = rows;
  }
  return uKReportLabourEntity;
}

Map<String, dynamic> $UKReportLabourEntityToJson(UKReportLabourEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['total'] = entity.total;
  data['rows'] = entity.rows.map((v) => v.toJson()).toList();
  return data;
}

extension UKReportLabourEntityExtension on UKReportLabourEntity {
  UKReportLabourEntity copyWith({
    int? total,
    List<UKReportLabourRows>? rows,
  }) {
    return UKReportLabourEntity()
      ..total = total ?? this.total
      ..rows = rows ?? this.rows;
  }
}

UKReportLabourRows $UKReportLabourRowsFromJson(Map<String, dynamic> json) {
  final UKReportLabourRows uKReportLabourRows = UKReportLabourRows();
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    uKReportLabourRows.id = id;
  }
  final String? jobDate = jsonConvert.convert<String>(json['job_date']);
  if (jobDate != null) {
    uKReportLabourRows.jobDate = jobDate;
  }
  final String? departmentName = jsonConvert.convert<String>(json['department_name']);
  if (departmentName != null) {
    uKReportLabourRows.departmentName = departmentName;
  }
  final String? jobTitle = jsonConvert.convert<String>(json['job_title']);
  if (jobTitle != null) {
    uKReportLabourRows.jobTitle = jobTitle;
  }
  final String? startTime = jsonConvert.convert<String>(json['start_time']);
  if (startTime != null) {
    uKReportLabourRows.startTime = startTime;
  }
  final String? endTime = jsonConvert.convert<String>(json['end_time']);
  if (endTime != null) {
    uKReportLabourRows.endTime = endTime;
  }
  final int? needNum = jsonConvert.convert<int>(json['need_num']);
  if (needNum != null) {
    uKReportLabourRows.needNum = needNum;
  }
  final int? realNum = jsonConvert.convert<int>(json['real_num']);
  if (realNum != null) {
    uKReportLabourRows.realNum = realNum;
  }
  final String? createdAt = jsonConvert.convert<String>(json['created_at']);
  if (createdAt != null) {
    uKReportLabourRows.createdAt = createdAt;
  }
  final String? approvedAt = jsonConvert.convert<String>(json['approved_at']);
  if (approvedAt != null) {
    uKReportLabourRows.approvedAt = approvedAt;
  }
  return uKReportLabourRows;
}

Map<String, dynamic> $UKReportLabourRowsToJson(UKReportLabourRows entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['job_date'] = entity.jobDate;
  data['department_name'] = entity.departmentName;
  data['job_title'] = entity.jobTitle;
  data['start_time'] = entity.startTime;
  data['end_time'] = entity.endTime;
  data['need_num'] = entity.needNum;
  data['real_num'] = entity.realNum;
  data['created_at'] = entity.createdAt;
  data['approved_at'] = entity.approvedAt;
  return data;
}

extension UKReportLabourRowsExtension on UKReportLabourRows {
  UKReportLabourRows copyWith({
    String? id,
    String? jobDate,
    String? departmentName,
    String? jobTitle,
    String? startTime,
    String? endTime,
    int? needNum,
    int? realNum,
    String? createdAt,
    String? approvedAt,
  }) {
    return UKReportLabourRows()
      ..id = id ?? this.id
      ..jobDate = jobDate ?? this.jobDate
      ..departmentName = departmentName ?? this.departmentName
      ..jobTitle = jobTitle ?? this.jobTitle
      ..startTime = startTime ?? this.startTime
      ..endTime = endTime ?? this.endTime
      ..needNum = needNum ?? this.needNum
      ..realNum = realNum ?? this.realNum
      ..createdAt = createdAt ?? this.createdAt
      ..approvedAt = approvedAt ?? this.approvedAt;
  }
}