targo-backend/src/time-and-attendance/time-tracker/timesheets/controllers/timesheet.controller.ts

20 lines
980 B
TypeScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { Controller, Get, ParseIntPipe, Query, Req, UnauthorizedException} from "@nestjs/common";
import { RolesAllowed } from "src/common/decorators/roles.decorators";
import { GetTimesheetsOverviewService } from "src/time-and-attendance/time-tracker/timesheets/services/timesheet-get-overview.service";
import { Roles as RoleEnum } from '.prisma/client';
@Controller('timesheets')
export class TimesheetController {
constructor( private readonly timesheetOverview: GetTimesheetsOverviewService ){}
@Get()
@RolesAllowed(RoleEnum.SUPERVISOR, RoleEnum.HR, RoleEnum.ACCOUNTING, RoleEnum.ADMIN)
async getTimesheetByIds(
@Req() req, @Query('year', ParseIntPipe) year:number, @Query('period_number', ParseIntPipe) period_number: number) {
const email = req.user?.email;
if(!email) throw new UnauthorizedException('Unauthorized User'); 
return this.timesheetOverview.getTimesheetsForEmployeeByPeriod(email, year, period_number);
}
}