All files / src/platform/tenants branding.controller.ts

0% Statements 0/14
0% Branches 0/8
0% Functions 0/3
0% Lines 0/12

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38                                                                           
import { Controller, Get, Put, Body, Req, UseGuards } from '@nestjs/common';
import { TenantService } from './tenant.service';
import { JwtAuthGuard } from '../auth/jwt-auth.guard';
import { ApiTags, ApiOperation, ApiResponse } from '@nestjs/swagger';
 
@Controller('api/v1/branding')
@ApiTags('Branding')
@UseGuards(JwtAuthGuard)
export class BrandingController {
  constructor(private readonly tenantService: TenantService) {}
 
  @Get()
  @ApiOperation({ summary: 'Retrieve white-label branding styles' })
  @ApiResponse({ status: 200, description: 'Branding details config' })
  async getBranding(@Req() req: any) {
    const tenantId = req.user?.tenantId || req.headers['x-tenant-id'];
    return this.tenantService.getBranding(tenantId);
  }
 
  @Put()
  @ApiOperation({ summary: 'Update white-label branding configurations' })
  @ApiResponse({ status: 200, description: 'Updated branding config payload' })
  async updateBranding(
    @Req() req: any,
    @Body()
    body: {
      logo?: string;
      favicon?: string;
      primaryColor?: string;
      accentColor?: string;
      domain?: string;
    },
  ) {
    const tenantId = req.user?.tenantId || req.headers['x-tenant-id'];
    return this.tenantService.updateBranding(tenantId, body);
  }
}