/// Use Case: Get Categories
///
/// Business logic for retrieving product categories.
library;

import 'package:worker/features/products/domain/entities/category.dart';
import 'package:worker/features/products/domain/repositories/products_repository.dart';

/// Get Categories Use Case
///
/// Retrieves all product categories from the repository.
class GetCategories {
  final ProductsRepository repository;

  const GetCategories(this.repository);

  /// Execute the use case
  ///
  /// Returns list of all categories sorted by order
  Future<List<Category>> call() async {
    final categories = await repository.getCategories();

    // Sort by display order
    categories.sort((a, b) => a.order.compareTo(b.order));

    return categories;
  }
}
