import { Controller, Get, Query } from '@nestjs/common';
import { placesAutocompleteQuerySchema } from '@vihar/shared';
import { PlacesService } from './places.service';
import { ZodValidationPipe } from '../../common/pipes/zod-validation.pipe';
import { RequiresCaptain } from '../../common/decorators/auth.decorators';

@Controller('places')
@RequiresCaptain()
export class PlacesController {
  constructor(private readonly places: PlacesService) {}

  @Get('autocomplete')
  autocomplete(
    @Query(new ZodValidationPipe(placesAutocompleteQuerySchema)) q: { q: string; sessionToken: string },
  ) {
    return this.places.autocomplete(q.q, q.sessionToken);
  }
}
