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

class TaskActivityLog {
  TaskActivityLog({
    required this.id,
    required this.taskId,
    this.actorId,
    required this.actionType,
    this.meta,
    required this.createdAt,
  });

  final String id;
  final String taskId;
  final String? actorId;
  final String actionType; // created, assigned, reassigned, started, completed
  final Map<String, dynamic>? meta;
  final DateTime createdAt;

  factory TaskActivityLog.fromMap(Map<String, dynamic> map) {
    return TaskActivityLog(
      id: map['id'] as String,
      taskId: map['task_id'] as String,
      actorId: map['actor_id'] as String?,
      actionType: map['action_type'] as String? ?? 'unknown',
      meta: map['meta'] as Map<String, dynamic>?,
      createdAt: AppTime.parse(map['created_at'] as String),
    );
  }
}
