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

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

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

extension UKAttendanceEntityExtension on UKAttendanceEntity {
  UKAttendanceEntity copyWith({
    int? total,
    List<UKAttendanceRows>? rows,
  }) {
    return UKAttendanceEntity()
      ..total = total ?? this.total
      ..rows = rows ?? this.rows;
  }
}

UKAttendanceRows $UKAttendanceRowsFromJson(Map<String, dynamic> json) {
  final UKAttendanceRows uKAttendanceRows = UKAttendanceRows();
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    uKAttendanceRows.id = id;
  }
  final String? memberId = jsonConvert.convert<String>(json['member_id']);
  if (memberId != null) {
    uKAttendanceRows.memberId = memberId;
  }
  final String? staffName = jsonConvert.convert<String>(json['staff_name']);
  if (staffName != null) {
    uKAttendanceRows.staffName = staffName;
  }
  final String? phone = jsonConvert.convert<String>(json['phone']);
  if (phone != null) {
    uKAttendanceRows.phone = phone;
  }
  final String? jobTitle = jsonConvert.convert<String>(json['job_title']);
  if (jobTitle != null) {
    uKAttendanceRows.jobTitle = jobTitle;
  }
  final String? departmentName = jsonConvert.convert<String>(json['department_name']);
  if (departmentName != null) {
    uKAttendanceRows.departmentName = departmentName;
  }
  final String? jobDate = jsonConvert.convert<String>(json['job_date']);
  if (jobDate != null) {
    uKAttendanceRows.jobDate = jobDate;
  }
  final String? startTime = jsonConvert.convert<String>(json['start_time']);
  if (startTime != null) {
    uKAttendanceRows.startTime = startTime;
  }
  final String? endTime = jsonConvert.convert<String>(json['end_time']);
  if (endTime != null) {
    uKAttendanceRows.endTime = endTime;
  }
  final String? appliedAt = jsonConvert.convert<String>(json['applied_at']);
  if (appliedAt != null) {
    uKAttendanceRows.appliedAt = appliedAt;
  }
  final String? adjustShow = jsonConvert.convert<String>(json['adjust_show']);
  if (adjustShow != null) {
    uKAttendanceRows.adjustShow = adjustShow;
  }
  final String? totalHours = jsonConvert.convert<String>(json['total_hours']);
  if (totalHours != null) {
    uKAttendanceRows.totalHours = totalHours;
  }
  final int? status = jsonConvert.convert<int>(json['status']);
  if (status != null) {
    uKAttendanceRows.status = status;
  }
  final String? statusShow = jsonConvert.convert<String>(json['status_show']);
  if (statusShow != null) {
    uKAttendanceRows.statusShow = statusShow;
  }
  final UKAttendanceInOut? securityIn = jsonConvert.convert<UKAttendanceInOut>(json['security_in']);
  if (securityIn != null) {
    uKAttendanceRows.securityIn = securityIn;
  }
  final UKAttendanceInOut? securityOut = jsonConvert.convert<UKAttendanceInOut>(json['security_out']);
  if (securityOut != null) {
    uKAttendanceRows.securityOut = securityOut;
  }
  final UKAttendanceInOut? workIn = jsonConvert.convert<UKAttendanceInOut>(json['work_in']);
  if (workIn != null) {
    uKAttendanceRows.workIn = workIn;
  }
  final UKAttendanceInOut? workOut = jsonConvert.convert<UKAttendanceInOut>(json['work_out']);
  if (workOut != null) {
    uKAttendanceRows.workOut = workOut;
  }
  final int? sIn = jsonConvert.convert<int>(json['s_in']);
  if (sIn != null) {
    uKAttendanceRows.sIn = sIn;
  }
  final int? sOut = jsonConvert.convert<int>(json['s_out']);
  if (sOut != null) {
    uKAttendanceRows.sOut = sOut;
  }
  final int? wIn = jsonConvert.convert<int>(json['w_in']);
  if (wIn != null) {
    uKAttendanceRows.wIn = wIn;
  }
  final int? wOut = jsonConvert.convert<int>(json['w_out']);
  if (wOut != null) {
    uKAttendanceRows.wOut = wOut;
  }
  final String? reviseHours = jsonConvert.convert<String>(json['revise_hours']);
  if (reviseHours != null) {
    uKAttendanceRows.reviseHours = reviseHours;
  }
  final String? gratuity = jsonConvert.convert<String>(json['gratuity']);
  if (gratuity != null) {
    uKAttendanceRows.gratuity = gratuity;
  }
  return uKAttendanceRows;
}

