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

@Entity("stateUserComment")
export class StateUserComment extends EntityBase {
  @Column({
    nullable: true,
    comment: "เลือกรับทราบ",
    default: null,
  })
  isAccept: boolean;

  @Column({
    nullable: true,
    comment: "เลือกพิจารณา",
    default: null,
  })
  isApprove: boolean;

  @Column({
    nullable: true,
    comment: "แสดงความคิดเห็น",
    length: 255,
    default: null,
  })
  reason: string;

  @Column({
    comment: "เลือกรับทราบ",
    default: false,
  })
  isAcceptSetting: boolean;

  @Column({
    comment: "เลือกพิจารณา",
    default: false,
  })
  isApproveSetting: boolean;

  @Column({
    comment: "แสดงความคิดเห็น",
    default: false,
  })
  isReasonSetting: boolean;

  @Column({
    nullable: true,
    comment: "ลำดับ",
    default: null,
  })
  order: number;

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

  @ManyToOne(() => State, (state) => state.stateUserComments)
  @JoinColumn({ name: "stateId" })
  state: State;

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

  @ManyToOne(() => Profile, (profile) => profile.stateUserComments)
  @JoinColumn({ name: "profileId" })
  profile: Profile;
}
