/// Order Status Model
///
/// Data model for order 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/orders/domain/entities/order_status.dart';

part 'order_status_model.g.dart';

/// Order Status Model - Type ID: 62
@HiveType(typeId: HiveTypeIds.orderStatusModel)
class OrderStatusModel extends HiveObject {
  @HiveField(0)
  final String status;

  @HiveField(1)
  final String label;

  @HiveField(2)
  final String color;

  @HiveField(3)
  final int index;

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

  /// Create from JSON
  factory OrderStatusModel.fromJson(Map<String, dynamic> json) {
    return OrderStatusModel(
      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
  OrderStatus toEntity() {
    return OrderStatus(
      status: status,
      label: label,
      color: color,
      index: index,
    );
  }

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