import { BaseCoreDto } from 'src/core/modules/infrastructure/dto/base-core.dto';
import { UserPrivilegeConfigurationEntity } from '../../domain/entities/user-privilege-configuration.entity';
import { ApiProperty } from '@nestjs/swagger';
import { IsBoolean, IsString, ValidateIf } from 'class-validator';
import { Exclude } from 'class-transformer';

export class UserPrivilegeConfigurationDto
  extends BaseCoreDto
  implements UserPrivilegeConfigurationEntity
{
  @ApiProperty({ type: String, required: true, example: 'ADMIN_PAGE' })
  @IsString()
  module: string;

  @ApiProperty({ type: String, required: true, example: 'admin page' })
  @IsString()
  module_label: string;

  @ApiProperty({ type: String, required: true, example: 'DASHBOARD' })
  @IsString()
  menu: string;

  @ApiProperty({ type: String, required: true, example: 'dashboard' })
  @IsString()
  menu_label: string;

  @ApiProperty()
  sub_menu: string;

  @ApiProperty()
  sub_menu_label: string;

  @ApiProperty({
    type: Boolean,
    required: false,
  })
  @ValidateIf((body) => body.view)
  @IsBoolean()
  view: boolean;

  @ApiProperty({
    type: Boolean,
    required: false,
  })
  @ValidateIf((body) => body.create)
  @IsBoolean()
  create: boolean;

  @ApiProperty({
    type: Boolean,
    required: false,
  })
  @ValidateIf((body) => body.edit)
  @IsBoolean()
  edit: boolean;

  @ApiProperty({
    type: Boolean,
    required: false,
  })
  @ValidateIf((body) => body.delete)
  @IsBoolean()
  delete: boolean;

  @ApiProperty({
    type: Boolean,
    required: false,
  })
  @ValidateIf((body) => body.cancel)
  @IsBoolean()
  cancel: boolean;

  @ApiProperty({
    type: Boolean,
    required: false,
  })
  @ValidateIf((body) => body.confirm)
  @IsBoolean()
  confirm: boolean;

  @Exclude()
  index: number;
}
