class AppNotification {
  final String id;
  final String userId;
  final String type; // 'connection' | 'message' | 'system' | 'update' | 'request'
  final String title;
  final String description;
  final bool read;
  final String? actionUrl;
  final Map<String, String>? data;
  final DateTime createdAt;

  const AppNotification({
    required this.id,
    required this.userId,
    required this.type,
    required this.title,
    required this.description,
    required this.read,
    this.actionUrl,
    this.data,
    required this.createdAt,
  });

  factory AppNotification.fromJson(Map<String, dynamic> json) {
    return AppNotification(
      id: json['id'] as String,
      userId: json['userId'] as String? ?? '',
      type: json['type'] as String? ?? 'system',
      title: json['title'] as String? ?? '',
      description: json['description'] as String? ?? '',
      read: json['read'] as bool? ?? false,
      actionUrl: json['actionUrl'] as String?,
      data: json['data'] != null
          ? Map<String, String>.from(json['data'] as Map)
          : null,
      createdAt: DateTime.parse(json['createdAt'] as String),
    );
  }

  AppNotification copyWith({bool? read}) {
    return AppNotification(
      id: id,
      userId: userId,
      type: type,
      title: title,
      description: description,
      read: read ?? this.read,
      actionUrl: actionUrl,
      data: data,
      createdAt: createdAt,
    );
  }
}
