import 'package:firebase_auth/firebase_auth.dart' as auth;
import 'package:flutter_modular/flutter_modular.dart';
import 'package:krow_data_connect/krow_data_connect.dart';
import 'package:staff_bank_account/src/data/repositories/bank_account_repository_impl.dart';

import 'domain/repositories/bank_account_repository.dart';
import 'domain/usecases/add_bank_account_usecase.dart';
import 'domain/usecases/get_bank_accounts_usecase.dart';
import 'presentation/blocs/bank_account_cubit.dart';
import 'presentation/pages/bank_account_page.dart';

class StaffBankAccountModule extends Module {
  @override
  List<Module> get imports => <Module>[DataConnectModule()];
  
  @override
  void binds(Injector i) {
    // Repositories
    i.addLazySingleton<BankAccountRepository>(
      () => BankAccountRepositoryImpl(
        firebaseAuth: auth.FirebaseAuth.instance,
        dataConnect: ExampleConnector.instance,
      ),
    );
    
    // Use Cases
    i.addLazySingleton<GetBankAccountsUseCase>(GetBankAccountsUseCase.new);
    i.addLazySingleton<AddBankAccountUseCase>(AddBankAccountUseCase.new);
    
    // Blocs
    i.add<BankAccountCubit>(
      () => BankAccountCubit(
        getBankAccountsUseCase: i.get<GetBankAccountsUseCase>(),
        addBankAccountUseCase: i.get<AddBankAccountUseCase>(),
      ),
    );
  }

  @override
  void routes(RouteManager r) {
    r.child('/', child: (_) => const BankAccountPage());
  }
}
