import { ApiProperty } from '@nestjs/swagger';
import { IsInt, IsNumber, IsOptional, IsString, IsUUID } from 'class-validator';
import {
  ApiGetListParams,
  ApiFilterParamsDecorator,
} from 'src/common/types/api-filter-params';
import {
  FilterProp,
  FilterPropTypes,
} from 'src/common/types/filter-prop-decorators';

export class WorkspaceDTO {
  @ApiProperty({ required: true })
  id: string;

  @ApiProperty({})
  title: string;

  @ApiProperty({})
  parentId: string;

  @ApiProperty({})
  createdAt: Date;

  @ApiProperty({})
  updatedAt: Date;

  @ApiProperty({})
  scope: string;

  @IsInt()
  @ApiProperty()
  rights: number;

  @ApiProperty({})
  index: number | null;
}

export class ChangeWorkspaceDTO {
  @IsOptional()
  @ApiProperty({})
  parentId?: string | null;

  @IsString()
  @IsOptional()
  @ApiProperty({})
  title?: string;

  @IsNumber()
  @IsOptional()
  @ApiProperty({})
  index?: number | null;
}

export class CreateWorkspaceDTO extends ChangeWorkspaceDTO {
  @ApiProperty({})
  @IsOptional()
  scope?: string;
}

export class WorkspaceQueryDTOWhere {
  @FilterProp(FilterPropTypes.STRING)
  workspaceId?: string;

  @FilterProp([FilterPropTypes.STRING])
  ids?: string[];

  @FilterProp(FilterPropTypes.STRING)
  scope?: string;
}

@ApiFilterParamsDecorator(WorkspaceQueryDTOWhere)
export class WorkspaceQueryDTO extends ApiGetListParams<WorkspaceQueryDTOWhere> {}
