import {
  Entity,
  PrimaryGeneratedColumn,
  Column,
  ManyToOne,
  ManyToMany,
  JoinTable,
} from "typeorm";
import { Client } from "./Client";
import { ClassDetail } from "./ClassDetail";
import { TypeStudent } from "./TypeStudent";
import { TitleStudent } from "./TitleStudent";

@Entity()
export class Student {
  @PrimaryGeneratedColumn()
  id!: number;

  @Column()
  firstName!: string;

  @Column()
  lastName!: string;

  @Column({ default: null, nullable: true })
  suffix!: string;

  @Column({ default: null, nullable: true })
  email!: string;

  @Column({ default: null, nullable: true })
  phoneNumber!: string;

  @Column({ default: null, nullable: true })
  stateBoardLicense!: string;

  @Column({ default: null, nullable: true })
  DEA!: string;

  @Column({ default: false })
  isMainProvider: boolean = false;

  @Column({ default: false })
  newsletter: boolean = false;

  @Column({ default: false })
  isPrivacySecurityOfficer: boolean = false;

  @Column({ default: false })
  isOSHACoordinator: boolean = false;

  @Column({ default: true })
  enable: boolean = true;

  @ManyToOne(() => Client, client => client.Students)
  Client!: Client;

  @ManyToMany(() => ClassDetail, classDetail => classDetail.Students, {
    onDelete: "CASCADE",
  })
  @JoinTable()
  ClassDetails!: ClassDetail[];

  @ManyToOne(() => TitleStudent, title => title.Students, { nullable: true })
  TitleStudent?: TitleStudent;

  @ManyToOne(() => TypeStudent, type => type.Students, { nullable: true })
  TypeStudent?: TypeStudent;
}
