import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { AccessScopeEnum } from 'src/common/enum/access-scope.enum';
import { AccessStateEnum } from 'src/common/enum/access-state.enum';

/**
 * Response DTO for program access user mapping
 */
export class ProgramAccessUserResponseDto {
  @ApiProperty({
    description: 'Mapping ID',
    example: 1,
  })
  id: number;

  @ApiProperty({
    description: 'Program ID',
    example: 10,
  })
  programId: number;

  @ApiProperty({
    description: 'User ID',
    example: 101,
  })
  userId: number;

  @ApiPropertyOptional({
    description: 'User details',
  })
  user?: {
    id: number;
    fullName: string;
    email: string;
    phoneNumber: string;
    gender: string;
    role: string;
  };

  @ApiProperty({
    description: 'Access scope',
    enum: AccessScopeEnum,
    example: AccessScopeEnum.VIEW_AND_REGISTER,
  })
  accessScope: AccessScopeEnum;

  @ApiProperty({
    description: 'Current state of mapping',
    enum: AccessStateEnum,
    example: AccessStateEnum.ACTIVE,
  })
  state: AccessStateEnum;

  @ApiPropertyOptional({
    description: 'When access becomes effective',
    example: '2026-03-28T00:00:00.000Z',
  })
  effectiveFrom?: Date;

  @ApiPropertyOptional({
    description: 'When access expires',
    example: null,
  })
  effectiveTill?: Date;

  @ApiPropertyOptional({
    description: 'Reason for the mapping',
    example: 'Internal batch publish',
  })
  reason?: string;

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

/**
 * Paginated response for program access users
 */
export class ProgramAccessUsersListResponseDto {
  @ApiProperty({
    description: 'List of access mappings',
    type: [ProgramAccessUserResponseDto],
  })
  data: ProgramAccessUserResponseDto[];

  @ApiProperty({
    description: 'Pagination information',
    example: {
      totalPages: 5,
      pageNumber: 1,
      pageSize: 20,
      totalRecords: 100,
      numberOfRecords: 20,
    },
  })
  pagination: {
    totalPages: number;
    pageNumber: number;
    pageSize: number;
    totalRecords: number;
    numberOfRecords: number;
  };
}
