All files / src/domains/helpdesk/controllers client-helpdesk.controller.ts

0% Statements 0/16
0% Branches 0/12
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                                                                     
import { Controller, Get, Post, Body, Param, Req, UseGuards } from '@nestjs/common';
import { HelpdeskTicketService } from '../services/helpdesk-ticket.service';
import { HelpdeskFeedbackService } from '../services/helpdesk-feedback.service';
import { JwtAuthGuard } from '../../../platform/auth/jwt-auth.guard';
import { ApiTags, ApiOperation } from '@nestjs/swagger';
 
@ApiTags('ClientHelpdesk')
@Controller('api/v1/client/helpdesk')
@UseGuards(JwtAuthGuard)
export class ClientHelpdeskController {
  constructor(
    private readonly ticketSvc: HelpdeskTicketService,
    private readonly feedbackSvc: HelpdeskFeedbackService
  ) {}
 
  @Get('tickets/:id')
  @ApiOperation({ summary: 'Retrieve specific ticket details for Client Portal (hides internal notes)' })
  async getTicketDetailsForClient(@Req() req: any, @Param('id') id: string) {
    const tenantId = req.user?.tenantId || 'SYSTEM';
    // Passing true as clientPortalContext filters out isInternalNote comments
    return this.ticketSvc.getTicketById(tenantId, id, true);
  }
 
  @Post('tickets/:id/feedback')
  @ApiOperation({ summary: 'Submit survey feedback rating for CSAT and NPS validation' })
  async submitFeedback(
    @Req() req: any,
    @Param('id') id: string,
    @Body() body: { score: number; surveyType: 'CSAT' | 'NPS'; comment?: string }
  ) {
    const tenantId = req.user?.tenantId || 'SYSTEM';
    return this.feedbackSvc.submitFeedback(tenantId, id, body.score, body.surveyType, body.comment);
  }
}