import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { ConfigModule } from '@nestjs/config';

// Controller
import { AdminController } from '../controllers/admin.controller';

// ORM Entities
import { UserOrmEntity } from '@infrastructure/persistence/typeorm/entities/user.orm-entity';
import { OrganizationOrmEntity } from '@infrastructure/persistence/typeorm/entities/organization.orm-entity';
import { CsvBookingOrmEntity } from '@infrastructure/persistence/typeorm/entities/csv-booking.orm-entity';

// Repositories
import { TypeOrmUserRepository } from '@infrastructure/persistence/typeorm/repositories/typeorm-user.repository';
import { TypeOrmOrganizationRepository } from '@infrastructure/persistence/typeorm/repositories/typeorm-organization.repository';
import { TypeOrmCsvBookingRepository } from '@infrastructure/persistence/typeorm/repositories/csv-booking.repository';

// Repository tokens
import { USER_REPOSITORY } from '@domain/ports/out/user.repository';
import { ORGANIZATION_REPOSITORY } from '@domain/ports/out/organization.repository';

// SIRET verification
import { SIRET_VERIFICATION_PORT } from '@domain/ports/out/siret-verification.port';
import { PappersSiretAdapter } from '@infrastructure/external/pappers-siret.adapter';

// CSV Booking Service
import { CsvBookingsModule } from '../csv-bookings/csv-bookings.module';

// Email
import { EmailModule } from '@infrastructure/email/email.module';

// Blog
import { BlogModule } from '../blog/blog.module';

// Storage
import { StorageModule } from '@infrastructure/storage/storage.module';

@Module({
  imports: [
    TypeOrmModule.forFeature([UserOrmEntity, OrganizationOrmEntity, CsvBookingOrmEntity]),
    ConfigModule,
    CsvBookingsModule,
    EmailModule,
    BlogModule,
    StorageModule,
  ],
  controllers: [AdminController],
  providers: [
    {
      provide: USER_REPOSITORY,
      useClass: TypeOrmUserRepository,
    },
    {
      provide: ORGANIZATION_REPOSITORY,
      useClass: TypeOrmOrganizationRepository,
    },
    TypeOrmCsvBookingRepository,
    {
      provide: SIRET_VERIFICATION_PORT,
      useClass: PappersSiretAdapter,
    },
  ],
})
export class AdminModule {}
