import { Column, Entity, PrimaryColumn } from 'typeorm';
import { ApiProperty } from '@nestjs/swagger';
import {
  decodeBigNumberKey,
  encodeBigNumberKey,
} from '../utils/big-number-key';
import { Lang } from 'src/constants';

@Entity('projects', { schema: 'public' })
export class ProjectEntity {
  @PrimaryColumn({
    name: 'id',
    nullable: false,
    transformer: {
      from: (x) => encodeBigNumberKey(x),
      to: (x) => decodeBigNumberKey(x),
    },
  })
  id: string;

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

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

  @Column('integer', {
    name: 'timezone_shift',
  })
  @ApiProperty({})
  timezoneShift: number;

  @Column('uuid', {
    name: 'template_id',
  })
  templateId: string;

  @Column('varchar', {
    name: 'lang',
  })
  @ApiProperty({})
  lang: Lang;

  @Column('boolean', {
    name: 'is_public_gdd',
  })
  isPublicGdd: boolean;

  @Column('boolean', {
    name: 'is_public_tasks',
  })
  isPublicTasks: boolean;

  @Column('boolean', {
    name: 'is_public_about',
  })
  isPublicAbout: boolean;

  @Column('boolean', {
    name: 'is_public_pulse',
  })
  isPublicPulse: boolean;

  @Column('boolean', {
    name: 'display_on_main_page',
  })
  displayOnMainPage: boolean;

  @Column('boolean', {
    name: 'is_unsafe_content',
  })
  isUnsafeContent: boolean;

  @Column('timestamp with time zone', {
    name: 'unsafe_content_by_moderator',
  })
  @ApiProperty({})
  unsafeContentByModerator: Date;

  @Column('timestamp with time zone', {
    name: 'created_at',
    nullable: false,
    default: () => 'CURRENT_TIMESTAMP',
  })
  @ApiProperty({})
  createdAt: Date;

  @Column('timestamp with time zone', {
    name: 'updated_at',
    nullable: false,
    default: () => 'CURRENT_TIMESTAMP',
  })
  @ApiProperty({})
  updatedAt: Date;

  @Column('timestamp with time zone', {
    name: 'deleted_at',
  })
  @ApiProperty({})
  deletedAt: Date;
}
