This commit is contained in:
2025-11-25 15:49:08 +03:30
parent 6f76b36a09
commit e6fb28b87e
4 changed files with 58 additions and 49 deletions
@@ -36,21 +36,17 @@ export class CategoryController {
@UseGuards(AdminAuthGuard)
@ApiBearerAuth()
@Post('admin/categories')
create(@Body() dto: CreateCategoryDto) {
return this.categoryService.create(dto);
create(@Body() dto: CreateCategoryDto, @RestId() restId: string) {
return this.categoryService.create(restId, dto);
}
@ApiOperation({ summary: 'my restaurant categories' })
@ApiOkResponse({ description: 'List of categories' })
@ApiQuery({ name: 'restId', required: false, type: String })
@ApiQuery({ name: 'isActive', required: false, type: Boolean })
@UseGuards(AdminAuthGuard)
@ApiBearerAuth()
@Get('admin/categories')
findAll(@RestId() restId: string, @Query('isActive') isActive?: string) {
// convert isActive from query string to boolean when provided
const isActiveBool: boolean | undefined = typeof isActive !== 'undefined' ? isActive === 'true' : undefined;
return this.categoryService.findAll({ restId, isActive: isActiveBool });
findAll(@RestId() restId: string) {
return this.categoryService.findAllByRestaurantId(restId);
}
@UseGuards(AdminAuthGuard)