import {
  Entity,
  PrimaryGeneratedColumn,
  Column,
  CreateDateColumn,
  UpdateDateColumn,
} from 'typeorm';

@Entity('job_posts')
export class JobPosts {
  @PrimaryGeneratedColumn()
  id: number;

  @Column()
  company_id: number;

  @Column({ type: 'int', nullable: true })
  associate_id: number;

  @Column({ type: 'varchar', length: 255, nullable: true })
  title: string;

  @Column({ type: 'varchar', length: 255 })
  address: string;

  @Column({ type: 'text' })
  description: string;

  @Column({ type: 'text', nullable: true })
  requirements: string;

  @Column({ type: 'text', nullable: true })
  benefits: string;

  @Column({ type: 'tinyint', width: 1, default: () => '0', nullable: true })
  featured: boolean;

  @Column({ type: 'int', default: 0 })
  salary_min: number;

  @Column({ type: 'int', default: 0 })
  salary_max: number;

  @Column({ type: 'text', nullable: true })
  desirable: string;

  @Column({ type: 'int', nullable: true })
  job_level_id: number;

  @Column({
    type: 'enum',
    enum: ['open', 'closed', 'paused', 'pending', 'rejected'],
    default: 'pending',
    nullable: true,
  })
  status: 'open' | 'closed' | 'paused' | 'pending' | 'rejected';

  @Column({ type: 'varchar', length: 255, nullable: true })
  image_url: string;

  @Column({ type: 'int', width: 6, nullable: true })
  pincode: number;

  @Column({ type: 'int', nullable: true })
  area_id: number;

  @Column({ type: 'int', default: 0, nullable: true })
  vacancies: number;

  @CreateDateColumn({ type: 'timestamp' })
  created_at: Date;

  @UpdateDateColumn({ type: 'timestamp' })
  updated_at: Date;

  @Column({ type: 'datetime', nullable: true })
  expires_at: Date;

  @Column({ type: 'int', nullable: true })
  job_type_id: number;

  @Column({
    type: 'enum',
    enum: ['Onsite', 'Remote', 'Hybrid'],
    default: null,
    nullable: true,
  })
  work_mode: 'Onsite' | 'Remote' | 'Hybrid';

  @Column({ type: 'int', nullable: true })
  experience_id: number;

  @Column({ type: 'int', nullable: true })
  education_id: number;

  @Column({ type: 'int', nullable: true })
  role_levels_id: number;

  @Column({ type: 'int', nullable: true })
  country_id: number;

  @Column({ type: 'int', nullable: true })
  state_id: number;

  @Column({ type: 'int', nullable: true })
  city_id: number;

  @Column({ type: 'int', nullable: true })
  role_id: number;

  @Column({ type: 'int', nullable: true })
  industry_id: number;

  @Column({ type: 'boolean', default: false, nullable: false })
  urgent_hiring: boolean;
  @Column({
    type: 'enum',
    enum: ['day', 'night'],
    default: 'day',
    nullable: true,
  })
  shift: 'day' | 'night';

  @Column({
    type: 'enum',
    enum: ['no_english', 'basic_english', 'intermediate_english', 'good_english', 'fluent_english'],
    default: null,
    nullable: true,
  })
  english_level: 'no_english' | 'basic_english' | 'intermediate_english' | 'good_english' | 'fluent_english';

  @Column({
    type: 'enum',
    enum: ['both', 'male', 'female'],
    default: null,
    nullable: true,
  })
  gender: 'both' | 'male' | 'female';
  @Column({
    type: 'enum',
    enum: ['yes', 'no'],
    default: 'no',
    nullable: false,
  })
  walk_in_interview: 'yes' | 'no';

  @Column({ type: 'text', nullable: true })
  walkin_address: string;

  @Column({ type: 'date', nullable: true })
  walkin_start_date: Date;

  @Column({ type: 'date', nullable: true })
  walkin_end_date: Date;

  @Column({ type: 'time', nullable: true })
  walkin_start_time: string;

  @Column({ type: 'time', nullable: true })
  walkin_end_time: string;

  @Column({ type: 'text', nullable: true })
  walkin_instructions: string;

  /**
   * Communication Preferences
   */
  @Column({
    type: 'enum',
    enum: ['myself', 'other_recruiter', 'no'],
    default: null,
    nullable: true,
  })
  communication_preference: 'myself' | 'other_recruiter' | 'no';

  @Column({ type: 'varchar', length: 255, nullable: true })
  other_recruiter_name: string;

  @Column({ type: 'varchar', length: 20, nullable: true })
  other_recruiter_whatsapp: string;

  @Column({ type: 'varchar', length: 255, nullable: true })
  other_recruiter_email: string;

  /**
   * Notification Preferences
   */
  @Column({
    type: 'enum',
    enum: ['yes', 'daily_summary'],
    default: null,
    nullable: true,
  })
  notification_preference: 'yes' | 'daily_summary';

  /**
   * Admin Review Fields
   */
  @Column({ type: 'text', nullable: true })
  admin_remarks: string;

  @Column({ type: 'int', nullable: true })
  reviewed_by_admin_id: number;

  @Column({ type: 'datetime', nullable: true })
  reviewed_at: Date;
}
