import { Module } from '@nestjs/common';
import { CqrsModule } from '@nestjs/cqrs';
import { RecalculateQualityScoreHandler } from './application/commands/recalculate-quality-score/recalculate-quality-score.handler';
import { UpgradeToAgentHandler } from './application/commands/upgrade-to-agent/upgrade-to-agent.handler';
import { ReviewEventsListener } from './application/listeners/review-events.listener';
import { GetAgentDashboardHandler } from './application/queries/get-agent-dashboard/get-agent-dashboard.handler';
import { GetAgentPublicProfileHandler } from './application/queries/get-agent-public-profile/get-agent-public-profile.handler';
import { AGENT_REPOSITORY } from './domain/repositories/agent.repository';
import { PrismaAgentRepository } from './infrastructure/repositories/prisma-agent.repository';
import { AgentsController } from './presentation/controllers/agents.controller';

const CommandHandlers = [RecalculateQualityScoreHandler, UpgradeToAgentHandler];

const QueryHandlers = [GetAgentDashboardHandler, GetAgentPublicProfileHandler];

@Module({
  imports: [CqrsModule],
  controllers: [AgentsController],
  providers: [
    { provide: AGENT_REPOSITORY, useClass: PrismaAgentRepository },
    ...CommandHandlers,
    ...QueryHandlers,
    ReviewEventsListener,
  ],
  exports: [AGENT_REPOSITORY],
})
export class AgentsModule {}
