import { BadRequestException, Controller, Get } from '@nestjs/common';
import { LocalitiesService } from './localities.service';
import { CurrentUser } from '../../common/decorators/auth.decorators';
import type { AuthUser } from '@vihar/shared';

@Controller('localities')
export class LocalitiesController {
  constructor(private readonly localities: LocalitiesService) {}

  @Get()
  list(@CurrentUser() user: AuthUser) {
    if (!user.cityId) throw new BadRequestException('No city scope');
    return this.localities.list(user.cityId);
  }
}
