diff --git a/src/orientation/dto/findOrientation.dto.ts b/src/orientation/dto/findOrientation.dto.ts index 476ef01c6458d0864012f4d796575683e7a82200..aca199194fdfe03d2915be6b6731db5c5997933e 100644 --- a/src/orientation/dto/findOrientation.dto.ts +++ b/src/orientation/dto/findOrientation.dto.ts @@ -1,6 +1,10 @@ +import { ApiProperty } from '@nestjs/swagger'; import { IOrientation } from '../interfaces/orientation.interface'; export class FindOrientationDto { + @ApiProperty() myOrientations: { inProgress: IOrientation[]; history: IOrientation[] }; + + @ApiProperty() todoOrientations: { inProgress: IOrientation[]; history: IOrientation[] }; } diff --git a/src/orientation/orientation.controller.ts b/src/orientation/orientation.controller.ts index 19113b58920a34c47f67e1cba488262ef995aeff..997488c34035dd8147a2f639e1d85f24fe8fff25 100644 --- a/src/orientation/orientation.controller.ts +++ b/src/orientation/orientation.controller.ts @@ -6,6 +6,7 @@ import { OrientationService } from './orientation.service'; import { JwtAuthGuard } from '../auth/guards/jwt-auth.guard'; import { RolesGuard } from '../users/guards/roles.guard'; import { Roles } from '../users/decorators/roles.decorator'; +import { FindOrientationDto } from './dto/findOrientation.dto'; @ApiTags('orientation') @Controller('orientation') @@ -15,16 +16,6 @@ export class OrientationController { constructor(private orientationService: OrientationService) {} @Get() - @UseGuards(JwtAuthGuard) - @ApiOperation({ summary: 'Get user orientations' }) - @ApiResponse({ status: 200, description: 'Return user orientations with populated details.' }) - @ApiResponse({ status: 500, description: 'Internal server error.' }) - public async find(@Request() req, @Query('structureId') structureId?: string): Promise<any> { - this.logger.debug(`find for user=${req.user._id}, structureId=${structureId}`); - return this.orientationService.find(req.user._id, structureId); - } - - @Get('admin') @UseGuards(JwtAuthGuard, RolesGuard) @Roles('admin') @ApiOperation({ summary: 'Get all orientations with full details' }) @@ -35,6 +26,16 @@ export class OrientationController { return this.orientationService.findAll(); } + @Get('dashboard') + @UseGuards(JwtAuthGuard) + @ApiOperation({ summary: 'Get user orientations' }) + @ApiResponse({ status: 200, description: 'Return user orientations with populated details.' }) + @ApiResponse({ status: 500, description: 'Internal server error.' }) + public async getDashboard(@Request() req, @Query('structureId') structureId?: string): Promise<FindOrientationDto> { + this.logger.debug(`find for user=${req.user._id}, structureId=${structureId}`); + return this.orientationService.find(req.user._id, structureId); + } + @Post() @UseGuards(JwtAuthGuard) @ApiOperation({ summary: 'Save a new orientation' })