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

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

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

extension JobListEntityExtension on JobListEntity {
  JobListEntity copyWith({
    int? total,
    List<JobListRows>? rows,
  }) {
    return JobListEntity()
      ..total = total ?? this.total
      ..rows = rows ?? this.rows;
  }
}

JobListRows $JobListRowsFromJson(Map<String, dynamic> json) {
  final JobListRows jobListRows = JobListRows();
  final int? jobId = jsonConvert.convert<int>(json['job_id']);
  if (jobId != null) {
    jobListRows.jobId = jobId;
  }
  final String? jobTitle = jsonConvert.convert<String>(json['job_title']);
  if (jobTitle != null) {
    jobListRows.jobTitle = jobTitle;
  }
  final String? jobTime = jsonConvert.convert<String>(json['job_time']);
  if (jobTime != null) {
    jobListRows.jobTime = jobTime;
  }
  final String? departmentName = jsonConvert.convert<String>(json['department_name']);
  if (departmentName != null) {
    jobListRows.departmentName = departmentName;
  }
  final String? staffShow = jsonConvert.convert<String>(json['staff_show']);
  if (staffShow != null) {
    jobListRows.staffShow = staffShow;
  }
  final String? statusShow = jsonConvert.convert<String>(json['status_show']);
  if (statusShow != null) {
    jobListRows.statusShow = statusShow;
  }
  final String? createdAt = jsonConvert.convert<String>(json['created_at']);
  if (createdAt != null) {
    jobListRows.createdAt = createdAt;
  }
  final List<String>? actionList = (json['action_list'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<String>(e) as String).toList();
  if (actionList != null) {
    jobListRows.actionList = actionList;
  }
  return jobListRows;
}

Map<String, dynamic> $JobListRowsToJson(JobListRows entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['job_id'] = entity.jobId;
  data['job_title'] = entity.jobTitle;
  data['job_time'] = entity.jobTime;
  data['department_name'] = entity.departmentName;
  data['staff_show'] = entity.staffShow;
  data['status_show'] = entity.statusShow;
  data['created_at'] = entity.createdAt;
  data['action_list'] = entity.actionList;
  return data;
}

extension JobListRowsExtension on JobListRows {
  JobListRows copyWith({
    int? jobId,
    String? jobTitle,
    String? jobTime,
    String? departmentName,
    String? staffShow,
    String? statusShow,
    String? createdAt,
    List<String>? actionList,
  }) {
    return JobListRows()
      ..jobId = jobId ?? this.jobId
      ..jobTitle = jobTitle ?? this.jobTitle
      ..jobTime = jobTime ?? this.jobTime
      ..departmentName = departmentName ?? this.departmentName
      ..staffShow = staffShow ?? this.staffShow
      ..statusShow = statusShow ?? this.statusShow
      ..createdAt = createdAt ?? this.createdAt
      ..actionList = actionList ?? this.actionList;
  }
}