import { Body, Controller, Delete, Get, Param, Patch, Post, Query, UseGuards, } from '@nestjs/common'; import { AuthUser } from '../auth/auth.types'; import { CurrentUser } from '../auth/decorators/current-user.decorator'; import { RequireBusinessPermission } from '../auth/decorators/require-business-permission.decorator'; import { BusinessPermissionGuard } from '../auth/guards/business-permission.guard'; import { JwtAuthGuard } from '../auth/guards/jwt-auth.guard'; import { CreateWebsiteBrandGroupDto, ListWebsiteBrandGroupsDto, UpdateWebsiteBrandGroupDto, } from './dto/website-brand-groups.dto'; import { WebsiteBrandGroupsService } from './website-brand-groups.service'; @Controller('tenants/:host/website/brand-groups') export class PublicWebsiteBrandGroupsController { constructor(private readonly service: WebsiteBrandGroupsService) {} @Get() list(@Param('host') host: string) { return this.service.listPublic(host); } } @Controller('businesses/:businessId/website/brand-groups') @UseGuards(JwtAuthGuard, BusinessPermissionGuard) export class WebsiteBrandGroupsController { constructor(private readonly service: WebsiteBrandGroupsService) {} @Get() @RequireBusinessPermission('website.read') list( @Param('businessId') businessId: string, @Query() query: ListWebsiteBrandGroupsDto, @CurrentUser() user: AuthUser, ) { return this.service.list(businessId, query, user); } @Get(':groupId') @RequireBusinessPermission('website.read') getOne( @Param('businessId') businessId: string, @Param('groupId') groupId: string, @CurrentUser() user: AuthUser, ) { return this.service.getOne(businessId, groupId, user); } @Post() @RequireBusinessPermission('website.update') create( @Param('businessId') businessId: string, @Body() dto: CreateWebsiteBrandGroupDto, @CurrentUser() user: AuthUser, ) { return this.service.create(businessId, dto, user); } @Patch(':groupId') @RequireBusinessPermission('website.update') update( @Param('businessId') businessId: string, @Param('groupId') groupId: string, @Body() dto: UpdateWebsiteBrandGroupDto, @CurrentUser() user: AuthUser, ) { return this.service.update(businessId, groupId, dto, user); } @Delete(':groupId') @RequireBusinessPermission('website.update') remove( @Param('businessId') businessId: string, @Param('groupId') groupId: string, @CurrentUser() user: AuthUser, ) { return this.service.remove(businessId, groupId, user); } }