All files / src/domains/projects/controllers timesheet.controller.ts

0% Statements 0/16
0% Branches 0/22
0% Functions 0/4
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 41 42 43                                                                                     
import { Controller, Post, Put, Param, Body, Req } from '@nestjs/common';
import { TimesheetService } from '../services/timesheet.service';
import { ApiTags, ApiOperation, ApiResponse } from '@nestjs/swagger';
 
@Controller('api/v1/timesheets')
@ApiTags('Timesheet')
export class TimesheetController {
  constructor(private readonly timesheetService: TimesheetService) {}
 
  @Post('generate')
  @ApiOperation({ summary: 'Generate operation' })
  @ApiResponse({ status: 201, description: 'Operation successful' })
  async generate(@Req() req: any, @Body() data: any): Promise<any> {
    const tenantId = req.user?.tenantId || 'dummy-tenant-id';
    return this.timesheetService.generateTimesheet(
      tenantId,
      data.employeeId,
      new Date(data.startDate),
      new Date(data.endDate),
    );
  }
 
  @Put(':id/submit')
  @ApiOperation({ summary: 'Submit operation' })
  @ApiResponse({ status: 200, description: 'Operation successful' })
  async submit(@Req() req: any, @Param('id') id: string): Promise<any> {
    const tenantId = req.user?.tenantId || 'dummy-tenant-id';
    return this.timesheetService.submit(tenantId, id);
  }
 
  @Put(':id/approve')
  @ApiOperation({ summary: 'Approve operation' })
  @ApiResponse({ status: 200, description: 'Operation successful' })
  async approve(
    @Req() req: any,
    @Param('id') id: string,
    @Body('approverId') approverId: string,
  ): Promise<any> {
    const tenantId = req.user?.tenantId || 'dummy-tenant-id';
    return this.timesheetService.approve(tenantId, id, approverId);
  }
}