import { Column, Entity, ManyToOne, JoinColumn } from "typeorm";
import { EntityBase } from "./base/Base";
import { Profile } from "./Profile";
import { ProfileEmployee } from "./ProfileEmployee";

@Entity("profileFamilyHistory")
export class ProfileFamilyHistory extends EntityBase {
  @Column({
    nullable: true,
    default: null,
    type: "boolean",
  })
  couple: boolean;

  @Column({
    nullable: true,
    default: null,
    comment: "คำนำหน้าคู่สมรส",
  })
  couplePrefix: string;

  @Column({
    nullable: true,
    default: null,
    comment: "ชื่อคู่สมรส",
  })
  coupleFirstName: string;

  @Column({
    nullable: true,
    default: null,
    comment: "นามสกุลคู่สมรส",
  })
  coupleLastName: string;

  @Column({
    nullable: true,
    default: null,
    comment: "นามสกุลคู่สมรส(เดิม)",
  })
  coupleLastNameOld: string;

  @Column({
    nullable: true,
    default: null,
    comment: "อาชีพคู่สมรส",
  })
  coupleCareer: string;

  @Column({
    nullable: true,
    default: null,
    length: 13,
    comment: "เลขที่บัตรประชาชนคู่สมรส",
  })
  coupleCitizenId: string;

  @Column({
    nullable: true,
    default: null,
    type: "boolean",
    comment: "มีชีวิตคู่สมรส",
  })
  coupleLive: boolean;

  @Column({
    nullable: true,
    default: null,
    comment: "คำนำหน้าบิดา",
  })
  fatherPrefix: string;

  @Column({
    nullable: true,
    default: null,
    comment: "ชื่อบิดา",
  })
  fatherFirstName: string;

  @Column({
    nullable: true,
    default: null,
    comment: "นามสกุลบิดา",
  })
  fatherLastName: string;

  @Column({
    nullable: true,
    default: null,
    comment: "อาชีพบิดา",
  })
  fatherCareer: string;

  @Column({
    nullable: true,
    default: null,
    comment: "เลขที่บัตรประชาชนบิดา",
  })
  fatherCitizenId: string;

  @Column({
    nullable: true,
    default: null,
    comment: "มีชีวิตบิดา",
  })
  fatherLive: boolean;

  @Column({
    nullable: true,
    default: null,
    comment: "คำนำหน้ามารดา",
  })
  motherPrefix: string;

  @Column({
    nullable: true,
    default: null,
    comment: "ชื่อมารดา",
  })
  motherFirstName: string;

  @Column({
    nullable: true,
    default: null,
    comment: "นามสกุลมารดา",
  })
  motherLastName: string;

  @Column({
    nullable: true,
    default: null,
    comment: "อาชีพบิดา",
  })
  motherCareer: string;

  @Column({
    nullable: true,
    default: null,
    comment: "เลขที่บัตรประชาชนมารดา",
  })
  motherCitizenId: string;

  @Column({
    nullable: true,
    default: null,
    comment: "มีชีวิตมารดา",
  })
  motherLive: boolean;

  @Column({
    nullable: true,
    length: 40,
    type: "uuid",
    comment: "คีย์นอก(FK) ของตาราง Profile",
    default: null,
  })
  profileId: string;

  @Column({
    nullable: true,
    length: 40,
    comment: "คีย์นอก(FK)ของตาราง ProfileEmployee",
    default: null,
  })
  profileEmployeeId: string;

  @ManyToOne(() => Profile, (v) => v.profileFamily)
  profile: Profile;

  @ManyToOne(() => ProfileEmployee, (ProfileEmployee) => ProfileEmployee.profileFamilys)
  @JoinColumn({ name: "profileEmployeeId" })
  profileEmployee: ProfileEmployee;
}

export type CreateChildren = {
  childrenCareer: string;
  childrenFirstName: string;
  childrenLastName: string;
  childrenPrefix: string;
  childrenLive: boolean;
  childrenCitizenId: string;
};

export type UpdateChildren = {
  id: string;
  childrenCareer?: string | null;
  childrenFirstName?: string | null;
  childrenLastName?: string | null;
  childrenPrefix?: string | null;
  childrenLive?: boolean | null;
  childrenCitizenId?: string | null;
};

export type CreateProfileFamily = {
  couple: boolean | null;
  couplePrefix: string | null;
  coupleFirstName: string | null;
  coupleLastName: string | null;
  coupleLastNameOld: string | null;
  coupleCareer: string | null;
  coupleCitizenId: string | null;
  coupleLive: boolean | null;
  fatherPrefix: string | null;
  fatherFirstName: string | null;
  fatherLastName: string | null;
  fatherCareer: string | null;
  fatherCitizenId: string | null;
  fatherLive: boolean | null;
  motherPrefix: string | null;
  motherFirstName: string | null;
  motherLastName: string | null;
  motherCareer: string | null;
  motherCitizenId: string | null;
  motherLive: boolean | null;
  profileId: string;
  children: CreateChildren[];
};
export type CreateProfileFamilyEmployee = {
  couple: boolean | null;
  couplePrefix: string | null;
  coupleFirstName: string | null;
  coupleLastName: string | null;
  coupleLastNameOld: string | null;
  coupleCareer: string | null;
  coupleCitizenId: string | null;
  coupleLive: boolean | null;
  fatherPrefix: string | null;
  fatherFirstName: string | null;
  fatherLastName: string | null;
  fatherCareer: string | null;
  fatherCitizenId: string | null;
  fatherLive: boolean | null;
  motherPrefix: string | null;
  motherFirstName: string | null;
  motherLastName: string | null;
  motherCareer: string | null;
  motherCitizenId: string | null;
  motherLive: boolean | null;
  profileEmployeeId: string | null;
  children: CreateChildren[];
};

export type UpdateProfileFamily = {
  couple?: boolean | null;
  couplePrefix?: string | null;
  coupleFirstName?: string | null;
  coupleLastName?: string | null;
  coupleLastNameOld?: string | null;
  coupleCareer?: string | null;
  coupleCitizenId?: string | null;
  coupleLive?: boolean | null;
  fatherPrefix?: string | null;
  fatherFirstName?: string | null;
  fatherLastName?: string | null;
  fatherCareer?: string | null;
  fatherCitizenId?: string | null;
  fatherLive?: boolean | null;
  motherPrefix?: string | null;
  motherFirstName?: string | null;
  motherLastName?: string | null;
  motherCareer?: string | null;
  motherCitizenId?: string | null;
  motherLive?: boolean | null;
  children: UpdateChildren[];
};
