import { ApiProperty } from '@nestjs/swagger';
import { TicketPriority, TicketSource, TicketStatus } from 'common/enum/ticket.enum';
import { UserCommentResponseDto } from './comment-response.dto';

export class TicketResponseDto {
  @ApiProperty({ example: 1, description: 'Unique identifier for the ticket' })
  id: number;

  @ApiProperty({ example: 'TKT-12345678', description: 'Unique ticket token' })
  ticketToken: string;

  @ApiProperty({ example: 'Login issue', description: 'Title of the ticket' })
  title: string;

  @ApiProperty({ example: 'Unable to log into the system', description: 'Detailed description of the issue' })
  description: string;

  @ApiProperty({ example: TicketSource.MANUAL, enum: TicketSource, description: 'Source of the ticket creation' })
  source: TicketSource;

  @ApiProperty({ example: TicketStatus.OPEN, enum: TicketStatus, description: 'Current status of the ticket' })
  status: TicketStatus;

  @ApiProperty({ example: TicketPriority.MEDIUM, enum: TicketPriority, description: 'Priority level of the ticket' })
  priority: TicketPriority;

  @ApiProperty({ example: 1, description: 'Author of the ticket' })
  authorId: number;

  @ApiProperty({ example: 1, description: 'Assignee of the ticket', required: false })
  assigneeId?: number;

  @ApiProperty({ example: ['bug', 'urgent'], description: 'Labels associated with the ticket', required: false })
  labels?: string[];

  @ApiProperty({ example: 1, description: 'Reference ID for the ticket', required: false })
  referenceId?: number;

  @ApiProperty({ example: 'https://example.com/attachment', description: 'URL of the attached file (NOT FOR FRONTEND)', required: false })
  attachmentUrl?: string;

  @ApiProperty({ example: '2024-02-20T10:00:00.000Z', description: 'Timestamp when the ticket was created' })
  createdAt: Date;

  @ApiProperty({ example: '2024-02-20T12:00:00.000Z', description: 'Timestamp when the ticket was last updated' })
  updatedAt: Date;

  @ApiProperty({
    example: [
      {
        id: 1,
        content: 'This is a test comment',
        authorId: 1,
        ticketId: 1,
        createdAt: '2024-02-20T10:00:00.000Z',
        updatedAt: '2024-02-20T10:00:00.000Z',
      },
    ],
    description: 'List of comments on the ticket',
    type: [UserCommentResponseDto],
    required: false,
  })
  comments?: UserCommentResponseDto[];

  // constructor(ticket: TicketResponseDto) {
  //   this.id = ticket.id;
  //   this.title = ticket.title;
  //   this.description = ticket.description;
  //   this.status = ticket.status;
  //   this.priority = ticket.priority;
  //   this.authorId = ticket.authorId;
  //   this.assigneeId = ticket.assigneeId;
  //   this.labels = ticket.labels || [];
  //   this.createdAt = ticket.createdAt;
  //   this.updatedAt = ticket.updatedAt;
  //   this.comments = ticket.comments || [];
  // }
}
