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

@Entity({ name: 'user_activity_logs' })
export class ActivityLogs {
  @PrimaryGeneratedColumn({ type: 'bigint' })
  id: number;

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

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

  @Column({
    type: 'enum',
    enum: ['guest', 'seeker', 'recruiter', 'admin', 'franchise', 'associate'],
  })
  user_type: string;

  @Column({ type: 'varchar', length: 100 })
  action_type: string;

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

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

  @Column({ type: 'json', nullable: true })
  action_details: any;

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

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

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

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

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

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

  @Column({
    type: 'enum',
    enum: ['mobile', 'tablet', 'desktop', 'android', 'ios', 'web'],
    default: 'desktop',
  })
  device_type: string;

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

  @Column({ type: 'boolean', default: false })
  is_billable: boolean;

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

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