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

@Entity('page_seo_metadata')
@Index('uq_route_slug_locale', ['route_type', 'slug', 'locale'], {
  unique: true,
})
export class PageSeoMetadata {
  @PrimaryGeneratedColumn()
  id: number;

  @Column({
    type: 'enum',
    enum: ['jobs', 'category', 'company', 'static'],
  })
  route_type: 'jobs' | 'category' | 'company' | 'static';

  @Column({ type: 'varchar', length: 500 })
  slug: string;

  @Column({ type: 'varchar', length: 10, default: 'en' })
  locale: string;

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

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

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

  @Column({
    type: 'enum',
    enum: [
      'index, follow',
      'noindex, follow',
      'index, nofollow',
      'noindex, nofollow',
    ],
    default: 'index, follow',
    nullable: true,
  })
  robots:
    | 'index, follow'
    | 'noindex, follow'
    | 'index, nofollow'
    | 'noindex, nofollow';

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

  @Column({ type: 'longtext', nullable: true })
  content_description: string;

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

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

  @Column({
    type: 'enum',
    enum: ['draft', 'published'],
    default: 'draft',
    nullable: true,
  })
  status: 'draft' | 'published';

  @Column({ type: 'boolean', default: true, nullable: true })
  is_active: boolean;

  @Column({ type: 'int' })
  created_by: number;

  @Column({ type: 'int' })
  updated_by: number;

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

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