/// Project Status Model
///
/// Data model for project status from API responses with Hive caching.
library;

import 'package:hive_ce/hive.dart';
import 'package:worker/core/constants/storage_constants.dart';
import 'package:worker/features/projects/domain/entities/project_status.dart';

part 'project_status_model.g.dart';

/// Project Status Model - Type ID: 63
@HiveType(typeId: HiveTypeIds.projectStatusModel)
class ProjectStatusModel extends HiveObject {
  @HiveField(0)
  final String status;

  @HiveField(1)
  final String label;

  @HiveField(2)
  final String color;

  @HiveField(3)
  final int index;

  ProjectStatusModel({
    required this.status,
    required this.label,
    required this.color,
    required this.index,
  });

  /// Create from JSON
  factory ProjectStatusModel.fromJson(Map<String, dynamic> json) {
    return ProjectStatusModel(
      status: json['status'] as String,
      label: json['label'] as String,
      color: json['color'] as String,
      index: json['index'] as int,
    );
  }

  /// Convert to JSON
  Map<String, dynamic> toJson() {
    return {
      'status': status,
      'label': label,
      'color': color,
      'index': index,
    };
  }

  /// Convert to entity
  ProjectStatus toEntity() {
    return ProjectStatus(
      status: status,
      label: label,
      color: color,
      index: index,
    );
  }

  /// Create from entity
  factory ProjectStatusModel.fromEntity(ProjectStatus entity) {
    return ProjectStatusModel(
      status: entity.status,
      label: entity.label,
      color: entity.color,
      index: entity.index,
    );
  }
}
