import {
  Table,
  Model,
  Column,
  DataType,
  ForeignKey,
  BelongsTo,
  CreatedAt,
  UpdatedAt,
} from 'sequelize-typescript';
import { RentalHirerChangeRequestModel } from './rental-hirer-change-request.entity';
import { HirerChangeRequestHirerRoleEnum } from '../enum/rental-hirer-change-request-hirer-role';
import { IHirerChangeRequestSignatureAttr } from '../interfaces/hirer-change-request-signature-attr.interface';

@Table({
  tableName: 'hirerChangeRequest_Signature',
})
export class HirerChangeRequestSignatureModel
  extends Model
  implements IHirerChangeRequestSignatureAttr
{
  @Column({
    primaryKey: true,
    allowNull: false,
    type: DataType.STRING(30),
  })
  SignatureId: string;

  @ForeignKey(() => RentalHirerChangeRequestModel)
  @Column({
    allowNull: false,
    type: DataType.STRING(30),
  })
  RequestId: string;

  @Column({
    allowNull: true,
    type: DataType.STRING(30),
  })
  CustomerId: string;

  @Column({
    type: DataType.STRING(30),
    allowNull: true,
  })
  JointHirerId: string;

  @Column({
    allowNull: false,
    type: DataType.STRING(30),
  })
  HirerType: HirerChangeRequestHirerRoleEnum;

  @Column({
    type: DataType.DATE,
    allowNull: true,
  })
  SignedAt: Date;

  @Column({
    allowNull: false,
    type: DataType.STRING(20),
  })
  Method: string;

  @Column({
    allowNull: true,
    type: DataType.STRING(300),
  })
  Remarks: string;

  @CreatedAt
  CreatedAt: Date;

  @UpdatedAt
  UpdatedAt: Date;

  @Column({
    allowNull: false,
    type: DataType.STRING(30),
  })
  UpdatedById: string;

  @BelongsTo(() => RentalHirerChangeRequestModel)
  HirerChangeRequest: RentalHirerChangeRequestModel;
}
