library staff_profile_experience;

import 'package:flutter_modular/flutter_modular.dart';
import 'package:krow_data_connect/krow_data_connect.dart';

import 'src/data/repositories/experience_repository_impl.dart';
import 'src/domain/repositories/experience_repository_interface.dart';
import 'src/domain/usecases/get_staff_industries_usecase.dart';
import 'src/domain/usecases/get_staff_skills_usecase.dart';
import 'src/domain/usecases/save_experience_usecase.dart';
import 'src/presentation/blocs/experience_bloc.dart';
import 'src/presentation/pages/experience_page.dart';

export 'src/presentation/pages/experience_page.dart';

class StaffProfileExperienceModule extends Module {
  @override
  List<Module> get imports => [DataConnectModule()];

  @override
  void binds(Injector i) {
    // Repository
    i.addLazySingleton<ExperienceRepositoryInterface>(
      ExperienceRepositoryImpl.new,
    );

    // UseCases
    i.addLazySingleton<GetStaffIndustriesUseCase>(
      () => GetStaffIndustriesUseCase(i.get<ExperienceRepositoryInterface>()),
    );
    i.addLazySingleton<GetStaffSkillsUseCase>(
      () => GetStaffSkillsUseCase(i.get<ExperienceRepositoryInterface>()),
    );
    i.addLazySingleton<SaveExperienceUseCase>(
      () => SaveExperienceUseCase(i.get<ExperienceRepositoryInterface>()),
    );

    // BLoC
    i.add<ExperienceBloc>(
      () => ExperienceBloc(
        getIndustries: i.get<GetStaffIndustriesUseCase>(),
        getSkills: i.get<GetStaffSkillsUseCase>(),
        saveExperience: i.get<SaveExperienceUseCase>(),
      ),
    );
  }

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