import { Body, Controller, Get, HttpCode, HttpStatus, Inject, Post, Req, UseGuards, } from '@nestjs/common'; import { JwtAuthGuard } from 'src/module/auth/guards/jwt.guard'; import { ActionService } from '../service/action.service'; import { ActionDataService } from '../service/action-data.service'; @Controller('/action') @UseGuards(JwtAuthGuard) export class ActionController { constructor( @Inject('ActionService') private readonly actionService: ActionService, private readonly actionDataService: ActionDataService, ) {} @Get('/getReasonCode') @HttpCode(HttpStatus.OK) async getReasonCode(@Req() req: Request & { user: any }) { const loggedInUser = req.user.userData; const result = this.actionService.getReasonCode(loggedInUser); return result; } @Post('/defaultReasonCode') @HttpCode(HttpStatus.OK) async defaultReasonCode( @Req() req: Request & { user: any }, @Body() body: { list_type: string }, ) { const loggedInUser = req.user.userData; const result = this.actionService.defaultReasonCode( body.list_type, loggedInUser, ); return result; } @Post('/getactions') @HttpCode(HttpStatus.OK) async getActions( @Req() req: Request & { user: any }, @Body('stage_id') stage_id: number, ) { const loggedInUser = req.user.userData; const result = this.actionService.getActions(loggedInUser, stage_id); return result; } @Post('/get_dependent_action') @HttpCode(HttpStatus.OK) async getDependentActions( @Req() req: Request & { user: any }, @Body() body: { stage_id: number; action_id?: number }, ) { const loggedInUser = req.user.userData; const result = this.actionService.getDependentActions( loggedInUser, body.stage_id, body.action_id, ); return result; } @Post('/getaction') @HttpCode(HttpStatus.OK) async getAction( @Req() req: Request & { user: any }, @Body('stage_id') stage_id: number, @Body('mapped_entity_id') mapped_entity_id: number, @Body('mapped_entity_type') mapped_entity_type: string, ) { const loggedInUser = req.user.userData; const result = this.actionService.getAction( loggedInUser, stage_id, mapped_entity_id, mapped_entity_type, ); return result; } @Post('/resubmit') @HttpCode(HttpStatus.OK) async resubmit( @Req() req: Request & { user: any }, @Body('stage_id') stage_id: number, @Body('mapped_entity_id') mapped_entity_id: number, @Body('mapped_entity_type') mapped_entity_type: string, @Body('action_id') action_id: number, ) { const loggedInUser = req.user.userData; const result = this.actionDataService.resubmitAction( loggedInUser, mapped_entity_type, mapped_entity_id, stage_id, action_id, ); return result; } }