import 'package:krow_core/core.dart';
import 'package:krow_domain/krow_domain.dart';
import '../repositories/availability_repository.dart';

/// Use case to fetch availability for a specific week.
/// 
/// This encapsulates the logic of calculating the week range and fetching data
/// from the repository.
class GetWeeklyAvailabilityUseCase extends UseCase<GetWeeklyAvailabilityParams, List<DayAvailability>> {
  final AvailabilityRepository repository;

  GetWeeklyAvailabilityUseCase(this.repository);

  @override
  Future<List<DayAvailability>> call(GetWeeklyAvailabilityParams params) async {
    // Calculate end of week (assuming start is start of week)
    final end = params.start.add(const Duration(days: 6));
    return repository.getAvailability(params.start, end);
  }
}

/// Parameters for [GetWeeklyAvailabilityUseCase].
class GetWeeklyAvailabilityParams extends UseCaseArgument {
  final DateTime start;

  const GetWeeklyAvailabilityParams(this.start);

  @override
  List<Object?> get props => [start];
}
