/// Represents a push notification received from the backend. class AppNotification { final String id; final String type; // alert, approval, task_complete, message final String title; final String body; final String? actionRoute; // deep link path, e.g. '/alerts' final DateTime receivedAt; final bool isRead; const AppNotification({ required this.id, required this.type, required this.title, required this.body, this.actionRoute, required this.receivedAt, this.isRead = false, }); AppNotification copyWith({bool? isRead}) { return AppNotification( id: id, type: type, title: title, body: body, actionRoute: actionRoute, receivedAt: receivedAt, isRead: isRead ?? this.isRead, ); } factory AppNotification.fromJson(Map json) { return AppNotification( id: json['id'] as String? ?? DateTime.now().millisecondsSinceEpoch.toString(), type: json['type'] as String? ?? 'message', title: json['title'] as String? ?? json['content'] as String? ?? '', body: json['body'] as String? ?? json['content'] as String? ?? '', actionRoute: json['actionRoute'] as String?, receivedAt: json['receivedAt'] != null ? DateTime.parse(json['receivedAt'] as String) : (json['sentAt'] != null ? DateTime.parse(json['sentAt'] as String) : DateTime.now()), isRead: json['isRead'] as bool? ?? false, ); } }