class TaskStage {
  final String stageName;
  final String displayName;
  final String status; // pending / in_progress / completed / failed
  final int progress;
  final DateTime? startedAt;
  final DateTime? endedAt;
  final String? errorMessage;

  TaskStage({
    required this.stageName,
    required this.displayName,
    required this.status,
    required this.progress,
    this.startedAt,
    this.endedAt,
    this.errorMessage,
  });

  factory TaskStage.fromJson(Map<String, dynamic> json) {
    return TaskStage(
      stageName: json['stageName'] ?? '',
      displayName: json['displayName'] ?? '',
      status: json['status'] ?? 'pending',
      progress: (json['progress'] ?? 0) as int,
      startedAt: json['startedAt'] != null
          ? DateTime.parse(json['startedAt'] as String)
          : null,
      endedAt: json['endedAt'] != null
          ? DateTime.parse(json['endedAt'] as String)
          : null,
      errorMessage: json['errorMessage'] as String?,
    );
  }
}


