import 'package:flutter_modular/flutter_modular.dart';
import 'domain/repositories/shifts_repository_interface.dart';
import 'data/repositories_impl/shifts_repository_impl.dart';
import 'domain/usecases/get_my_shifts_usecase.dart';
import 'domain/usecases/get_available_shifts_usecase.dart';
import 'domain/usecases/get_pending_assignments_usecase.dart';
import 'domain/usecases/get_cancelled_shifts_usecase.dart';
import 'domain/usecases/get_history_shifts_usecase.dart';
import 'domain/usecases/accept_shift_usecase.dart';
import 'domain/usecases/decline_shift_usecase.dart';
import 'domain/usecases/apply_for_shift_usecase.dart';
import 'domain/usecases/get_shift_details_usecase.dart';
import 'presentation/blocs/shifts/shifts_bloc.dart';
import 'presentation/blocs/shift_details/shift_details_bloc.dart';
import 'presentation/pages/shifts_page.dart';

class StaffShiftsModule extends Module {
  @override
  void binds(Injector i) {
    // Repository
    i.add<ShiftsRepositoryInterface>(ShiftsRepositoryImpl.new);

    // UseCases
    i.add(GetMyShiftsUseCase.new);
    i.add(GetAvailableShiftsUseCase.new);
    i.add(GetPendingAssignmentsUseCase.new);
    i.add(GetCancelledShiftsUseCase.new);
    i.add(GetHistoryShiftsUseCase.new);
    i.add(AcceptShiftUseCase.new);
    i.add(DeclineShiftUseCase.new);
    i.add(ApplyForShiftUseCase.new);
    i.add(GetShiftDetailsUseCase.new);

    // Bloc
    i.add(ShiftsBloc.new);
    i.add(ShiftDetailsBloc.new);
  }

  @override
  void routes(RouteManager r) {
    r.child(
      '/',
      child: (_) {
        final args = r.args.data as Map?;
        final queryParams = r.args.queryParams;
        return ShiftsPage(
          initialTab: queryParams['tab'] ?? args?['initialTab'],
          selectedDate: args?['selectedDate'],
        );
      },
    );
  }
}