Map<String, dynamic> $UKAttendanceRowsToJson(UKAttendanceRows entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['member_id'] = entity.memberId;
  data['staff_name'] = entity.staffName;
  data['phone'] = entity.phone;
  data['job_title'] = entity.jobTitle;
  data['department_name'] = entity.departmentName;
  data['job_date'] = entity.jobDate;
  data['start_time'] = entity.startTime;
  data['end_time'] = entity.endTime;
  data['applied_at'] = entity.appliedAt;
  data['adjust_show'] = entity.adjustShow;
  data['total_hours'] = entity.totalHours;
  data['status'] = entity.status;
  data['status_show'] = entity.statusShow;
  data['security_in'] = entity.securityIn?.toJson();
  data['security_out'] = entity.securityOut?.toJson();
  data['work_in'] = entity.workIn?.toJson();
  data['work_out'] = entity.workOut?.toJson();
  data['s_in'] = entity.sIn;
  data['s_out'] = entity.sOut;
  data['w_in'] = entity.wIn;
  data['w_out'] = entity.wOut;
  data['revise_hours'] = entity.reviseHours;
  data['gratuity'] = entity.gratuity;
  return data;
}

extension UKAttendanceRowsExtension on UKAttendanceRows {
  UKAttendanceRows copyWith({
    String? id,
    String? memberId,
    String? staffName,
    String? phone,
    String? jobTitle,
    String? departmentName,
    String? jobDate,
    String? startTime,
    String? endTime,
    String? appliedAt,
    String? adjustShow,
    String? totalHours,
    int? status,
    String? statusShow,
    UKAttendanceInOut? securityIn,
    UKAttendanceInOut? securityOut,
    UKAttendanceInOut? workIn,
    UKAttendanceInOut? workOut,
    int? sIn,
    int? sOut,
    int? wIn,
    int? wOut,
    String? reviseHours,
    String? gratuity,
  }) {
    return UKAttendanceRows()
      ..id = id ?? this.id
      ..memberId = memberId ?? this.memberId
      ..staffName = staffName ?? this.staffName
      ..phone = phone ?? this.phone
      ..jobTitle = jobTitle ?? this.jobTitle
      ..departmentName = departmentName ?? this.departmentName
      ..jobDate = jobDate ?? this.jobDate
      ..startTime = startTime ?? this.startTime
      ..endTime = endTime ?? this.endTime
      ..appliedAt = appliedAt ?? this.appliedAt
      ..adjustShow = adjustShow ?? this.adjustShow
      ..totalHours = totalHours ?? this.totalHours
      ..status = status ?? this.status
      ..statusShow = statusShow ?? this.statusShow
      ..securityIn = securityIn ?? this.securityIn
      ..securityOut = securityOut ?? this.securityOut
      ..workIn = workIn ?? this.workIn
      ..workOut = workOut ?? this.workOut
      ..sIn = sIn ?? this.sIn
      ..sOut = sOut ?? this.sOut
      ..wIn = wIn ?? this.wIn
      ..wOut = wOut ?? this.wOut
      ..reviseHours = reviseHours ?? this.reviseHours
      ..gratuity = gratuity ?? this.gratuity;
  }
}

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

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

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