import { UserConfirmCode } from 'src/auth/user/entities/user-confirm-code.entity';
import { UserResetCode } from 'src/auth/user/entities/user-reset-code.entity';
import { Category } from 'src/category/entities/category.entity';
import { Entity, Column, ManyToMany, JoinTable, PrimaryColumn, OneToMany } from 'typeorm';

@Entity()
export class User {
  @PrimaryColumn()
  email: string;

  @JoinTable()
  @ManyToMany(() => Category)
  preferedCategories: Category[];

  @Column()
  name: string;

  @Column()
  lastName: string;

  @Column()
  birthDate: Date;

  @Column()
  password: string;

  @Column({ nullable: true })
  imageUrl: string;

  @Column({ default: false })
  isEmailConfirmed: boolean;

  @OneToMany(() => UserResetCode, (resetCode) => resetCode.user)
  resetCodes: UserResetCode[];

  @OneToMany(() => UserConfirmCode, (confirmCode) => confirmCode.user)
  confirmCodes: UserConfirmCode[];
}
