All files / src/domains/crm/controllers lead-capture.controller.ts

0% Statements 0/16
0% Branches 0/4
0% Functions 0/3
0% Lines 0/14

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 39 40                                                                               
import {
  Controller,
  Get,
  Post,
  Body,
  Param,
  UseGuards,
  Request,
} from '@nestjs/common';
import { LeadCaptureService } from '../services/lead-capture.service';
import { PermissionGuard } from '../../../platform/permissions/permission.guard';
import { RequirePermission } from '../../../platform/permissions/permission.decorator';
import { Types } from 'mongoose';
import { ApiTags, ApiOperation, ApiResponse } from '@nestjs/swagger';
 
@Controller('crm/lead-capture')
@UseGuards(PermissionGuard)
@ApiTags('LeadCapture')
export class LeadCaptureController {
  constructor(private readonly leadCaptureService: LeadCaptureService) {}
 
  @Post('forms')
  @RequirePermission('crm_config', 'update')
  @ApiOperation({ summary: 'Create form operation' })
  @ApiResponse({ status: 201, description: 'Operation successful' })
  async createForm(@Request() req: any, @Body() body: any) {
    const tenantId = new Types.ObjectId(req.user.tenantId);
    return this.leadCaptureService.createForm(tenantId, body);
  }
 
  @Get('forms/:formId/submissions')
  @RequirePermission('crm_lead', 'read')
  @ApiOperation({ summary: 'Get submissions operation' })
  @ApiResponse({ status: 200, description: 'Operation successful' })
  async getSubmissions(@Request() req: any, @Param('formId') formId: string) {
    const tenantId = new Types.ObjectId(req.user.tenantId);
    return this.leadCaptureService.getSubmissions(tenantId, formId);
  }
}