import 'package:flutter_modular/flutter_modular.dart';
import 'package:krow_data_connect/krow_data_connect.dart';
import 'data/repositories/emergency_contact_repository_impl.dart';
import 'domain/repositories/emergency_contact_repository_interface.dart';
import 'domain/usecases/get_emergency_contacts_usecase.dart';
import 'domain/usecases/save_emergency_contacts_usecase.dart';
import 'presentation/blocs/emergency_contact_bloc.dart';
import 'presentation/pages/emergency_contact_screen.dart';

class StaffEmergencyContactModule extends Module {
  @override
  void binds(Injector i) {
    // Repository
    // Uses ProfileRepositoryMock from data_connect
    i.addLazySingleton<ProfileRepositoryMock>(ProfileRepositoryMock.new);
    i.addLazySingleton<EmergencyContactRepositoryInterface>(
      () => EmergencyContactRepositoryImpl(i.get<ProfileRepositoryMock>()),
    );

    // UseCases
    i.addLazySingleton<GetEmergencyContactsUseCase>(
      () => GetEmergencyContactsUseCase(i.get<EmergencyContactRepositoryInterface>()),
    );
    i.addLazySingleton<SaveEmergencyContactsUseCase>(
      () => SaveEmergencyContactsUseCase(i.get<EmergencyContactRepositoryInterface>()),
    );

    // BLoC
    i.addLazySingleton<EmergencyContactBloc>(
      () => EmergencyContactBloc(
        getEmergencyContacts: i.get<GetEmergencyContactsUseCase>(),
        saveEmergencyContacts: i.get<SaveEmergencyContactsUseCase>(),
        staffId: 'mock-staff-id', // TODO: Get direct from auth state
      ),
    );
  }

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