import { Body, Controller, Inject, Post, UseGuards } from '@nestjs/common';
import { WINSTON_MODULE_PROVIDER } from 'nest-winston';
import { OptionalAuthGuard } from 'src/jwt-auth/optional-auth.guard';
import { UserListingCriteria } from 'src/models/main.model';
import { Logger } from 'winston';
import { UserService } from '../user/user.service';

@Controller('listings/professionals_brokers')
export class BrokerListingsController {
  constructor(
    private readonly userService: UserService,
    @Inject(WINSTON_MODULE_PROVIDER) private readonly logger: Logger,
  ) {}

  @UseGuards(OptionalAuthGuard)
  @Post('search')
  async find(@Body() criteria: UserListingCriteria): Promise<any> {
    return await this.userService.searchUserListings(criteria);
  }
}
