import { Get, Param, ParseIntPipe, NotFoundException, Controller, UseGuards } from "@nestjs/common"; import { ApiOperation, ApiResponse, ApiTags } from "@nestjs/swagger"; import { ShiftsArchive, Roles as RoleEnum } from "@prisma/client"; import { RolesAllowed } from "src/common/decorators/roles.decorators"; import { ShiftsService } from "src/modules/shifts/services/shifts.service"; @ApiTags('Shift Archives') // @UseGuards() @Controller('archives/shifts') export class ShiftsArchiveController { constructor(private readonly shiftsService:ShiftsService) {} @Get() @RolesAllowed(RoleEnum.ADMIN, RoleEnum.HR, RoleEnum.SUPERVISOR) @ApiOperation({ summary: 'List of archived shifts'}) @ApiResponse({ status: 200, description: 'List of archived shifts', isArray: true }) async findAllArchived(): Promise { return this.shiftsService.findAllArchived(); } @Get() @RolesAllowed(RoleEnum.ADMIN, RoleEnum.HR,RoleEnum.SUPERVISOR) @ApiOperation({ summary: 'Fetch shift in archives with its Id'}) @ApiResponse({ status: 200, description: 'Archived shift found'}) async findOneArchived(@Param('id', ParseIntPipe) id: number ): Promise { try{ return await this.shiftsService.findOneArchived(id); }catch { throw new NotFoundException(`Archived shift #${id} not found`); } } }