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

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

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

extension UKSecurityAttendanceEntityExtension on UKSecurityAttendanceEntity {
  UKSecurityAttendanceEntity copyWith({
    int? total,
    List<UKSecurityAttendanceRows>? rows,
  }) {
    return UKSecurityAttendanceEntity()
      ..total = total ?? this.total
      ..rows = rows ?? this.rows;
  }
}

UKSecurityAttendanceRows $UKSecurityAttendanceRowsFromJson(Map<String, dynamic> json) {
  final UKSecurityAttendanceRows uKSecurityAttendanceRows = UKSecurityAttendanceRows();
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    uKSecurityAttendanceRows.id = id;
  }
  final String? staffName = jsonConvert.convert<String>(json['staff_name']);
  if (staffName != null) {
    uKSecurityAttendanceRows.staffName = staffName;
  }
  final String? phone = jsonConvert.convert<String>(json['phone']);
  if (phone != null) {
    uKSecurityAttendanceRows.phone = phone;
  }
  final String? jobTitle = jsonConvert.convert<String>(json['job_title']);
  if (jobTitle != null) {
    uKSecurityAttendanceRows.jobTitle = jobTitle;
  }
  final String? departmentName = jsonConvert.convert<String>(json['department_name']);
  if (departmentName != null) {
    uKSecurityAttendanceRows.departmentName = departmentName;
  }
  final String? jobTime = jsonConvert.convert<String>(json['job_time']);
  if (jobTime != null) {
    uKSecurityAttendanceRows.jobTime = jobTime;
  }
  final String? appliedAt = jsonConvert.convert<String>(json['applied_at']);
  if (appliedAt != null) {
    uKSecurityAttendanceRows.appliedAt = appliedAt;
  }
  final int? status = jsonConvert.convert<int>(json['status']);
  if (status != null) {
    uKSecurityAttendanceRows.status = status;
  }
  final String? statusShow = jsonConvert.convert<String>(json['status_show']);
  if (statusShow != null) {
    uKSecurityAttendanceRows.statusShow = statusShow;
  }
  final UKSecurityInOut? securityIn = jsonConvert.convert<UKSecurityInOut>(json['security_in']);
  if (securityIn != null) {
    uKSecurityAttendanceRows.securityIn = securityIn;
  }
  final UKSecurityInOut? securityOut = jsonConvert.convert<UKSecurityInOut>(json['security_out']);
  if (securityOut != null) {
    uKSecurityAttendanceRows.securityOut = securityOut;
  }
  final int? sIn = jsonConvert.convert<int>(json['s_in']);
  if (sIn != null) {
    uKSecurityAttendanceRows.sIn = sIn;
  }
  final int? sOut = jsonConvert.convert<int>(json['s_out']);
  if (sOut != null) {
    uKSecurityAttendanceRows.sOut = sOut;
  }
  return uKSecurityAttendanceRows;
}

Map<String, dynamic> $UKSecurityAttendanceRowsToJson(UKSecurityAttendanceRows entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['staff_name'] = entity.staffName;
  data['phone'] = entity.phone;
  data['job_title'] = entity.jobTitle;
  data['department_name'] = entity.departmentName;
  data['job_time'] = entity.jobTime;
  data['applied_at'] = entity.appliedAt;
  data['status'] = entity.status;
  data['status_show'] = entity.statusShow;
  data['security_in'] = entity.securityIn?.toJson();
  data['security_out'] = entity.securityOut?.toJson();
  data['s_in'] = entity.sIn;
  data['s_out'] = entity.sOut;
  return data;
}

extension UKSecurityAttendanceRowsExtension on UKSecurityAttendanceRows {
  UKSecurityAttendanceRows copyWith({
    String? id,
    String? staffName,
    String? phone,
    String? jobTitle,
    String? departmentName,
    String? jobTime,
    String? appliedAt,
    int? status,
    String? statusShow,
    UKSecurityInOut? securityIn,
    UKSecurityInOut? securityOut,
    int? sIn,
    int? sOut,
  }) {
    return UKSecurityAttendanceRows()
      ..id = id ?? this.id
      ..staffName = staffName ?? this.staffName
      ..phone = phone ?? this.phone
      ..jobTitle = jobTitle ?? this.jobTitle
      ..departmentName = departmentName ?? this.departmentName
      ..jobTime = jobTime ?? this.jobTime
      ..appliedAt = appliedAt ?? this.appliedAt
      ..status = status ?? this.status
      ..statusShow = statusShow ?? this.statusShow
      ..securityIn = securityIn ?? this.securityIn
      ..securityOut = securityOut ?? this.securityOut
      ..sIn = sIn ?? this.sIn
      ..sOut = sOut ?? this.sOut;
  }
}

UKSecurityInOut $UKSecurityInOutFromJson(Map<String, dynamic> json) {
  final UKSecurityInOut uKSecurityInOut = UKSecurityInOut();
  final String? time = jsonConvert.convert<String>(json['time']);
  if (time != null) {
    uKSecurityInOut.time = time;
  }
  final String? image = jsonConvert.convert<String>(json['image']);
  if (image != null) {
    uKSecurityInOut.image = image;
  }
  final int? changed = jsonConvert.convert<int>(json['changed']);
  if (changed != null) {
    uKSecurityInOut.changed = changed;
  }
  return uKSecurityInOut;
}

Map<String, dynamic> $UKSecurityInOutToJson(UKSecurityInOut entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['time'] = entity.time;
  data['image'] = entity.image;
  data['changed'] = entity.changed;
  return data;
}

extension UKSecurityInOutExtension on UKSecurityInOut {
  UKSecurityInOut copyWith({
    String? time,
    String? image,
    int? changed,
  }) {
    return UKSecurityInOut()
      ..time = time ?? this.time
      ..image = image ?? this.image
      ..changed = changed ?? this.changed;
  }
}