import '../utils/app_time.dart';

class TicketMessage {
  TicketMessage({
    required this.id,
    required this.ticketId,
    required this.taskId,
    required this.senderId,
    required this.content,
    required this.createdAt,
  });

  final int id;
  final String? ticketId;
  final String? taskId;
  final String? senderId;
  final String content;
  final DateTime createdAt;

  factory TicketMessage.fromMap(Map<String, dynamic> map) {
    return TicketMessage(
      id: map['id'] as int,
      ticketId: map['ticket_id'] as String?,
      taskId: map['task_id'] as String?,
      senderId: map['sender_id'] as String?,
      content: map['content'] as String? ?? '',
      createdAt: AppTime.parse(map['created_at'] as String),
    );
  }
}
