import { Module, forwardRef } from "@nestjs/common";
import { TypeOrmModule } from "@nestjs/typeorm";
import { HttpModule } from "@nestjs/axios";
import { FilesModule } from "../files/files.module";
import { FileUploadSettingsModule } from "../file-upload-settings/file-upload-settings.module";
import { MinioModule } from "../minio/minio.module";
import { NotificationsModule } from "../notifications/notifications.module";
import { NotificationInboxModule } from "../notification-inbox/notification-inbox.module";
import { CompaniesController } from "./companies.controller";
import { CompaniesService } from "./companies.service";
import { CompaniesRepository } from "./companies.repository";
import { ExternalProfileRepository } from "./external-profile.repository";
import { CompanyDashboardRepository } from "./company-dashboard.repository";
import { Company } from "./entities/company.entity";
import { ExternalProfile } from "./entities/external-profile.entity";
import { CompanyProfile } from "./entities/company-profile.entity";
import { CompanyChangeRequest } from "./entities/company-change-request.entity";
import { Booking } from "../bookings/entities/booking.entity";
import { CompanyProfileRepository } from "./company-profile.repository";
import { CompanyChangeRequestRepository } from "./company-change-request.repository";
import { ETradeService } from "./services/etrade.service";
import { CompanyNotifierService } from "./company-notifier.service";

@Module({
  imports: [
    TypeOrmModule.forFeature([
      Company,
      ExternalProfile,
      CompanyProfile,
      CompanyChangeRequest,
      Booking,
    ]),
    HttpModule,
    FilesModule,
    FileUploadSettingsModule,
    MinioModule,
    // Account-status notifications (CompanyNotifierService). The inbox module
    // imports this module back for portal recipient targeting, hence forwardRef.
    NotificationsModule,
    forwardRef(() => NotificationInboxModule),
  ],
  controllers: [CompaniesController],
  providers: [
    CompaniesService,
    CompaniesRepository,
    ExternalProfileRepository,
    CompanyProfileRepository,
    CompanyChangeRequestRepository,
    CompanyDashboardRepository,
    ETradeService,
    CompanyNotifierService,
  ],
  exports: [
    CompaniesService,
    // Consumed by NotificationInboxModule for portal recipient targeting.
    ExternalProfileRepository,
    CompanyProfileRepository,
  ],
})
export class CompaniesModule { }
