import { IsEnum, IsOptional, IsString, IsDateString } from 'class-validator';
import { ApiPropertyOptional } from '@nestjs/swagger';
import { AccessScopeEnum } from 'src/common/enum/access-scope.enum';
import { AccessStateEnum } from 'src/common/enum/access-state.enum';

/**
 * DTO for updating program access user mapping
 */
export class UpdateProgramAccessUserDto {
  @ApiPropertyOptional({
    description: 'Access scope for the user',
    enum: AccessScopeEnum,
    example: AccessScopeEnum.VIEW_ONLY,
  })
  @IsEnum(AccessScopeEnum)
  @IsOptional()
  accessScope?: AccessScopeEnum;

  @ApiPropertyOptional({
    description: 'State of the access mapping',
    enum: AccessStateEnum,
    example: AccessStateEnum.ACTIVE,
  })
  @IsEnum(AccessStateEnum)
  @IsOptional()
  state?: AccessStateEnum;

  @ApiPropertyOptional({
    description: 'When the access becomes effective (ISO 8601 format)',
    example: '2026-03-28T00:00:00.000Z',
  })
  @IsOptional()
  @IsDateString()
  effectiveFrom?: string;

  @ApiPropertyOptional({
    description: 'When the access expires (ISO 8601 format)',
    example: '2026-12-31T23:59:59.000Z',
  })
  @IsOptional()
  @IsDateString()
  effectiveTill?: string;

  @ApiPropertyOptional({
    description: 'Reason for updating access',
    example: 'Extended access due to special request',
  })
  @IsOptional()
  @IsString()
  reason?: string;

  @ApiPropertyOptional({
    description: 'Additional metadata',
    example: { updated_by_admin: true },
  })
  @IsOptional()
  meta?: Record<string, any>;
}
