import 'package:riverpod_annotation/riverpod_annotation.dart';
import 'package:worker/features/price_policy/data/datasources/price_policy_local_datasource.dart';
import 'package:worker/features/price_policy/data/repositories/price_policy_repository_impl.dart';
import 'package:worker/features/price_policy/domain/entities/price_document.dart';
import 'package:worker/features/price_policy/domain/repositories/price_policy_repository.dart';

part 'price_documents_provider.g.dart';

/// Provider for local data source
@riverpod
PricePolicyLocalDataSource pricePolicyLocalDataSource(Ref ref) {
  return PricePolicyLocalDataSource();
}

/// Provider for price policy repository
@riverpod
PricePolicyRepository pricePolicyRepository(Ref ref) {
  final localDataSource = ref.watch(pricePolicyLocalDataSourceProvider);

  return PricePolicyRepositoryImpl(localDataSource: localDataSource);
}

/// Provider for all price policy documents
@riverpod
Future<List<PriceDocument>> priceDocuments(Ref ref) async {
  final repository = ref.watch(pricePolicyRepositoryProvider);
  return repository.getAllDocuments();
}

/// Provider for filtered documents by category
@riverpod
Future<List<PriceDocument>> filteredPriceDocuments(
  Ref ref,
  DocumentCategory category,
) async {
  final repository = ref.watch(pricePolicyRepositoryProvider);
  return repository.getDocumentsByCategory(category);
}
