import { Entity, Column, PrimaryGeneratedColumn, OneToMany } from 'typeorm';
import { Course } from '../course/course.entity';
import { Exclude } from 'class-transformer';

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

  @Column({ unique: true })
  email: string;

  @Exclude()
  @Column()
  password: string;

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

  @Column({ nullable: true })
  gender: string; // 'male' | 'female' | 'other'

  @Column({ default: 'learner' })
  role: string; // learner, creator, admin

  @Exclude()
  @Column({ type: 'text', nullable: true })
  resetToken: string | null;

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

  @Column({ type: 'varchar', nullable: true })
  verificationOtp: string | null;

  @Column({ type: 'timestamp', nullable: true })
  otpExpires: Date | null;

  @OneToMany(() => Course, (course) => course.trainer)
  courses: Course[];
}
