import { Controller, Get, Query, Req, UseGuards } from '@nestjs/common';
import { ApiBearerAuth, ApiOperation, ApiTags } from '@nestjs/swagger';
import { JwtAuthGuard } from '../auth/guards/jwt-auth.guard';
import { ProsthesisCatalogService } from './prosthesis-catalog.service';

@ApiTags('prosthesis-catalog')
@ApiBearerAuth('JWT-auth')
@UseGuards(JwtAuthGuard)
@Controller('prosthesis-catalog')
export class ProsthesisCatalogController {
  constructor(private readonly prosthesisCatalogService: ProsthesisCatalogService) {}

  @Get()
  @ApiOperation({
    summary: 'List prosthesis types (optionally scoped to lab — v1 returns all types)',
  })
  list(
    @Req() req: { user?: { language?: string | null } },
    @Query('labOrganizationId') _labOrganizationId?: string,
  ) {
    return this.prosthesisCatalogService.list(req.user?.language).then((data) => ({
      success: true,
      data,
    }));
  }
}
