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

@Entity({ name: 'notification_preferences' })
export class NotificationPreferenceOrmEntity {
  @PrimaryColumn({ type: 'text' })
  id!: string;

  @Index()
  @Column({ type: 'text' })
  driverId!: string;

  @Column({ type: 'jsonb' })
  channels!: {
    in_app: { enabled: boolean; settings?: Record<string, string> };
    email: { enabled: boolean; settings?: Record<string, string> };
    discord: { enabled: boolean; settings?: Record<string, string> };
    push: { enabled: boolean; settings?: Record<string, string> };
  };

  @Column({ type: 'jsonb', nullable: true })
  typePreferences!: Record<string, { enabled: boolean; channels?: string[] }> | null;

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

  @Column({ type: 'integer', nullable: true })
  digestFrequencyHours!: number | null;

  @Column({ type: 'integer', nullable: true })
  quietHoursStart!: number | null;

  @Column({ type: 'integer', nullable: true })
  quietHoursEnd!: number | null;

  @CreateDateColumn({ type: 'timestamptz' })
  createdAt!: Date;

  @UpdateDateColumn({ type: 'timestamptz' })
  updatedAt!: Date;
}