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

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

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

extension AttendanceEntityExtension on AttendanceEntity {
  AttendanceEntity copyWith({
    int? total,
    List<AttendanceList>? rows,
  }) {
    return AttendanceEntity()
      ..total = total ?? this.total
      ..rows = rows ?? this.rows;
  }
}

AttendanceList $AttendanceListFromJson(Map<String, dynamic> json) {
  final AttendanceList attendanceList = AttendanceList();
  final int? appliedId = jsonConvert.convert<int>(json['applied_id']);
  if (appliedId != null) {
    attendanceList.appliedId = appliedId;
  }
  final int? staffId = jsonConvert.convert<int>(json['staff_id']);
  if (staffId != null) {
    attendanceList.staffId = staffId;
  }
  final String? staffName = jsonConvert.convert<String>(json['staff_name']);
  if (staffName != null) {
    attendanceList.staffName = staffName;
  }
  final String? jobDate = jsonConvert.convert<String>(json['job_date']);
  if (jobDate != null) {
    attendanceList.jobDate = jobDate;
  }
  final String? startTime = jsonConvert.convert<String>(json['start_time']);
  if (startTime != null) {
    attendanceList.startTime = startTime;
  }
  final String? endTime = jsonConvert.convert<String>(json['end_time']);
  if (endTime != null) {
    attendanceList.endTime = endTime;
  }
  final String? securityIn = jsonConvert.convert<String>(json['security_in']);
  if (securityIn != null) {
    attendanceList.securityIn = securityIn;
  }
  final String? securityOut = jsonConvert.convert<String>(json['security_out']);
  if (securityOut != null) {
    attendanceList.securityOut = securityOut;
  }
  final int? checkInId = jsonConvert.convert<int>(json['check_in_id']);
  if (checkInId != null) {
    attendanceList.checkInId = checkInId;
  }
  final String? checkInTime = jsonConvert.convert<String>(json['check_in_time']);
  if (checkInTime != null) {
    attendanceList.checkInTime = checkInTime;
  }
  final String? checkInImg = jsonConvert.convert<String>(json['check_in_img']);
  if (checkInImg != null) {
    attendanceList.checkInImg = checkInImg;
  }
  final int? checkOutId = jsonConvert.convert<int>(json['check_out_id']);
  if (checkOutId != null) {
    attendanceList.checkOutId = checkOutId;
  }
  final String? checkOutTime = jsonConvert.convert<String>(json['check_out_time']);
  if (checkOutTime != null) {
    attendanceList.checkOutTime = checkOutTime;
  }
  final String? checkOutImg = jsonConvert.convert<String>(json['check_out_img']);
  if (checkOutImg != null) {
    attendanceList.checkOutImg = checkOutImg;
  }
  final int? status = jsonConvert.convert<int>(json['status']);
  if (status != null) {
    attendanceList.status = status;
  }
  final String? statusShow = jsonConvert.convert<String>(json['status_show']);
  if (statusShow != null) {
    attendanceList.statusShow = statusShow;
  }
  final bool? isExpended = jsonConvert.convert<bool>(json['isExpended']);
  if (isExpended != null) {
    attendanceList.isExpended = isExpended;
  }
  return attendanceList;
}

Map<String, dynamic> $AttendanceListToJson(AttendanceList entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['applied_id'] = entity.appliedId;
  data['staff_id'] = entity.staffId;
  data['staff_name'] = entity.staffName;
  data['job_date'] = entity.jobDate;
  data['start_time'] = entity.startTime;
  data['end_time'] = entity.endTime;
  data['security_in'] = entity.securityIn;
  data['security_out'] = entity.securityOut;
  data['check_in_id'] = entity.checkInId;
  data['check_in_time'] = entity.checkInTime;
  data['check_in_img'] = entity.checkInImg;
  data['check_out_id'] = entity.checkOutId;
  data['check_out_time'] = entity.checkOutTime;
  data['check_out_img'] = entity.checkOutImg;
  data['status'] = entity.status;
  data['status_show'] = entity.statusShow;
  data['isExpended'] = entity.isExpended;
  return data;
}

extension AttendanceListExtension on AttendanceList {
  AttendanceList copyWith({
    int? appliedId,
    int? staffId,
    String? staffName,
    String? jobDate,
    String? startTime,
    String? endTime,
    String? securityIn,
    String? securityOut,
    int? checkInId,
    String? checkInTime,
    String? checkInImg,
    int? checkOutId,
    String? checkOutTime,
    String? checkOutImg,
    int? status,
    String? statusShow,
    bool? isExpended,
  }) {
    return AttendanceList()
      ..appliedId = appliedId ?? this.appliedId
      ..staffId = staffId ?? this.staffId
      ..staffName = staffName ?? this.staffName
      ..jobDate = jobDate ?? this.jobDate
      ..startTime = startTime ?? this.startTime
      ..endTime = endTime ?? this.endTime
      ..securityIn = securityIn ?? this.securityIn
      ..securityOut = securityOut ?? this.securityOut
      ..checkInId = checkInId ?? this.checkInId
      ..checkInTime = checkInTime ?? this.checkInTime
      ..checkInImg = checkInImg ?? this.checkInImg
      ..checkOutId = checkOutId ?? this.checkOutId
      ..checkOutTime = checkOutTime ?? this.checkOutTime
      ..checkOutImg = checkOutImg ?? this.checkOutImg
      ..status = status ?? this.status
      ..statusShow = statusShow ?? this.statusShow
      ..isExpended = isExpended ?? this.isExpended;
  }
}