import { BotTelegramApi } from '@/modules/bids/apis/bot-telegram.api';
import { Body, Controller, Get, Post } from '@nestjs/common';
import { SendMessageDto } from '../dto/send-message.dto';
import { NotificationService } from '../notification.service';
import { BidsService } from '@/modules/bids/services/bids.service';

@Controller('notifications')
export class ClientNotificationController {
  constructor(
    private botTelegramApi: BotTelegramApi,
    private readonly notifyService: NotificationService,
    private readonly bidsService: BidsService,
  ) {}

  @Post('send-messages')
  async sendMessage(@Body() data: SendMessageDto) {
    return await this.botTelegramApi.sendMessage(data.text, data.options);
  }

  @Post('test')
  async test() {
    const bid = await this.bidsService.bidsRepo.findOne({
      where: { lot_id: '23755862' },
      relations: { web_bid: true },
    });

    return await this.notifyService.emitBidStatus({
      ...bid,
      status: 'win-bid',
    });
  }
}
