import { AutoIncrement, BelongsTo, Column, DataType, DeletedAt, ForeignKey, HasMany, Model, PrimaryKey, Table } from 'sequelize-typescript';
import { UserBotAppDAO } from '../../../botApps/infrastructure/dataAccessObjects/botApp';
import { InstanceDAO } from '../../../instances/infrastructure/dataAccessObjects/instanceDAO';
import { SiteDAO } from '../../../regions/infrastructure/dataAccessObjects/siteDAO';
import { TimeTrackingKioskForCreation } from '../../business/models/timeTrackingKiosk';
import { TimeTrackingKioskLinkDAO } from './kioskLink';

@Table({ tableName: 'TimeTrackingKiosks' })
export class TimeTrackingKioskDAO extends Model<TimeTrackingKioskDAO, TimeTrackingKioskForCreation> {
    @PrimaryKey
    @AutoIncrement
    @Column
    id!: number;

    @Column
    name!: string;

    @Column
    description!: string;

    @Column
    @ForeignKey(() => InstanceDAO)
    instanceId!: number;

    @Column
    faceRecognitionEnabled!: boolean;

    @Column
    faceRecognitionBlocking!: boolean;

    @Column
    status!: string;

    @Column
    @ForeignKey(() => UserBotAppDAO)
    botAppId?: number;

    @Column
    pinAuthenticationEnabled!: boolean;

    @ForeignKey(() => SiteDAO)
    @Column({ allowNull: true, type: DataType.INTEGER })
    siteId?: number | null;

    @DeletedAt
    @Column({ type: DataType.DATE })
    deletedAt!: Date | null;

    @HasMany(() => TimeTrackingKioskLinkDAO)
    kioskLinks!: TimeTrackingKioskLinkDAO[];

    @BelongsTo(() => InstanceDAO)
    instance!: InstanceDAO;

    @Column
    createdBy?: number;
}
