import 'package:unit2/model/login_data/employee_info/office.dart';

class EmployeeInfo {
  EmployeeInfo({
    this.employeeId,
    this.empid,
    this.classid,
    this.uuid,
    this.office,
    this.profile,
  });

  String? employeeId;
  int? empid;
  String? classid;
  String? uuid;
  Office? office;
  Profile? profile;

  factory EmployeeInfo.fromJson(Map<String, dynamic> json) => EmployeeInfo(
        employeeId: json["employee_id"],
        empid: json["empid"],
        classid: json["classid"],
        uuid: json["uuid"],
        office: json["office"]==null?null:Office.fromJson(json["office"]),
        profile: json["profile"]==null?null:Profile.fromJson(json["profile"]),
      );

  Map<String, dynamic> toJson() => {
        "employee_id": employeeId,
        "empid": empid,
        "classid": classid,
        "uuid": uuid,
        "office": office!.toJson(),
        "profile": profile!.toJson(),
      };
}
class Profile {
  Profile({
    this.id,
    this.sex,
    this.gender,
    this.deceased,
    this.heightM,
    this.birthdate,
    this.esigPath,
    this.fullName,
    this.lastName,
    this.weightKg,
    this.bloodType,
    this.firstName,
    this.photoPath,
    this.maidenName,
    this.middleName,
    this.uuidQrcode,
    this.civilStatus,
    this.titlePrefix,
    this.titleSuffix,
    this.showTitleId,
    this.lastFullName,
    this.nameExtension,
  });

  int? id;
  String? sex;
  String? gender;
  bool? deceased;
  double? heightM;
  DateTime? birthdate;
  String? esigPath;
  String? fullName;
  String? lastName;
  int? weightKg;
  String? bloodType;
  String? firstName;
  String? photoPath;
  String? maidenName;
  String? middleName;
  String? uuidQrcode;
  String? civilStatus;
  String? titlePrefix;
  String? titleSuffix;
  bool? showTitleId;
  String? lastFullName;
  String? nameExtension;

  factory Profile.fromJson(Map<String, dynamic> json) => Profile(
        id: json["id"],
        sex: json["sex"],
        gender: json["gender"],
        deceased: json["deceased"],
        heightM: json["height_m"].toDouble(),
        birthdate: DateTime.parse(json["birthdate"]),
        esigPath: json["esig_path"],
        fullName: json["full_name"],
        lastName: json["last_name"],
        weightKg: json["weight_kg"],
        bloodType: json["blood_type"],
        firstName: json["first_name"],
        photoPath: json["photo_path"],
        maidenName: json["maiden_name"],
        middleName: json["middle_name"],
        uuidQrcode: json["uuid_qrcode"],
        civilStatus: json["civil_status"],
        titlePrefix: json["title_prefix"],
        titleSuffix: json["title_suffix"],
        showTitleId: json["show_title_id"],
        lastFullName: json["last_full_name"],
        nameExtension: json["name_extension"],
      );

  Map<String, dynamic> toJson() => {
        "id": id,
        "sex": sex,
        "gender": gender,
        "deceased": deceased,
        "height_m": heightM,
        "birthdate":
            "${birthdate!.year.toString().padLeft(4, '0')}-${birthdate!.month.toString().padLeft(2, '0')}-${birthdate!.day.toString().padLeft(2, '0')}",
        "esig_path": esigPath,
        "full_name": fullName,
        "last_name": lastName,
        "weight_kg": weightKg,
        "blood_type": bloodType,
        "first_name": firstName,
        "photo_path": photoPath,
        "maiden_name": maidenName,
        "middle_name": middleName,
        "uuid_qrcode": uuidQrcode,
        "civil_status": civilStatus,
        "title_prefix": titlePrefix,
        "title_suffix": titleSuffix,
        "show_title_id": showTitleId,
        "last_full_name": lastFullName,
        "name_extension": nameExtension,
      };
}
