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

JobTitleEditIndexEntity $JobTitleEditIndexEntityFromJson(Map<String, dynamic> json) {
  final JobTitleEditIndexEntity jobTitleEditIndexEntity = JobTitleEditIndexEntity();
  final int? titleId = jsonConvert.convert<int>(json['title_id']);
  if (titleId != null) {
    jobTitleEditIndexEntity.titleId = titleId;
  }
  final String? jobTitle = jsonConvert.convert<String>(json['job_title']);
  if (jobTitle != null) {
    jobTitleEditIndexEntity.jobTitle = jobTitle;
  }
  final int? sort = jsonConvert.convert<int>(json['sort']);
  if (sort != null) {
    jobTitleEditIndexEntity.sort = sort;
  }
  final List<JobTitleEditIndexTemplate?>? template = (json['template'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<JobTitleEditIndexTemplate>(e)).toList();
  if (template != null) {
    jobTitleEditIndexEntity.template = template;
  }
  return jobTitleEditIndexEntity;
}

Map<String, dynamic> $JobTitleEditIndexEntityToJson(JobTitleEditIndexEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['title_id'] = entity.titleId;
  data['job_title'] = entity.jobTitle;
  data['sort'] = entity.sort;
  data['template'] = entity.template.map((v) => v?.toJson()).toList();
  return data;
}

extension JobTitleEditIndexEntityExtension on JobTitleEditIndexEntity {
  JobTitleEditIndexEntity copyWith({
    int? titleId,
    String? jobTitle,
    int? sort,
    List<JobTitleEditIndexTemplate?>? template,
  }) {
    return JobTitleEditIndexEntity()
      ..titleId = titleId ?? this.titleId
      ..jobTitle = jobTitle ?? this.jobTitle
      ..sort = sort ?? this.sort
      ..template = template ?? this.template;
  }
}

JobTitleEditIndexTemplate $JobTitleEditIndexTemplateFromJson(Map<String, dynamic> json) {
  final JobTitleEditIndexTemplate jobTitleEditIndexTemplate = JobTitleEditIndexTemplate();
  final int? value = jsonConvert.convert<int>(json['value']);
  if (value != null) {
    jobTitleEditIndexTemplate.value = value;
  }
  final String? txt = jsonConvert.convert<String>(json['txt']);
  if (txt != null) {
    jobTitleEditIndexTemplate.txt = txt;
  }
  final String? selected = jsonConvert.convert<String>(json['selected']);
  if (selected != null) {
    jobTitleEditIndexTemplate.selected = selected;
  }
  return jobTitleEditIndexTemplate;
}

Map<String, dynamic> $JobTitleEditIndexTemplateToJson(JobTitleEditIndexTemplate entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['value'] = entity.value;
  data['txt'] = entity.txt;
  data['selected'] = entity.selected;
  return data;
}

extension JobTitleEditIndexTemplateExtension on JobTitleEditIndexTemplate {
  JobTitleEditIndexTemplate copyWith({
    int? value,
    String? txt,
    String? selected,
  }) {
    return JobTitleEditIndexTemplate()
      ..value = value ?? this.value
      ..txt = txt ?? this.txt
      ..selected = selected ?? this.selected;
  }
}