import { ApiProperty } from '@nestjs/swagger';
import { IsEnum, IsInt, IsPositive } from 'class-validator';
import { AttendanceStatus } from 'src/common/enum/attendance-status.enum';

/**
 * Legacy unmark / owner-scoped undo target for an online session. Identified by
 * registration (not user) so proxy and child registrations are handled
 * correctly — matching how the rest of the online-attendance flow keys per-session
 * attendance.
 */
export class MarkAttendanceDto {
  @ApiProperty({ description: 'Registration id to unmark/undo attendance for' })
  @IsInt()
  @IsPositive()
  registrationId: number;
}

/**
 * Source-aware manual mark (SESSION_ATTENDANCE): carries an explicit present/
 * absent status. The source (RM vs coordinator) is derived server-side from the
 * caller's roles — never sent by the client — see TRD §6.
 */
export class SetAttendanceDto {
  @ApiProperty({ description: 'Registration id to mark attendance for' })
  @IsInt()
  @IsPositive()
  registrationId: number;

  @ApiProperty({
    enum: [AttendanceStatus.PRESENT, AttendanceStatus.ABSENT],
    description: 'Whether the registrant is present or absent',
  })
  @IsEnum(AttendanceStatus)
  status: AttendanceStatus;
}
