import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
import { ItemQueueEntity } from '../../domain/entities/item-queue.entity';
import { Column, Entity, OneToMany } from 'typeorm';
import { BaseStatusModel } from 'src/core/modules/data/model/base-status.model';
import { ItemType, UsageType } from '../../constants';
import { ItemModel } from 'src/modules/item-related/item/data/models/item.model';

@Entity(TABLE_NAME.ITEM_QUEUE)
export class ItemQueueModel
  extends BaseStatusModel<ItemQueueEntity>
  implements ItemQueueEntity
{
  @Column('int', { default: 100 })
  max_peak_level: number;

  @Column('int', { default: 5 })
  call_preparation: number;

  @Column('varchar', { name: 'name' })
  name: string;

  @Column('varchar', { name: 'information', nullable: true })
  information: string;

  @Column('enum', {
    name: 'item_type',
    enum: ItemType,
    default: ItemType.TIKET_MASUK,
  })
  item_type: ItemType;

  @Column('enum', {
    name: 'usage_type',
    enum: UsageType,
    default: UsageType.ONE_TIME,
  })
  usage_type: UsageType;

  @OneToMany(() => ItemModel, (model) => model.item_queue, {
    onUpdate: 'CASCADE',
  })
  items: ItemModel[];

  @Column('boolean', { default: true })
  use_notification: boolean;

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